diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c41c1aec72ebc854d5db613bee96f11111463167..50d543456e11864a467e872e6db3e06f6bf5e3c9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,7 +10,8 @@ variables:
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"
- ENCODER_TEST_SUITE: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_basop_encoder.prm"
+ 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: ""
DUT_ENCODER_PATH: "./IVAS_cod"
DUT_DECODER_PATH: "./IVAS_dec"
@@ -41,7 +42,7 @@ variables:
- 'pytest-compare-to-input'
- 'pytest-saturation-smoke-test'
- 'evs-26444'
- - 'sanitizer-stv'
+ - 'sanitizer'
- 'pytest-renderer'
- 'complexity'
- 'coverage'
@@ -82,7 +83,7 @@ workflow:
- 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-stv'
+ - 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'
@@ -493,14 +494,14 @@ stages:
.ivas-pytest-sanitizers-anchor: &ivas-pytest-sanitizers-anchor
stage: test
needs: ["build-codec-linux-make"]
- timeout: "90 minutes"
+ timeout: "300 minutes"
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
when: never
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: never
- if: $CI_PIPELINE_SOURCE == 'schedule' && $IVAS_PYTEST_MSAN
- - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "sanitizer-stv"
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "sanitizer"
script:
- *print-common-info
- *update-scripts-repo
@@ -510,7 +511,7 @@ stages:
- make -j CLANG=$CLANG_NUM
- if [[ $CLANG_NUM == 3 ]]; then export UBSAN_OPTIONS="suppressions=scripts/ubsan.supp,report_error_type=1"; fi
- testcase_timeout=$TESTCASE_TIMEOUT_STV_SANITIZERS
- - python3 -m pytest $SHORT_TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout $testcase_timeout --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH
+ - python3 -m pytest $TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout $testcase_timeout --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH
artifacts:
name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results"
when: always
@@ -733,7 +734,7 @@ build-codec-linux-debugging-make:
# before_script:
# - USE_LTV=0
# - DUT_DECODER_PATH=./IVAS_dec_ref
-# - TEST_SUITE="$SHORT_TEST_SUITE"
+# - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
# - LEVEL_SCALING=1.0
# <<: *ivas-pytest-on-merge-request-anchor
@@ -744,7 +745,7 @@ build-codec-linux-debugging-make:
# before_script:
# - USE_LTV=0
# - DUT_DECODER_PATH=./IVAS_dec_ref
-# - TEST_SUITE="$SHORT_TEST_SUITE"
+# - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
# - LEVEL_SCALING=0.3162
# <<: *ivas-pytest-on-merge-request-anchor
@@ -755,7 +756,7 @@ build-codec-linux-debugging-make:
# before_script:
# - USE_LTV=0
# - DUT_DECODER_PATH=./IVAS_dec_ref
-# - TEST_SUITE="$SHORT_TEST_SUITE"
+# - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
# - LEVEL_SCALING=3.162
# <<: *ivas-pytest-on-merge-request-anchor
@@ -810,7 +811,7 @@ ivas-pytest-compare_to_ref-short-enc:
- USE_LTV=0
- ENCODER_TEST="true"
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- - TEST_SUITE="$ENCODER_TEST_SUITE"
+ - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
- LEVEL_SCALING=1.0
<<: *ivas-pytest-anchor
@@ -823,7 +824,7 @@ ivas-pytest-compare_to_ref-short-enc-lev-10:
- USE_LTV=0
- ENCODER_TEST="true"
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- - TEST_SUITE="$ENCODER_TEST_SUITE"
+ - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
- LEVEL_SCALING=0.3162
<<: *ivas-pytest-anchor
@@ -836,7 +837,7 @@ ivas-pytest-compare_to_ref-short-enc-lev+10:
- USE_LTV=0
- ENCODER_TEST="true"
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- - TEST_SUITE="$ENCODER_TEST_SUITE"
+ - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
- LEVEL_SCALING=3.162
<<: *ivas-pytest-anchor
@@ -846,6 +847,7 @@ ivas-pytest-enc-msan:
before_script:
- CLANG_NUM=1
- DUT_DECODER_PATH=./$REF_DECODER_PATH
+ - TEST_SUITE=$LONG_TEST_SUITE_ENCODER
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-enc-asan:
@@ -854,6 +856,7 @@ ivas-pytest-enc-asan:
before_script:
- CLANG_NUM=2
- DUT_DECODER_PATH=./$REF_DECODER_PATH
+ - TEST_SUITE=$LONG_TEST_SUITE_ENCODER
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-enc-usan:
@@ -862,6 +865,7 @@ ivas-pytest-enc-usan:
before_script:
- CLANG_NUM=3
- DUT_DECODER_PATH=./$REF_DECODER_PATH
+ - TEST_SUITE=$SHORT_TEST_SUITE_ENCODER
<<: *ivas-pytest-sanitizers-anchor
### jobs that test flt encoder -> fx decoder
@@ -921,28 +925,31 @@ ivas-pytest-compare-to-input-short-enc:
- LEVEL_SCALING=1.0
<<: *ivas-pytest-compare-to-input-anchor
-ivas-pytest-dec-msan-short:
+ivas-pytest-dec-msan:
extends:
- .test-job-linux
before_script:
- CLANG_NUM=1
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER
<<: *ivas-pytest-sanitizers-anchor
-ivas-pytest-dec-asan-short:
+ivas-pytest-dec-asan:
extends:
- .test-job-linux
before_script:
- CLANG_NUM=2
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER
<<: *ivas-pytest-sanitizers-anchor
-ivas-pytest-dec-usan-short:
+ivas-pytest-dec-usan:
extends:
- .test-job-linux
before_script:
- CLANG_NUM=3
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
+ - TEST_SUITE=$SHORT_TEST_SUITE
<<: *ivas-pytest-sanitizers-anchor
# ---------------------------------------------------------------
@@ -956,7 +963,7 @@ ivas-pytest-compare_ref-long-enc:
before_script:
- USE_LTV=1
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- - TEST_SUITE="$LONG_TEST_SUITE"
+ - TEST_SUITE="$LONG_TEST_SUITE_ENCODER"
- LEVEL_SCALING=1.0
<<: *ivas-pytest-anchor
@@ -978,7 +985,7 @@ ivas-pytest-compare_ref-long-enc-lev-10:
before_script:
- USE_LTV=1
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- - TEST_SUITE="$LONG_TEST_SUITE"
+ - TEST_SUITE="$LONG_TEST_SUITE_ENCODER"
- LEVEL_SCALING=0.3162
<<: *ivas-pytest-anchor
@@ -1000,7 +1007,7 @@ ivas-pytest-compare_ref-long-enc-lev+10:
before_script:
- USE_LTV=1
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- - TEST_SUITE="$LONG_TEST_SUITE"
+ - TEST_SUITE="$LONG_TEST_SUITE_ENCODER"
- LEVEL_SCALING=3.162
<<: *ivas-pytest-anchor
@@ -1213,16 +1220,6 @@ voip-be-on-merge-request:
- curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts_ref.zip
- unzip -j artifacts_ref.zip "*latest_WMOPS.csv"
- ### 2. part: setup specific for BASOP repo
- # hack for using the reference encoder -> need to build manually to make script use ref enc and BASOP dec
- - mkdir COMPLEXITY
- - cp IVAS_cod_ref COMPLEXITY/IVAS_cod
- # build branch code aain with instrumentation
- - make clean
- - bash scripts/prepare_instrumentation.sh -p BASOP -m MEM_ONLY
- - make -j -C $INSTR_DIR
- - cp $INSTR_DIR/IVAS_dec COMPLEXITY/IVAS_dec
-
.complexity-measurements-prepare-artifacts:
&complexity-measurements-prepare-artifacts # prepare artifacts -> move to public directory
- public_dir="$CI_JOB_NAME-public"
diff --git a/.gitlab/issue_templates/default.md b/.gitlab/issue_templates/default.md
index bacb9fcb0533e52ea2a313408d95a9c74480c743..3e860a4c4f01ef6c21f4ac9b206c115b585b5ffb 100644
--- a/.gitlab/issue_templates/default.md
+++ b/.gitlab/issue_templates/default.md
@@ -2,14 +2,24 @@
-- Encoder (float):
-- Decoder:
+- Float reference:
+ - Encoder (float):
+ - Decoder (float):
+- Fixed point:
+ - Encoder (fixed):
+ - Decoder (fixed):
# Bug description
# Ways to reproduce
-(Clear steps or refer to a failing automated test, e.g. with a pipeline link)
+Box folder: ...\Box_EXTERNAL_IVAS_BASOP_VERIFICATION\issues\issue-xxxx
+
+
+
+```bash
+
+```
diff --git a/.gitlab/issue_templates/default_complexity.md b/.gitlab/issue_templates/default_complexity.md
new file mode 100644
index 0000000000000000000000000000000000000000..f66b1fc82e8312e8486bb4bd785408342fcae764
--- /dev/null
+++ b/.gitlab/issue_templates/default_complexity.md
@@ -0,0 +1,34 @@
+# Basic info
+
+
+
+- Float reference:
+ - Encoder (float):
+ - Decoder (float):
+- Fixed point:
+ - Encoder (fixed):
+ - Decoder (fixed):
+
+# Bug description
+
+| Metric | BASOP | Float |
+|------------|---------|---------|
+| WMOPS Max. | | |
+| WMOPS Min. | | |
+| WMOPS Avg. | | |
+
+# Ways to reproduce
+
+Box folder: ...\Box_EXTERNAL_IVAS_BASOP_VERIFICATION\issues\issue-xxxx
+
+
+
+```bash
+
+```
+
+
+
+/label ~Priority:: ~Company: ~Lib: ~Module:
+/label ~Type:Bug ~Status::ToDo
diff --git a/.gitlab/issue_templates/fixed_point_decoder_crash.md b/.gitlab/issue_templates/fixed_point_decoder_crash.md
new file mode 100644
index 0000000000000000000000000000000000000000..d060e2c696ff30dd33c180635cf27d4acb2a9e0e
--- /dev/null
+++ b/.gitlab/issue_templates/fixed_point_decoder_crash.md
@@ -0,0 +1,24 @@
+# Basic info
+
+
+
+- Encoder and Decoder (float):
+- Decoder (fixed):
+
+# Bug description
+
+# Ways to reproduce
+
+Box folder: ...\Box_EXTERNAL_IVAS_BASOP_VERIFICATION\issues\issue-xxxx
+
+
+
+```bash
+
+```
+
+
+
+/label ~Priority:: ~Company: ~Lib: ~Module:
+/label ~Type:Bug ~Status::ToDo
diff --git a/.gitlab/issue_templates/fixed_point_encoder_crash.md b/.gitlab/issue_templates/fixed_point_encoder_crash.md
new file mode 100644
index 0000000000000000000000000000000000000000..bfd33bc1d59829cf5e4a0767c76b3f0ecba7ffc1
--- /dev/null
+++ b/.gitlab/issue_templates/fixed_point_encoder_crash.md
@@ -0,0 +1,24 @@
+# Basic info
+
+
+
+- Encoder and Decoder (float):
+- Encoder (fixed):
+
+# Bug description
+
+# Ways to reproduce
+
+Box folder: ...\Box_EXTERNAL_IVAS_BASOP_VERIFICATION\issues\issue-xxxx
+
+
+
+```bash
+
+```
+
+
+
+/label ~Priority:: ~Company: ~Lib: ~Module:
+/label ~Type:Bug ~Status::ToDo
diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj
index a18464d878a503ae2e6c14cdfd042800744d1248..9182dd36282cc0652cc43986fb561b0be255385e 100644
--- a/Workspace_msvc/lib_com.vcxproj
+++ b/Workspace_msvc/lib_com.vcxproj
@@ -142,9 +142,7 @@
-
-
@@ -160,7 +158,6 @@
-
@@ -172,19 +169,16 @@
-
-
-
@@ -278,7 +272,6 @@
-
diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters
index 4d60b3abd8ce011126bb7b89fe9a5bfac636a699..93a2b1c00c5b944283f3f7778ccbe44a5f1548ff 100644
--- a/Workspace_msvc/lib_com.vcxproj.filters
+++ b/Workspace_msvc/lib_com.vcxproj.filters
@@ -10,9 +10,6 @@
common_ivas_c
-
- common_ivas_c
-
common_ivas_c
@@ -79,9 +76,6 @@
common_ivas_c
-
- common_all_c
-
common_all_c
@@ -386,15 +380,11 @@
-
-
-
-
@@ -424,7 +414,6 @@
-
diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj
index 384fb8bb1855a74c55dcab5b3087c521a642062f..43e7af2af14af672f137859d9dd72b04aace709b 100644
--- a/Workspace_msvc/lib_enc.vcxproj
+++ b/Workspace_msvc/lib_enc.vcxproj
@@ -229,6 +229,7 @@
+
@@ -238,13 +239,6 @@
-
-
-
-
-
-
-
@@ -278,28 +272,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -331,7 +310,6 @@
-
@@ -414,17 +392,9 @@
-
-
-
-
-
-
-
-
diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters
index 2476cdb6cf5fa921fe54ffb28616676ae9849a81..abc2ccec7162cae15eb0dd94fbadef0a8deabae2 100644
--- a/Workspace_msvc/lib_enc.vcxproj.filters
+++ b/Workspace_msvc/lib_enc.vcxproj.filters
@@ -19,12 +19,6 @@
enc_ivas_c
-
- enc_evs_c
-
-
- enc_evs_c
-
enc_evs_c
@@ -58,21 +52,9 @@
enc_evs_c
-
- enc_evs_c
-
-
- enc_evs_c
-
-
- enc_evs_c
-
enc_evs_c
-
- enc_evs_c
-
enc_evs_c
@@ -115,21 +97,6 @@
enc_evs_c
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
enc_all_c
@@ -193,15 +160,6 @@
enc_all_c
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
enc_all_c
@@ -211,18 +169,9 @@
enc_all_c
-
- enc_all_c
-
enc_all_c
-
- enc_all_c
-
-
- enc_all_c
-
enc_all_c
@@ -238,12 +187,6 @@
enc_all_c
-
- enc_all_c
-
-
- enc_all_c
-
enc_all_c
@@ -334,33 +277,12 @@
enc_all_c
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
enc_all_c
-
- enc_all_c
-
-
- enc_all_c
-
enc_all_c
-
- enc_all_c
-
enc_all_c
@@ -433,12 +355,6 @@
enc_evs_c
-
- enc_evs_c
-
-
- enc_ivas_c
-
enc_ivas_c
@@ -454,9 +370,6 @@
enc_ivas_c
-
- enc_ivas_c
-
enc_ivas_c
@@ -1013,6 +926,9 @@
enc_evs_c
+
+ enc_ivas_c
+
diff --git a/lib_com/basop32.c b/lib_com/basop32.c
index dbdda3aebcaa6963d43fb0d2ffeee54a3a397a70..732e33b2a5ef05c6b47458c63f0c854a73cf7b4d 100644
--- a/lib_com/basop32.c
+++ b/lib_com/basop32.c
@@ -159,7 +159,9 @@ HISTORY:
#include
#include
+#include "options.h"
#include "stl.h"
+
#ifdef BASOP_NOGLOB
#include
#endif /* BASOP_NOGLOB */
@@ -170,10 +172,6 @@ HISTORY:
#pragma warning( disable : 4310 )
#endif
-#ifdef WMOPS
-extern BASIC_OP multiCounter[MAXCOUNTERS];
-extern int currCounter;
-#endif
/*___________________________________________________________________________
| |
diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c
index c465428fc90125779c4ab2505bc28a0684356467..c4f40c6df6080faab71efb203dacdb31e808d86b 100644
--- a/lib_com/basop_util.c
+++ b/lib_com/basop_util.c
@@ -43,7 +43,6 @@
#include "rom_com.h"
#include "rom_basic_math.h"
#include "basop_settings.h"
-#include "control.h"
#include "cnst.h"
@@ -1556,7 +1555,7 @@ Word16 findIndexOfMinWord32( Word32 *x, const Word16 len )
Word16 imult1616( Word16 x, Word16 y )
{
assert( (int) x * (int) y < 32768 && (int) x * (int) y >= -32768 );
- return extract_l( L_mult0( x, y ) );
+ return i_mult( x, y );
}
Word32 imult3216( Word32 x, Word16 y )
diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c
index 480f7e5d630c1e797e4645287a6bdf0abbffa316..5a3d2e1a27b1fd60aba746579f8bc5cee346fe1e 100644
--- a/lib_com/cldfb.c
+++ b/lib_com/cldfb.c
@@ -437,11 +437,11 @@ void cldfbAnalysis_ts_fx(
i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
- i2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
- i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
- i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
- i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
- i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1
r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1
@@ -569,6 +569,278 @@ void cldfbAnalysis_ts_fx(
return;
}
+void cldfbAnalysis_ts_fx_var_q(
+ const Word32 *timeIn_fx,
+ /* i : time buffer */ // q
+ Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ /* o : real value buffer */ // q_cldfb - 5
+ Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ /* o : imag value buffer */ // q_cldfb - 5
+ const Word16 samplesToProcess, /* i : samples to process */
+ HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
+ Word16 *q_cldfb )
+
+{
+ Word16 i, k;
+ Word16 L2, M1, M2, M4;
+ Word16 no_col = h_cldfb->no_col;
+ move16();
+ Word32 r1_fx, r2_fx, rr12_fx, ir12_fx;
+ Word32 i1_fx, i2_fx, ri12_fx, ii12_fx;
+ Word32 rBuffer_fx[2 * CLDFB_NO_CHANNELS_MAX];
+ Word32 iBuffer_fx[2 * CLDFB_NO_CHANNELS_MAX];
+ const Word32 *rot_vctr_re_fx;
+ const Word32 *rot_vctr_im_fx;
+ const Word32 *rot_vctr_delay_re_fx;
+ const Word32 *rot_vctr_delay_im_fx;
+ const Word16 *ptr_pf_fx;
+ Word16 ptr_pf_sf;
+ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
+ Word16 offset, frameSize;
+
+ offset = sub( h_cldfb->p_filter_length, h_cldfb->no_channels );
+ frameSize = i_mult( h_cldfb->no_channels, h_cldfb->no_col );
+
+ /* prepare input buffer */
+ timeBuffer_fx = buffer_fx;
+ Copy32( h_cldfb->cldfb_state_fx, timeBuffer_fx, offset );
+
+ IF( GT_16( samplesToProcess, -1 ) )
+ {
+ Copy32( timeIn_fx, timeBuffer_fx + offset, samplesToProcess );
+ set32_fx( timeBuffer_fx + add( offset, samplesToProcess ), 0, sub( frameSize, samplesToProcess ) );
+ }
+ ELSE
+ {
+ Copy32( timeIn_fx, timeBuffer_fx + offset, frameSize );
+ }
+
+ IF( NE_16( h_cldfb->Q_cldfb_state, *q_cldfb ) )
+ {
+ Word16 norm_st = L_norm_arr( timeBuffer_fx, offset );
+ IF( GE_16( norm_st, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ) )
+ {
+ scale_sig32( timeBuffer_fx, offset, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) );
+ /* cldfb_state will get updated at end of processing with values whose q is same as
+ * *q_cldfb.
+ */
+ h_cldfb->Q_cldfb_state = *q_cldfb;
+ move16();
+ }
+ ELSE
+ {
+ scale_sig32( &timeBuffer_fx[offset], frameSize, sub( h_cldfb->Q_cldfb_state, *q_cldfb ) );
+ *q_cldfb = h_cldfb->Q_cldfb_state;
+ move16();
+ }
+ }
+
+ /* only process needed cols */
+ IF( GT_16( samplesToProcess, -1 ) )
+ {
+ no_col = s_min( no_col, idiv1616( sub( add( samplesToProcess, h_cldfb->no_channels ), 1 ), h_cldfb->no_channels ) );
+ assert( no_col == 1 );
+ }
+
+ M1 = h_cldfb->no_channels;
+ M2 = shr( M1, 1 );
+ M4 = shr( M1, 2 );
+ L2 = shl( M1, 1 );
+ move16();
+
+ if ( s_and( M2, 1 ) )
+ {
+ M4 = add( M4, 1 );
+ }
+
+ rot_vctr_re_fx = h_cldfb->rot_vec_ana_re_fx; // q = 29
+ rot_vctr_im_fx = h_cldfb->rot_vec_ana_im_fx; // q = 29
+ rot_vctr_delay_re_fx = h_cldfb->rot_vec_ana_delay_re_fx; // q = 31
+ rot_vctr_delay_im_fx = h_cldfb->rot_vec_ana_delay_im_fx; // q = 31
+
+ ptr_pf_fx = h_cldfb->p_filter;
+ ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+ move16();
+
+ FOR( i = 0; i < no_col; i++ )
+ {
+ FOR( k = 0; k < M4; k++ )
+ {
+ /* prototype filter */
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+
+ r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1
+ r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1
+ i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1
+ i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1
+
+ /* folding + pre modulation of DST IV */
+ rr12_fx = L_sub( r1_fx, r2_fx ); // q -1
+ ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1
+ /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
+ rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3
+ move32();
+ move32();
+
+ ///* folding + pre modulation of DCT IV */
+ ir12_fx = L_add( r1_fx, r2_fx ); // q - 1
+ ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1
+ /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
+ iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3
+ move32();
+ move32();
+ }
+
+ FOR( k = M4; k < M2; k++ )
+ {
+ /* prototype filter */
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1
+ r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1
+ i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1
+ i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1
+
+ /* folding + pre modulation of DST IV */
+ rr12_fx = L_add( r1_fx, r2_fx ); // q - 1
+ ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1
+ /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
+ rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3
+ move32();
+ move32();
+
+ /* folding + pre modulation of DCT IV */
+ ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1
+ ii12_fx = L_add( i1_fx, i2_fx ); // q - 1
+ /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
+ iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3
+ move32();
+ move32();
+ }
+
+ *q_cldfb = sub( *q_cldfb, 3 );
+ move16();
+
+ /* FFT of DST IV */
+ fft_cldfb_fx( rBuffer_fx, M2 );
+
+ /* post modulation of DST IV */
+ FOR( k = 0; k < M2; k++ )
+ {
+ /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
+ realBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
+ realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
+ move32();
+ move32();
+ }
+ *q_cldfb = sub( *q_cldfb, 2 );
+ move16();
+
+ /* FFT of DCT IV */
+ fft_cldfb_fx( iBuffer_fx, M2 );
+
+ /* post modulation of DCT IV */
+ FOR( k = 0; k < M2; k++ )
+ {
+ /* do it inplace */
+ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
+ imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
+ imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
+ move32();
+ move32();
+ }
+
+ IF( EQ_32( h_cldfb->prototype, CLDFB_PROTOTYPE_5_00MS ) )
+ {
+ /* rotation due to delay*/
+ /*if(h_cldfb->da != M1)*/
+ IF( rot_vctr_delay_re_fx != NULL )
+ {
+ FOR( k = 0; k < M1; k++ )
+ {
+ Word32 cplx_aux_fx;
+ /* delay */
+ /*cplxMult(&rBuffer[k], &iBuffer[k], realBuffer[i][k], imagBuffer[i][k], cos((EVS_PI/M1)*(k+0.5)*((h_cldfb->da-M1)*0.5)),
+ sin((EVS_PI/M1)*(k+0.5)*((h_cldfb->da-M1)*0.5)));*/
+ /*cplxMult(&rBuffer[k], &iBuffer[k], realBuffer[k], imagBuffer[k], rot_vctr_delay_re[k], rot_vctr_delay_im[k]);*/
+ /*cplxMult(&realBuffer[k], &imagBuffer[k], realBuffer[k], imagBuffer[k], rot_vctr_delay_re[k], rot_vctr_delay_im[k]);*/
+ /*realBuffer[k] = rBuffer[k];
+ imagBuffer[k] = iBuffer[k];*/
+ cplx_aux_fx = Msub_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ); // q - 5
+ imagBuffer_fx[k] = Madd_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ); // q - 5
+ realBuffer_fx[k] = cplx_aux_fx;
+ move32();
+ move32();
+ }
+ }
+ }
+
+ timeBuffer_fx += i_mult( L2, 5 );
+ timeBuffer_fx += sub( h_cldfb->no_channels, h_cldfb->p_filter_length );
+ }
+
+ /* update memory */
+ IF( GT_16( samplesToProcess, -1 ) )
+ {
+ Copy32( buffer_fx + samplesToProcess, h_cldfb->cldfb_state_fx, offset );
+ }
+ ELSE
+ {
+ Copy32( buffer_fx + frameSize, h_cldfb->cldfb_state_fx, offset );
+ }
+
+ return;
+}
+
+
void cldfbAnalysis_ts_fx_fixed_q(
const Word32 *timeIn_fx,
/* i : time buffer */ // q
diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c
index f346f3bb3e4a39ac08c5fe664f3d06f9ba6967d7..6ca0d4c3a4dd00bfea52492faa4dcc4ce3de12a7 100644
--- a/lib_com/cng_exc_fx.c
+++ b/lib_com/cng_exc_fx.c
@@ -866,7 +866,7 @@ void cng_params_postupd_ivas_fx(
apply_scale( &att_fx, bwidth, last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO );
att_fx = L_shr( Mpy_32_16_1( att_fx, 26214 ), 3 ); /* 26214 = 0.1f in Q18 */
att_fx = BASOP_Util_fPow( 1342177280 /* 10 in Q27 */, 4, att_fx, 8, &tmp );
- tmp = extract_h( L_shl( att_fx, tmp ) );
+ tmp = extract_h( L_shl_sat( att_fx, tmp ) ); // Fix for 3gpp #1080 (tmp set to 1.0)
}
ELSE
{
diff --git a/lib_com/cnst.h b/lib_com/cnst.h
index 7e65723827fc815ad4a78a1bf7d85249c22661a7..fe16db670a45815e431324c572e699d454512c4a 100644
--- a/lib_com/cnst.h
+++ b/lib_com/cnst.h
@@ -747,10 +747,8 @@ enum
#define PIT_UP_SAMP6 6
#define PIT_L_INTERPOL6_2 17
#define PIT_FIR_SIZE6_2 ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 )
-#define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/
#define E_MIN 0.0035f /* minimum allowable energy */
#define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/
-#define E_MIN_Q16_FX 229 /* minimum allowable energy in Q16*/
#define STEP_DELTA 0.0625f /* quantization step for tilt compensation of gaussian cb. excitation */
#define GAMMA_EV 0.92f /* weighting factor for core synthesis error weighting */
#define FORMANT_SHARPENING_NOISE_THRESHOLD 21.0f /* lp_noise level above which formant sharpening is deactivated */
@@ -1937,7 +1935,7 @@ typedef enum _DCTTYPE
#define N_SMC_FEATURES 15 /* number of features */
#define N_SMC_MIXTURES 6 /* number of mixtures */
#define N_PCA_COEF 12 /* number of PCA components */
-#define HALF_N_PCA_COEF_LOG_P12_Q19 5781461//Q19 of (0.5f * N_PCA_COEF *logf( PI2 ))
+#define HALF_N_PCA_COEF_LOG_P12_Q18 2890731 //Q18 of (0.5f * N_PCA_COEF *logf( PI2 ))
#define SMC_ST_MEAN_FACT 0.5 /* forgetting factor of short-term IIR mean filter */
#define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */
@@ -2776,6 +2774,7 @@ enum
#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */
#define E_MIN_FXQ15 115 /* Q15*/
+#define E_MIN_FXQ31 7516193 /* 0.0035d in Q31*/
#define MAX_DYNAMIC_FX (82*128)
#define MIN_DYNAMIC_FX (50*128)
diff --git a/lib_com/complex_basop.c b/lib_com/complex_basop.c
index ffe56d47545610529d208ab39b4d0f9c5b2c4757..cf3b40154acf5119739354e855db0e55a78822cd 100644
--- a/lib_com/complex_basop.c
+++ b/lib_com/complex_basop.c
@@ -9,22 +9,9 @@
*****************************************************************************/
-#include "typedef.h"
-#include "basop32.h"
-
-#include "complex_basop.h"
-
#include "stl.h"
-
-#ifdef WMOPS
-
-extern BASIC_OP multiCounter[MAXCOUNTERS];
-
-extern int currCounter;
-
-#endif /* if WMOPS */
-
+#define WMC_TOOL_SKIP
#ifdef COMPLEX_OPERATOR
diff --git a/lib_com/complex_basop.h b/lib_com/complex_basop.h
index 117ba400e427883a5777c221f12b9950c93e3c63..bf1641e749960b5fdf2c9ee4130ebce852f39c81 100644
--- a/lib_com/complex_basop.h
+++ b/lib_com/complex_basop.h
@@ -10,8 +10,6 @@
#ifndef _COMPLEX_BASIC_OP_H
#define _COMPLEX_BASIC_OP_H
-#include "typedef.h"
-#include "basop32.h"
#include "stl.h"
#ifdef COMPLEX_OPERATOR
diff --git a/lib_com/control.c b/lib_com/control.c
deleted file mode 100644
index dadb2e4967166a786333097c5102c3745397d491..0000000000000000000000000000000000000000
--- a/lib_com/control.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- ===========================================================================
- File: CONTROL.C v.2.3 - 30.Nov.2009
- ===========================================================================
-
- ITU-T STL BASIC OPERATORS
-
- CONTROL FLOW OPERATOR INTERNAL VARIABLE DECLARATIONS
-
- History:
- 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
- operators for the ITU-T Standard Tool Library as
- described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
- TD 11 document and subsequent discussions on the
- wp3audio@yahoogroups.com email reflector.
- March 06 v2.1 Changed to improve portability.
-
- ============================================================================
-*/
-
-#include "stl.h"
-
-#ifdef WMOPS
-long funcid_total_wmops_at_last_call_to_else;
-#ifdef FIX_1054_IF_ELSE_CMPLX
-char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1] = "";
-#else
-int funcId_where_last_call_to_else_occurred;
-int call_occurred = 1;
-#endif
-#endif
-
-#ifdef CONTROL_CODE_OPS
-
-Flag LT_16( Word16 var1, Word16 var2 )
-{
- Flag F_ret = 0;
-
- if ( var1 < var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].LT_16++;
-#endif
- return F_ret;
-}
-
-Flag GT_16( Word16 var1, Word16 var2 )
-{
- Flag F_ret = 0;
-
- if ( var1 > var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].GT_16++;
-#endif
- return F_ret;
-}
-
-Flag LE_16( Word16 var1, Word16 var2 )
-{
- Flag F_ret = 0;
-
- if ( var1 <= var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].LE_16++;
-#endif
- return F_ret;
-}
-
-Flag GE_16( Word16 var1, Word16 var2 )
-{
- Flag F_ret = 0;
-
- if ( var1 >= var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].GE_16++;
-#endif
- return F_ret;
-}
-
-Flag EQ_16( Word16 var1, Word16 var2 )
-{
- Flag F_ret = 0;
-
- if ( var1 == var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].EQ_16++;
-#endif
- return F_ret;
-}
-
-Flag NE_16( Word16 var1, Word16 var2 )
-{
- Flag F_ret = 0;
-
- if ( var1 != var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].NE_16++;
-#endif
- return F_ret;
-}
-
-Flag LT_32( Word32 L_var1, Word32 L_var2 )
-{
- Flag F_ret = 0;
-
- if ( L_var1 < L_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].LT_32++;
-#endif
- return F_ret;
-}
-
-Flag GT_32( Word32 L_var1, Word32 L_var2 )
-{
- Flag F_ret = 0;
-
- if ( L_var1 > L_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].GT_32++;
-#endif
- return F_ret;
-}
-
-Flag LE_32( Word32 L_var1, Word32 L_var2 )
-{
- Flag F_ret = 0;
-
- if ( L_var1 <= L_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].LE_32++;
-#endif
- return F_ret;
-}
-
-Flag GE_32( Word32 L_var1, Word32 L_var2 )
-{
- Flag F_ret = 0;
-
- if ( L_var1 >= L_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].GE_32++;
-#endif
- return F_ret;
-}
-
-Flag EQ_32( Word32 L_var1, Word32 L_var2 )
-{
- Flag F_ret = 0;
-
- if ( L_var1 == L_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].EQ_32++;
-#endif
- return F_ret;
-}
-
-Flag NE_32( Word32 L_var1, Word32 L_var2 )
-{
- Flag F_ret = 0;
-
- if ( L_var1 != L_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].NE_32++;
-#endif
- return F_ret;
-}
-
-Flag LT_64( Word64 L64_var1, Word64 L64_var2 )
-{
- Flag F_ret = 0;
-
- if ( L64_var1 < L64_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].LT_64++;
-#endif
- return F_ret;
-}
-
-Flag GT_64( Word64 L64_var1, Word64 L64_var2 )
-{
- Flag F_ret = 0;
-
- if ( L64_var1 > L64_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].GT_64++;
-#endif
- return F_ret;
-}
-
-Flag LE_64( Word64 L64_var1, Word64 L64_var2 )
-{
- Flag F_ret = 0;
-
- if ( L64_var1 <= L64_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].LE_64++;
-#endif
- return F_ret;
-}
-Flag GE_64( Word64 L64_var1, Word64 L64_var2 )
-{
- Flag F_ret = 0;
-
- if ( L64_var1 >= L64_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].GE_64++;
-#endif
- return F_ret;
-}
-
-Flag EQ_64( Word64 L64_var1, Word64 L64_var2 )
-{
- Flag F_ret = 0;
-
- if ( L64_var1 == L64_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].EQ_64++;
-#endif
- return F_ret;
-}
-Flag NE_64( Word64 L64_var1, Word64 L64_var2 )
-{
- Flag F_ret = 0;
-
- if ( L64_var1 != L64_var2 )
- {
- F_ret = 1;
- }
-#ifdef WMOPS
- multiCounter[currCounter].NE_64++;
-#endif
- return F_ret;
-}
-
-#endif /* #ifdef CONTROL_CODE_OPS */
-
-
-/* end of file */
diff --git a/lib_com/control.h b/lib_com/control.h
deleted file mode 100644
index c788cac140d174f56799e577ec66d7355dfe4f91..0000000000000000000000000000000000000000
--- a/lib_com/control.h
+++ /dev/null
@@ -1,408 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-#ifndef _CONTROL_H
-#define _CONTROL_H
-
-#include
-#include "stl.h"
-
-/*****************************************************************************
- *
- * Constants and Globals
- *
- *****************************************************************************/
-#ifdef WMOPS
-extern BASIC_OP multiCounter[MAXCOUNTERS];
-extern int currCounter;
-
-#define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */
-
-extern long funcid_total_wmops_at_last_call_to_else;
-#ifdef FIX_1054_IF_ELSE_CMPLX
-extern char func_name_where_last_call_to_else_occurred[];
-#else
-/* Technical note :
- * The following 3 variables are only used for correct complexity
- * evaluation of the following structure :
- * IF{
- * ...
- * } ELSE IF {
- * ...
- * } ELSE IF {
- * ...
- * }
- * ...
- * } ELSE {
- * ...
- * }
- */
-
-extern int call_occurred;
-extern int funcId_where_last_call_to_else_occurred;
-#endif
-#endif /* ifdef WMOPS */
-
-
-/*****************************************************************************
- *
- * Function Macros
- *
- *****************************************************************************/
-
-/*****************************************************************************
- *
- * Function Name : FOR
- *
- * Purpose :
- *
- * The macro FOR should be used instead of the 'for' C statement.
- * The complexity is independent of the number of loop iterations that are
- * performed.
- *
- * Complexity weight : 3 (regardless of number of iterations).
- *
- *****************************************************************************/
-#ifndef WMOPS
-#define FOR( a ) for ( a )
-
-#else /* ifndef WMOPS */
-#define FOR( a ) \
- if ( incrFor(), 0 ) \
- ; \
- else \
- for ( a )
-
-static __inline void incrFor( void )
-{
- multiCounter[currCounter].For++;
-}
-#endif /* ifndef WMOPS */
-
-
-/*****************************************************************************
- *
- * Function Name : WHILE
- *
- * Purpose :
- *
- * The macro WHILE should be used instead of the 'while' C statement.
- * The complexity is proportional to the number of loop iterations that
- * are performed.
- *
- * Complexity weight : 4 x 'number of loop iterations'.
- *
- *****************************************************************************/
-#ifndef WMOPS
-#define WHILE( a ) while ( a )
-
-#else /* ifndef WMOPS */
-#define WHILE( a ) while ( incrWhile(), a )
-
-static __inline void incrWhile( void )
-{
- multiCounter[currCounter].While++;
-}
-#endif /* ifndef WMOPS */
-
-
-/*****************************************************************************
- *
- * Function Name : DO
- *
- * Purpose :
- *
- * The macro DO should be used instead of the 'do' C statement.
- *
- * Complexity weight : 0 (complexity counted by WHILE macro).
- *
- *****************************************************************************/
-#ifndef WMOPS
-#define DO do
-
-#else /* ifndef WMOPS */
-#define DO do
-
-#endif /* ifndef WMOPS */
-
-
-/*****************************************************************************
- *
- * Function Name : IF
- *
- * Purpose :
- *
- * The macro IF should :
- *
- * - not be used when :
- * - the 'if' structure does not have any 'else if' nor 'else' statement
- * - and it conditions only one DSP basic operations.
- *
- * - be used instead of the 'if' C statement in every other case :
- * - when there is an 'else' or 'else if' statement,
- * - or when the 'if' conditions several DSP basic operations,
- * - or when the 'if' conditions a function call.
- *
- * Complexity weight : 4
- *
- *****************************************************************************/
-#ifndef WMOPS
-#define IF( a ) if ( a )
-
-#else /* ifndef WMOPS */
-#ifdef FIX_1054_IF_ELSE_CMPLX
-#define IF( a ) if ( incrIf( __func__ ), a )
-#else
-#define IF( a ) if ( incrIf(), a )
-#endif
-
-#ifdef FIX_1054_IF_ELSE_CMPLX
-static __inline void incrIf( const char *func_name )
-#else
-static __inline void incrIf( void )
-#endif
-{
- /* Technical note :
- * If the "IF" operator comes just after an "ELSE", its counter
- * must not be incremented.
- */
-#ifdef FIX_1054_IF_ELSE_CMPLX
- if ( ( strncmp( func_name, func_name_where_last_call_to_else_occurred, MAX_FUNCTION_NAME_LENGTH ) != 0 ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) )
- {
-
- multiCounter[currCounter].If++;
- }
-
- func_name_where_last_call_to_else_occurred[0] = '\0';
-#else
- if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) )
- multiCounter[currCounter].If++;
-
- call_occurred = 0;
- funcId_where_last_call_to_else_occurred = MAXCOUNTERS;
-#endif
-}
-#endif /* ifndef WMOPS */
-
-
-/*****************************************************************************
- *
- * Function Name : ELSE
- *
- * Purpose :
- *
- * The macro ELSE should be used instead of the 'else' C statement.
- *
- * Complexity weight : 4
- *
- *****************************************************************************/
-#ifndef WMOPS
-#define ELSE else
-
-#else /* ifndef WMOPS */
-#ifdef FIX_1054_IF_ELSE_CMPLX
-#define ELSE \
- else if ( incrElse( __func__ ), 0 ); \
- else
-#else
-#define ELSE \
- else if ( incrElse(), 0 ); \
- else
-#endif
-
-#ifdef FIX_1054_IF_ELSE_CMPLX
-static __inline void incrElse( const char *func_name )
-#else
-static __inline void incrElse( void )
-#endif
-{
- multiCounter[currCounter].If++;
-
- /* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */
- funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation();
-
-#ifdef FIX_1054_IF_ELSE_CMPLX
- /* We keep track of the name of the last calling function when the ELSE macro was called */
- strncpy( func_name_where_last_call_to_else_occurred, func_name, MAX_FUNCTION_NAME_LENGTH );
- func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH] = '\0';
-#else
- /* We keep track of the funcId of the last function which used ELSE {...} structure. */
- funcId_where_last_call_to_else_occurred = currCounter;
-
- /* call_occurred is set to 0, in order to count the next IF (if necessary) */
- call_occurred = 0;
-#endif
-}
-#endif /* ifndef WMOPS */
-
-
-/*****************************************************************************
- *
- * Function Name : SWITCH
- *
- * Purpose :
- *
- * The macro SWITCH should be used instead of the 'switch' C statement.
- *
- * Complexity weight : 8
- *
- *****************************************************************************/
-#ifndef WMOPS
-#define SWITCH( a ) switch ( a )
-
-#else /* ifndef WMOPS */
-#define SWITCH( a ) switch ( incrSwitch(), a )
-
-static __inline void incrSwitch( void )
-{
- multiCounter[currCounter].Switch++;
-}
-#endif /* ifndef WMOPS */
-
-
-/*****************************************************************************
- *
- * Function Name : CONTINUE
- *
- * Purpose :
- *
- * The macro CONTINUE should be used instead of the 'continue' C statement.
- *
- * Complexity weight : 4
- *
- *****************************************************************************/
-#ifndef WMOPS
-#define CONTINUE continue
-
-#else /* ifndef WMOPS */
-#define CONTINUE \
- if ( incrContinue(), 0 ) \
- ; \
- else \
- continue
-
-static __inline void incrContinue( void )
-{
- multiCounter[currCounter].Continue++;
-}
-#endif /* ifndef WMOPS */
-
-
-/*****************************************************************************
- *
- * Function Name : BREAK
- *
- * Purpose :
- *
- * The macro BREAK should be used instead of the 'break' C statement.
- *
- * Complexity weight : 4
- *
- *****************************************************************************/
-#ifndef WMOPS
-#define BREAK break
-
-#else /* ifndef WMOPS */
-#define BREAK \
- if ( incrBreak(), 0 ) \
- ; \
- else \
- break
-
-static __inline void incrBreak( void )
-{
- multiCounter[currCounter].Break++;
-}
-#endif /* ifndef WMOPS */
-
-
-/*****************************************************************************
- *
- * Function Name : GOTO
- *
- * Purpose :
- *
- * The macro GOTO should be used instead of the 'goto' C statement.
- *
- * Complexity weight : 4
- *
- *****************************************************************************/
-#ifndef WMOPS
-#define GOTO goto
-
-#else /* ifndef WMOPS */
-#define GOTO \
- if ( incrGoto(), 0 ) \
- ; \
- else \
- goto
-
-static __inline void incrGoto( void )
-{
- multiCounter[currCounter].Goto++;
-}
-#endif /* ifndef WMOPS */
-
-
-/*
- * New control code basops
- */
-#ifdef CONTROL_CODE_OPS
-
-Flag LT_16( Word16 var1, Word16 var2 );
-Flag GT_16( Word16 var1, Word16 var2 );
-Flag LE_16( Word16 var1, Word16 var2 );
-Flag GE_16( Word16 var1, Word16 var2 );
-Flag EQ_16( Word16 var1, Word16 var2 );
-Flag NE_16( Word16 var1, Word16 var2 );
-
-Flag LT_32( Word32 L_var1, Word32 L_var2 );
-Flag GT_32( Word32 L_var1, Word32 L_var2 );
-Flag LE_32( Word32 L_var1, Word32 L_var2 );
-Flag GE_32( Word32 L_var1, Word32 L_var2 );
-Flag EQ_32( Word32 L_var1, Word32 L_var2 );
-Flag NE_32( Word32 L_var1, Word32 L_var2 );
-
-Flag LT_64( Word64 L64_var1, Word64 L64_var2 );
-Flag GT_64( Word64 L64_var1, Word64 L64_var2 );
-Flag LE_64( Word64 L64_var1, Word64 L64_var2 );
-Flag GE_64( Word64 L64_var1, Word64 L64_var2 );
-Flag EQ_64( Word64 L64_var1, Word64 L64_var2 );
-Flag NE_64( Word64 L64_var1, Word64 L64_var2 );
-
-
-#endif /* #ifdef CONTROL_CODE_OPS */
-
-#endif /* _CONTROL_H */
-
-
-/* end of file */
diff --git a/lib_com/count.c b/lib_com/count.c
deleted file mode 100644
index ce38def6716e73c2ccb0ce7f15913873d698f0dd..0000000000000000000000000000000000000000
--- a/lib_com/count.c
+++ /dev/null
@@ -1,1399 +0,0 @@
-/*
- ===========================================================================
- File: COUNT.C v.2.3 - 30.Nov.2009
- ===========================================================================
-
- ITU-T STL BASIC OPERATORS
-
- COMPLEXITY EVALUATION FUNCTIONS
-
- History:
- 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
- operators for the ITU-T Standard Tool Library as
- described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
- TD 11 document and subsequent discussions on the
- wp3audio@yahoogroups.com email reflector.
- norm_s() weight reduced from 15 to 1.
- norm_l() weight reduced from 30 to 1.
- L_abs() weight reduced from 2 to 1.
- L_add() weight reduced from 2 to 1.
- L_negate() weight reduced from 2 to 1.
- L_shl() weight reduced from 2 to 1.
- L_shr() weight reduced from 2 to 1.
- L_sub() weight reduced from 2 to 1.
- mac_r() weight reduced from 2 to 1.
- msu_r() weight reduced from 2 to 1.
- mult_r() weight reduced from 2 to 1.
- L_deposit_h() weight reduced from 2 to 1.
- L_deposit_l() weight reduced from 2 to 1.
- March 06 v2.1 Changed to improve portability.
- Dec 06 v2.2 Changed to specify frame rate using setFrameRate()
- Adding WMOPS_output_avg() for global average computation
- L_mls() weight of 5.
- div_l() weight of 32.
- i_mult() weight of 3.
- ============================================================================
-*/
-
-
-/*****************************************************************************
- *
- * This file contains functions for the automatic complexity calculation
- *
- *****************************************************************************/
-
-
-#include
-#include
-#include
-#include
-#include "stl.h"
-#include "options.h"
-#include "wmc_auto.h"
-
-#ifndef WMOPS
-#include "options_warnings.h"
-#endif
-
-#define WMC_TOOL_SKIP
-
-#ifdef WMOPS
-static double frameRate = FRAME_RATE; /* default value : 10 ms */
-
-#define MAX_RECORDS 1024
-#define MAX_STACK 64
-#define MAX_CHAR 64
-
-// struct wmops_record
-//{
-// char label[MAX_CHAR];
-// long call_number;
-// long update_cnt;
-// int call_tree[MAX_RECORDS];
-// double start_selfcnt;
-// double current_selfcnt;
-// double max_selfcnt;
-// double min_selfcnt;
-// double tot_selfcnt;
-// double start_cnt; /* The following take into account the decendants */
-// double current_cnt;
-// double max_cnt;
-// double min_cnt;
-// double tot_cnt;
-// };
-//
-// static struct wmops_record wmops[MAX_RECORDS];
-
-static int stack[MAX_STACK];
-static int sptr;
-static int sum_stack[MAX_STACK];
-
-/* Global counter variable for calculation of complexity weight */
-/* Some enhancement written by Vail., GJR and M.Mul. during EVS time */
-
-BASIC_OP multiCounter[MAXCOUNTERS];
-BASIC_OP glob_multiCounter;
-int currCounter = 0; /* Zero equals global counter */
-
-void setFrameRate( int samplingFreq, int frameLength )
-{
- if ( frameLength > 0 )
- {
- frameRate = samplingFreq / 1000000.0 / frameLength;
- }
- return;
-}
-
-
-/*
- * Below list is used for displaying the code profiling information in
- * the file which name is defined by CODE_PROFILE_FILENAME.
- * For further details see generic_WMOPS_output() function.
- * Attention, the ordering in this table must be kept in synchronisation
- * with the structure definition BASIC_OP.
- */
-char *BasicOperationList[] = {
- "add", "sub", "abs_s", "shl", "shr",
- "extract_h", "extract_l", "mult", "L_mult", "negate",
- "round", "L_mac", "L_msu", "L_macNs", "L_msuNs",
- "L_add", "L_sub", "L_add_c", "L_sub_c", "L_negate",
- "L_shl", "L_shr", "mult_r", "shr_r", "mac_r",
-
- "msu_r", "L_deposit_h", "L_deposit_l", "L_shr_r", "L_abs",
- "L_sat", "norm_s", "div_s", "norm_l", "move16",
- "move32", "Logic16", "Logic32", "Test", "s_max",
- "s_min", "L_max", "L_min", "L40_max", "L40_min",
- "shl_r", "L_shl_r", "L40_shr_r", "L40_shl_r", "norm_L40",
-
- "L40_shl", "L40_shr", "L40_negate", "L40_add", "L40_sub",
- "L40_abs", "L40_mult", "L40_mac", "mac_r40",
- "L40_msu", "msu_r40", "Mpy_32_16_ss", "Mpy_32_32_ss", "L_mult0",
- "L_mac0", "L_msu0", "lshl", "lshr", "L_lshl",
- "L_lshr", "L40_lshl", "L40_lshr", "s_and", "s_or",
-
- "s_xor", "L_and", "L_or", "L_xor", "rotl",
- "rotr", "L_rotl", "L_rotr", "L40_set", "L40_deposit_h",
- "L40_deposit_l", "L40_deposit32", "Extract40_H", "Extract40_L", "L_Extract40",
- "L40_round", "L_saturate40", "round40", "IF", "GOTO",
- "BREAK", "SWITCH", "FOR", "WHILE", "CONTINUE",
-
- "L_mls", "div_l", "i_mult"
-
-/* New complex basops */
-#ifdef COMPLEX_OPERATOR
- ,
- "CL_shr", "CL_shl", "CL_add", "CL_sub", "CL_scale", "CL_dscale", "CL_msu_j", "CL_mac_j", "CL_move", "CL_Extract_real", "CL_Extract_imag", "CL_form", "CL_multr_32x16", "CL_negate", "CL_conjugate", "CL_mul_j", "CL_swap_real_imag", "C_add", "C_sub", "C_mul_j", "C_multr", "C_form"
-
- ,
- "C_scale", "CL_round32_16", "CL_scale_32", "CL_dscale_32", "CL_multr_32x32", "C_mac_r", "C_msu_r", "C_Extract_real", "C_Extract_imag", "C_negate", "C_conjugate", "C_shr", "C_shl"
-
-#endif /* #ifdef COMPLEX_OPERATOR */
-
-/* New 64 bit basops */
-#ifdef ENH_64_BIT_OPERATOR
- ,
- "move64", "W_add_nosat", "W_sub_nosat", "W_shl", "W_shr", "W_shl_nosat", "W_shr_nosat", "W_mac_32_16", "W_msu_32_16", "W_mult_32_16", "W_mult0_16_16", "W_mac0_16_16", "W_msu0_16_16", "W_mult_16_16", "W_mac_16_16", "W_msu_16_16", "W_shl_sat_l", "W_sat_l", "W_sat_m", "W_deposit32_l", "W_deposit32_h", "W_extract_l", "W_extract_h", "W_round48_L", "W_round32_s", "W_norm", "W_add", "W_sub", "W_neg", "W_abs", "W_mult_32_32", "W_mult0_32_32", "W_lshl", "W_lshr", "W_round64_L"
-
-#endif /* #ifdef ENH_64_BIT_OPERATOR */
-
-#ifdef ENH_32_BIT_OPERATOR
- ,
- "Mpy_32_16_1", "Mpy_32_16_r", "Mpy_32_32", "Mpy_32_32_r", "Madd_32_16", "Madd_32_16_r", "Msub_32_16", "Msub_32_16_r", "Madd_32_32", "Madd_32_32_r", "Msub_32_32", "Msub_32_32_r"
-#endif /* #ifdef ENH_32_BIT_OPERATOR */
-
-#ifdef ENH_U_32_BIT_OPERATOR
- ,
- "UL_addNs", "UL_subNs", "UL_Mpy_32_32", "Mpy_32_32_uu", "Mpy_32_16_uu", "norm_ul_float", "UL_deposit_l"
-#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
-
-#ifdef CONTROL_CODE_OPS
- ,
- "LT_16", "GT_16", "LE_16", "GE_16", "EQ_16", "NE_16", "LT_32", "GT_32", "LE_32", "GE_32", "EQ_32", "NE_32", "LT_64", "GT_64", "LE_64", "GE_64", "EQ_64", "NE_64"
-#endif /* #ifdef CONTROL_CODE_OPS */
-
-};
-
-
-const BASIC_OP op_weight = {
- 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1,
- 1, 1, 2, 2, 1,
- 1, 1, 1, 2, 1,
-
- 1, 1, 1, 2, 1,
- 1, 1, 18, 1, 1,
- 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 1,
-
- 1, 1, 1, 1, 1,
- 1, 1, 1, 2,
- 1, 2, 2, 2, 1,
- 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 3,
- 3, 3, 3, 1, 1,
- 1, 1, 1, 1, 1,
- 1, 1, 1, 3, 2,
- 2, 6, 3, 3, 2,
-
- 1, 32, 1
-
-/* New complex basops */
-#ifdef COMPLEX_OPERATOR
- ,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1
-
- ,
- 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1
-
-#endif /* #ifdef COMPLEX_OPERATOR */
-
-#ifdef ENH_64_BIT_OPERATOR
- /* Weights of new 64 bit basops */
- ,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-#endif /* #ifdef ENH_64_BIT_OPERATOR */
-
-#ifdef ENH_32_BIT_OPERATOR
- ,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-#endif /* #ifdef ENH_32_BIT_OPERATOR */
-
-#ifdef ENH_U_32_BIT_OPERATOR
- ,
- 1, 1, 1, 2, 2, 1, 1
-#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
-
-#ifdef CONTROL_CODE_OPS
- ,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-#endif /* #ifdef CONTROL_CODE_OPS */
-};
-#endif /* ifdef WMOPS */
-
-
-Word32 TotalWeightedOperation( void );
-Word32 DeltaWeightedOperation( void );
-
-
-#ifdef WMOPS
-/* Counters for separating counting for different objects */
-
-/* FROM_EVS_DEV */
-/**
-maxCounter: current number of counters. Each scope initialized with BASOP_sub_start() gets a own counter assigned.
-objectName: Name of each counter passed to BASOP_sub_start().
-fwc_corr:
-nbTimeObjectIsCalled: number of times a counter (object) is referenced in the current frame.
-*/
-
-static int maxCounter = 0;
-static char *objectName[MAXCOUNTERS + 1];
-
-static Word16 fwc_corr[MAXCOUNTERS + 1];
-static long int nbTimeObjectIsCalled[MAXCOUNTERS + 1];
-
-
-#define NbFuncMax ( 4096 )
-
-
-/**
- funcid: current function call for each counter
- bc : best case for each counter and function call
- wc : worst case for each counter and function call
- nbframe: number of frames for each counter.
- glob_bc: global best case self time for each counter for current frame.
- glob_wc: global worst case self time for each counter for current frame.
- glob_sum_curr: global cummulative time for each counter for current frame.
- glob_sum_bc: global best case cummulative time for each counter for current frame.
- glob_sum_wc: global worst case cummulative time for each counter for current frame.
-
- total_wmops: total wmops self time for each counter for current frame.
- total_sum: total wmops cummulative time for each counter for current frame.
- LastWOper: values used for WMOPS deltas
- */
-
-static Word32 funcid[MAXCOUNTERS], nbframe[MAXCOUNTERS], nbcalls[MAXCOUNTERS];
-static Word32 glob_bc[MAXCOUNTERS], glob_wc[MAXCOUNTERS], bc[MAXCOUNTERS][NbFuncMax], wc[MAXCOUNTERS][NbFuncMax];
-static float total_wmops[MAXCOUNTERS];
-static Word32 LastWOper[MAXCOUNTERS];
-/* FROM_EVS_DEV */
-static float total_sum[MAXCOUNTERS];
-static Word16 call_tree[MAXCOUNTERS][MAXCOUNTERS];
-static int sum_curr[MAXCOUNTERS + 1];
-static int sum_bc[MAXCOUNTERS + 1];
-static int sum_wc[MAXCOUNTERS + 1];
-static int glob_sum_curr[MAXCOUNTERS + 1];
-static int glob_sum_bc[MAXCOUNTERS + 1];
-static int glob_sum_wc[MAXCOUNTERS + 1];
-#if MAX_CALLERS_SAVED_FRAMES
-#define MAX_CALLERS_PRINT 20
-static float callers_frames[MAX_CALLERS_SAVED_FRAMES + 1][MAXCOUNTERS + 1];
-static int callers_frames_nos[MAX_CALLERS_SAVED_FRAMES];
-static float callers_totals[MAX_CALLERS_SAVED_FRAMES];
-#endif
-
-#endif /* ifdef WMOPS */
-
-
-#ifdef WMOPS
-static char *my_strdup( const char *s )
-{
- /*
- * duplicates UNIX function strdup() which is not ANSI standard:
- * -- malloc() memory area big enough to hold the string s
- * -- copy string into new area
- * -- return pointer to new area
- *
- * returns NULL if either s==NULL or malloc() fails
- */
- char *dup;
-
- if ( s == NULL )
- return NULL;
-
- /* allocate memory for copy of ID string (including string terminator) */
- /* NOTE: the ID strings will never be deallocated because there is no way to "destroy" a counter that is not longer needed */
- if ( ( dup = (char *) malloc( strlen( s ) + 1 ) ) == NULL )
- return NULL;
-
- return strcpy( dup, s );
-}
-#endif /* ifdef WMOPS */
-
-
-int getCounterId( const char *objectNameArg )
-{
-#ifdef WMOPS
- if ( maxCounter >= MAXCOUNTERS - 1 )
- return 0;
- objectName[++maxCounter] = my_strdup( objectNameArg );
- return maxCounter;
-
-#else /* ifdef WMOPS */
- (void) objectNameArg;
- return 0; /* Dummy */
-
-#endif /* ifdef WMOPS */
-}
-
-
-#ifdef WMOPS
-int readCounterId()
-{
- return currCounter;
-}
-#endif /* ifdef WMOPS */
-
-
-#ifdef WMOPS
-char *readCounterIdName()
-{
- return objectName[currCounter];
-}
-#endif /* ifdef WMOPS */
-
-void setCounter( int counterId )
-{
-#ifdef WMOPS
- if ( ( counterId > maxCounter ) || ( counterId < 0 ) )
- {
- currCounter = 0;
- return;
- }
- currCounter = counterId;
-#ifndef FIX_1054_IF_ELSE_CMPLX
- call_occurred = 1;
-#endif
-#else
- (void) counterId;
-#endif /* ifdef WMOPS */
-}
-
-
-void incrementNbTimeObjectIsCalled( int counterId )
-{
-#ifdef WMOPS
- if ( ( counterId > maxCounter ) || ( counterId < 0 ) )
- {
- nbTimeObjectIsCalled[0]++;
- return;
- }
- nbTimeObjectIsCalled[counterId]++;
-#else
- (void) counterId;
-#endif /* ifdef WMOPS */
-}
-
-
-#ifdef WMOPS
-static Word32 WMOPS_frameStat( void )
-{
- /* calculate the WMOPS seen so far and update the global
- per-frame maximum (glob_wc)
- */
- Word32 tot;
-
- tot = TotalWeightedOperation();
- if ( tot > glob_wc[currCounter] )
- {
- glob_wc[currCounter] = tot;
- }
-
- if ( tot < glob_bc[currCounter] )
- {
- glob_bc[currCounter] = tot;
- }
- /* check if fwc() was forgotten at end of last frame */
- if ( tot > LastWOper[currCounter] )
- {
- if ( !fwc_corr[currCounter] )
- {
- fprintf( stderr,
- "count: operations counted after last fwc() for '%s'; "
- "-> fwc() called\n",
- objectName[currCounter] ? objectName[currCounter] : "" );
- }
- fwc();
- }
-
- return tot;
-}
-#endif /* ifdef WMOPS */
-
-
-#ifdef WMOPS
-static void WMOPS_clearMultiCounter( void )
-{
- Word16 i;
-
- Word32 *ptr = (Word32 *) &multiCounter[currCounter];
- for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ )
- {
- *ptr++ = 0;
- }
-}
-#endif /* ifdef WMOPS */
-
-
-void ClearNbTimeObjectsAreCalled()
-{
-#ifdef WMOPS
- Word16 i;
-
- for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ )
- {
- nbTimeObjectIsCalled[i] = 0;
- }
-#endif /* ifdef WMOPS */
-}
-
-Word32 TotalWeightedOperation()
-{
-#ifdef WMOPS
- Word16 i;
- Word32 tot, *ptr;
- const Word32 *ptr2;
-
- tot = 0;
- ptr = (Word32 *) &multiCounter[currCounter];
- ptr2 = (const Word32 *) &op_weight;
- for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ )
- {
- tot += ( ( *ptr++ ) * ( *ptr2++ ) );
- }
-
- return ( (Word32) tot );
-
-#else /* ifdef WMOPS */
- return 0; /* Dummy */
-
-#endif /* ifdef WMOPS */
-}
-
-Word32 DeltaWeightedOperation()
-{
-#ifdef WMOPS
- Word32 NewWOper, delta;
-
- NewWOper = TotalWeightedOperation();
- delta = NewWOper - LastWOper[currCounter];
- LastWOper[currCounter] = NewWOper;
- return ( delta );
-
-#else /* ifdef WMOPS */
- return 0; /* Dummy */
-
-#endif /* ifdef WMOPS */
-}
-
-
-void Init_WMOPS_counter( void )
-{
-#ifdef WMOPS
- Word16 i;
-
- /* reset function weight operation counter variable */
-
- for ( i = 0; i < NbFuncMax; i++ )
- wc[currCounter][i] = (Word32) 0;
- glob_wc[currCounter] = 0;
- nbframe[currCounter] = 0;
- total_wmops[currCounter] = 0.0;
- for ( i = 0; i < NbFuncMax; i++ )
- {
- bc[currCounter][i] = (Word32) MAX_32;
- }
- glob_bc[currCounter] = MAX_32;
- nbcalls[currCounter] = 0;
- total_sum[currCounter] = 0.0;
-
- /* initially clear all counters */
- WMOPS_clearMultiCounter();
- LastWOper[currCounter] = 0;
- funcid[currCounter] = 0;
-
-#ifndef FIX_1054_IF_ELSE_CMPLX
- /* Following line is useful for incrIf(), see control.h */
- call_occurred = 1;
- funcId_where_last_call_to_else_occurred = MAXCOUNTERS;
-#endif
-
- sum_bc[currCounter] = MAX_32;
- sum_wc[currCounter] = 0;
- sum_curr[currCounter] = 0;
- for ( i = 0; i < MAXCOUNTERS; i++ )
- {
- call_tree[currCounter][i] = -1;
- }
-
- glob_sum_curr[currCounter] = 0;
- glob_sum_wc[currCounter] = 0;
- glob_sum_bc[currCounter] = MAX_32;
-
-#endif /* ifdef WMOPS */
-}
-
-
-Word32 Reset_WMOPS_counter( void )
-{
-#ifdef WMOPS
- Word32 tot = WMOPS_frameStat();
-
- /* increase the frame counter --> a frame is counted WHEN IT BEGINS */
- nbframe[currCounter]++;
- /* Call counter */
- nbcalls[currCounter] += funcid[currCounter];
- /* add wmops used in last frame to count, then reset counter (in first frame, this is a no-op */
- total_wmops[currCounter] += (float) ( tot * frameRate );
- total_sum[currCounter] += (float) ( ( glob_sum_curr[currCounter] ) * frameRate );
-
- /* clear counter before new frame starts */
- WMOPS_clearMultiCounter();
- LastWOper[currCounter] = 0;
- funcid[currCounter] = 0; /* new frame, set function id to zero */
-
- glob_sum_curr[currCounter] = 0;
- sum_curr[currCounter] = 0;
- return tot;
-#else
- return 0;
-#endif /* ifdef WMOPS */
-}
-
-
-Word32 fwc( void )
-{
-/* function worst case */
-#ifdef WMOPS
- Word32 tot;
-
- tot = DeltaWeightedOperation();
- if ( tot > wc[currCounter][funcid[currCounter]] )
- wc[currCounter][funcid[currCounter]] = tot;
-
- if ( tot < bc[currCounter][funcid[currCounter]] )
- bc[currCounter][funcid[currCounter]] = tot;
-
- funcid[currCounter]++;
-
- /*make sure that BASOP_frame_update(); is put at the end of the main loop*/
- if ( funcid[currCounter] >= NbFuncMax )
- {
- printf( "to many function calls\n" );
- }
- assert( funcid[currCounter] < NbFuncMax );
- return ( tot );
-#else
- return 0;
-#endif /* ifdef WMOPS */
-}
-
-void WMOPS_output( Word16 dtx_mode )
-{
-#ifdef WMOPS
- Word16 i;
- Word32 tot, tot_wm, tot_wc;
-
- /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum)
- so output CAN be called in each frame without problems. The frame counter is NOT updated! */
- tot = WMOPS_frameStat();
- tot_wm = (Word32) ( total_wmops[currCounter] + ( (float) tot ) * frameRate );
-
- fprintf( stdout,
- "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "",
- ( (float) tot ) * frameRate );
-
- if ( nbframe[currCounter] != 0 )
- {
- fprintf( stdout, " Average=%.3f", tot_wm / (float) nbframe[currCounter] );
- }
- fprintf( stdout, " WorstCase=%.3f", ( (float) glob_wc[currCounter] ) * frameRate );
-
- /* Worst worst case printed only when not in DTX mode */
- if ( dtx_mode == 0 )
- {
- tot_wc = 0L;
- for ( i = 0; i < funcid[currCounter]; i++ )
- tot_wc += wc[currCounter][i];
- fprintf( stdout, " WorstWC=%.3f", ( (float) tot_wc ) * frameRate );
- }
- fprintf( stdout, " (%d frames)\n", nbframe[currCounter] );
-#else
- (void) dtx_mode;
-#endif /* ifdef WMOPS */
-}
-
-void WMOPS_output_avg( Word16 dtx_mode, Word32 *tot_wm, Word32 *num_frames )
-{
-#ifdef WMOPS
- Word16 i;
- Word32 tot, tot_wc;
-
- /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum)
- so output CAN be called in each frame without problems. The frame counter is NOT updated! */
- tot = WMOPS_frameStat();
- *tot_wm = (Word32) ( total_wmops[currCounter] + ( (float) tot ) * frameRate );
- *num_frames = nbframe[currCounter];
-
- fprintf( stdout, "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", ( (float) tot ) * frameRate );
-
- if ( nbframe[currCounter] != 0 )
- {
- fprintf( stdout, " Average=%.3f", *tot_wm / (float) nbframe[currCounter] );
- }
- fprintf( stdout, " WorstCase=%.3f", ( (float) glob_wc[currCounter] ) * frameRate );
-
- /* Worst worst case printed only when not in DTX mode */
- if ( dtx_mode == 0 )
- {
- tot_wc = 0L;
- for ( i = 0; i < funcid[currCounter]; i++ )
- tot_wc += wc[currCounter][i];
- fprintf( stdout, " WorstWC=%.3f", ( (float) tot_wc ) * frameRate );
- }
- fprintf( stdout, " (%d frames)\n", nbframe[currCounter] );
-#else
- (void) dtx_mode;
- (void) tot_wm;
- (void) num_frames;
-#endif /* ifdef WMOPS */
-}
-
-void generic_WMOPS_output( Word16 dtx_mode, char *test_file_name )
-{
-#ifdef WMOPS
- int saved_value;
- Word16 i;
- Word32 tot, tot_wm, tot_wc, *ptr;
- const Word32 *ptr2;
- Word40 grand_total;
- FILE *WMOPS_file;
-
- saved_value = currCounter;
-
- /* Count the grand_total WMOPS so that % ratio per function group can be displayed. */
- grand_total = 0;
- for ( currCounter = 0; currCounter <= maxCounter; currCounter++ )
- {
- tot = WMOPS_frameStat();
- grand_total += tot;
- }
-
-
- if ( ( WMOPS_file = fopen( WMOPS_DATA_FILENAME, "a" ) ) != NULL )
- {
-
- printf( "opened file %s in order to print WMOPS for each function group.\n", WMOPS_DATA_FILENAME );
-
- /* Print the file header line. */
- fprintf( WMOPS_file, "Test file name\tFunction Name \tFrame\tNb Times Called\tWMOPS\t%% versus grand total" );
-
- if ( nbframe[saved_value] != 0 )
- fprintf( WMOPS_file, "\tAverage" );
-
- fprintf( WMOPS_file, "\tWorstCase" );
-
- /* Worst worst case printed only when not in DTX mode */
- if ( dtx_mode == 0 )
- fprintf( WMOPS_file, "\tWorstWC" );
-
- fprintf( WMOPS_file, "\n" );
-
- /* Print the WMOPS for each Function Group by scanning all the function groups with currCounter index. */
- for ( currCounter = 0; currCounter <= maxCounter; currCounter++ )
- {
-
- fprintf( WMOPS_file, "%s", test_file_name );
- fprintf( WMOPS_file, "\t%s", objectName[currCounter] ? objectName[currCounter] : "" );
- fprintf( WMOPS_file, "\t%d", nbframe[currCounter] );
-
- tot = WMOPS_frameStat();
- tot_wm = (Word32) ( total_wmops[currCounter] + ( (float) tot ) * frameRate );
-
- fprintf( WMOPS_file, "\t\t%ld", nbTimeObjectIsCalled[currCounter] );
- fprintf( WMOPS_file, "\t%.6f", ( (float) tot ) * frameRate );
- fprintf( WMOPS_file, "\t%.3f", ( (float) tot ) / grand_total * 100 );
-
- if ( nbframe[currCounter] != 0 )
- fprintf( WMOPS_file, "\t%.3f", tot_wm / (float) nbframe[currCounter] );
-
- fprintf( WMOPS_file, "\t%.3f", ( (float) glob_wc[currCounter] ) * frameRate );
-
- /* Worst worst case printed only when not in DTX mode */
- if ( dtx_mode == 0 )
- {
- tot_wc = 0L;
- for ( i = 0; i < funcid[currCounter]; i++ )
- tot_wc += wc[currCounter][i];
- fprintf( WMOPS_file, "\t%.3f", ( (float) tot_wc ) * frameRate );
- }
- fprintf( WMOPS_file, "\n" );
- }
-
- /* Print the file Grand Total line */
- fprintf( WMOPS_file, "%s", test_file_name );
- fprintf( WMOPS_file, "\tGrand Total" );
- fprintf( WMOPS_file, "\t%d", nbframe[saved_value] );
- fprintf( WMOPS_file, "\t\t%.6f", ( (float) grand_total ) * frameRate );
- fprintf( WMOPS_file, "\t100.000" );
- fprintf( WMOPS_file, "\n" );
- fclose( WMOPS_file );
- }
- else
- printf( "Can not open file %s for WMOPS editing\n", WMOPS_DATA_FILENAME );
-
-
- if ( ( WMOPS_file = fopen( WMOPS_TOTAL_FILENAME, "a" ) ) != NULL )
- {
- printf( "opened file %s in order to print application's total WMOPS.\n", WMOPS_TOTAL_FILENAME );
- fprintf( WMOPS_file, "%s", test_file_name );
- fprintf( WMOPS_file, "\tframe=%d", nbframe[currCounter] );
- fprintf( WMOPS_file, "\tWMOPS=%.6f", ( (float) grand_total ) * frameRate );
- fprintf( WMOPS_file, "\n" );
- fclose( WMOPS_file );
- }
- else
- printf( "Can not open file %s for WMOPS editing.\n", WMOPS_TOTAL_FILENAME );
-
-
- if ( ( WMOPS_file = fopen( CODE_PROFILE_FILENAME, "a" ) ) != NULL )
- {
-
- printf( "opened file %s in order to print basic operation distribution statistics.\n", CODE_PROFILE_FILENAME );
-
- /* Print the file header line. */
- fprintf( WMOPS_file, "Test file name\tBasic Operation Name\tframe\tWMOPS\t\t%% versus grand total\n" );
-
- /* Print the WMOPS for each Basic Operation across all the defined */
- /* Function Groups. */
- for ( i = 0; i < (Word16) ( sizeof( op_weight ) / sizeof( Word32 ) ); i++ )
- {
- fprintf( WMOPS_file, "%-16s", test_file_name );
- fprintf( WMOPS_file, "\t%s", BasicOperationList[i] );
- fprintf( WMOPS_file, "\t%d", nbframe[0] );
-
- tot = 0;
- ptr = (Word32 *) &multiCounter[0] + i;
- ptr2 = (const Word32 *) &op_weight + i;
- for ( currCounter = 0; currCounter <= maxCounter; currCounter++ )
- {
- tot += ( ( *ptr ) * ( *ptr2 ) );
- ptr += ( sizeof( op_weight ) / sizeof( Word32 ) );
- }
-
- fprintf( WMOPS_file, "\t%.6f", ( (float) tot ) * frameRate );
- fprintf( WMOPS_file, "\t%.3f", ( (float) tot ) / grand_total * 100 );
- fprintf( WMOPS_file, "\n" );
- }
-
- /* Print the file Grand Total line */
- fprintf( WMOPS_file, "%s", test_file_name );
- fprintf( WMOPS_file, "\tGrand Total" );
- fprintf( WMOPS_file, "\t%d", nbframe[saved_value] );
- fprintf( WMOPS_file, "\t%.6f", ( (float) grand_total ) * frameRate );
- fprintf( WMOPS_file, "\t100.000" );
- fprintf( WMOPS_file, "\n" );
- fclose( WMOPS_file );
- }
- else
- printf( "Can not open file %s for basic operations distribution statistic editing\n", CODE_PROFILE_FILENAME );
-
- currCounter = saved_value;
-
-#else
- (void) dtx_mode;
- (void) test_file_name;
-#endif /* ifdef WMOPS */
-}
-/* FROM_EVS_DEV */
-
-
-/* jdr 20120117: add FLC similar functions */
-void BASOP_frame_update( void )
-{
-#ifdef WMOPS
- int i, current;
-#if MAX_CALLERS_SAVED_FRAMES
- int k;
-#endif
- float total = 0.0f;
-
-#ifdef DEBUG
- {
- static int sptr_target = -2;
-
- if ( sptr_target == -2 )
- {
- sptr_target = sptr;
- }
- else
- {
- if ( sptr_target != sptr )
- {
- fprintf( stderr, "BASOP_sub_start/BASOP_sub_end imbalance detected!!!\n" );
- sptr_target = sptr;
- }
- }
- }
-#endif
-
- /* Get current counter */
- current = readCounterId();
-
- /* Update global operation counters */
- for ( i = 1; i <= maxCounter; i++ )
- {
- int j;
-
- for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( UWord32 ) ); j++ )
- {
- ( (UWord32 *) &glob_multiCounter )[j] += ( (UWord32 *) &multiCounter[i] )[j];
- }
- }
-
-#if MAX_CALLERS_SAVED_FRAMES
- /* Reset all counters */
- for ( i = 1; i <= maxCounter; i++ )
- {
- callers_frames[0][i] = 0.0f;
- }
-#endif
- /* Reset all counters */
- for ( i = 1; i <= maxCounter; i++ )
- {
- if ( current != i && funcid[i] > 0 )
- {
- setCounter( i );
-
- glob_sum_curr[currCounter] += sum_curr[currCounter];
-
- if ( glob_sum_curr[currCounter] > glob_sum_wc[currCounter] )
- {
- glob_sum_wc[currCounter] = glob_sum_curr[currCounter];
- }
- if ( glob_sum_curr[currCounter] < glob_sum_bc[currCounter] )
- {
- glob_sum_bc[currCounter] = glob_sum_curr[currCounter];
- }
-#if MAX_CALLERS_SAVED_FRAMES
- /* Keep a Copy before it is Reset */
- callers_frames[0][currCounter] = (float) Reset_WMOPS_counter();
- total += callers_frames[0][currCounter];
-#else
- total += (float) Reset_WMOPS_counter();
-#endif
- }
- }
-
-#if MAX_CALLERS_SAVED_FRAMES
- /* Keep Callers for this Worst Case Frame */
- /* Select Slot to Use (Slot 0 is the Current) */
- k = 0;
- for ( i = k + 1; i < MAX_CALLERS_SAVED_FRAMES; i++ )
- {
- /* Is it the Min? */
- if ( callers_totals[i] < callers_totals[k] )
- { /* Yes */
- k = i;
- }
- }
- /* Current Greater than the Min? */
- if ( total > callers_totals[k] )
- {
- k += 1;
- /* Save Info of Callers */
- for ( i = 1; i <= maxCounter; i++ )
- {
- callers_frames[k][i] = callers_frames[0][i];
- }
- if ( i < MAXCOUNTERS )
- callers_frames[k][i] = -1;
- /* Save Total */
- callers_totals[k - 1] = total;
- /* Save Frame Number */
- callers_frames_nos[k - 1] = nbframe[0];
- }
-#endif
- if ( total < glob_bc[0] )
- {
- glob_bc[0] = (Word32) total;
- }
- if ( total > glob_wc[0] )
- {
- glob_wc[0] = (Word32) total;
- }
- /* Restore current counter */
- setCounter( current );
-
- nbframe[0]++;
-#endif /* if WMOPS */
-}
-
-void printStack( char *text, char *Id )
-{
-#ifdef WMOPS
- int i;
- if ( !Id )
- return;
- if ( !strcmp( "*", Id ) || ( !strcmp( Id, objectName[currCounter] ) ) )
- {
- printf( "%s %s", text, objectName[currCounter] );
- for ( i = sptr - 1; i > 0; i-- )
- {
- printf( " <- %s", objectName[stack[i]] );
- }
- printf( "\n" );
- }
-#else
- printf( "%s %s\n", text, Id ? Id : "(no name)" );
-#endif
-}
-
-#ifdef WMOPS
-void BASOP_push_wmops( const char *label )
-{
- int new_flag, prev_counter;
- int i, j;
-
- /* Check if new counter label */
- new_flag = 1;
- for ( i = 1; i <= maxCounter; i++ )
- {
- if ( strcmp( objectName[i], label ) == 0 )
- {
- new_flag = 0;
- break;
- }
- }
-
- prev_counter = readCounterId();
-
- /* Configure new record */
- if ( new_flag )
- {
- i = (int) getCounterId( label );
- setCounter( i );
- Init_WMOPS_counter();
- }
- else
- {
- setCounter( i );
- }
-
-
- /* Push current context onto stack */
- if ( currCounter >= 0 )
- {
- if ( sptr >= MAX_STACK )
- {
- fprintf( stderr, "\r push_wmops(): stack exceeded, try inreasing MAX_STACK\n" );
- exit( -1 );
- }
- stack[sptr++] = prev_counter;
-
- /* Reset accumulated WMOPS */
- sum_stack[sptr] = 0;
-
- /* update call tree */
- for ( j = 0; j < MAXCOUNTERS; j++ )
- {
- if ( call_tree[i][j] == prev_counter )
- {
- break;
- }
- else if ( call_tree[i][j] == -1 )
- {
- call_tree[i][j] = (Word16) prev_counter;
- break;
- }
- }
- }
-
- /*wmops[currCounter].start_selfcnt = ops_cnt;
- wmops[currCounter].start_cnt = ops_cnt;
- nbTimeObjectIsCalled[currCounter]++;*/
-
- incrementNbTimeObjectIsCalled( currCounter );
-
- sum_curr[currCounter] = 0;
-
-#ifdef DEBUG_COUNTER
- printf( "Entering: %s\n", readCounterIdName() );
-#endif
-}
-#endif
-
-Word32 BASOP_pop_wmops( void )
-{
-#ifdef WMOPS
- Word32 ops_cnt;
-
-#ifdef DEBUG_COUNTER
- printf( "Exiting: %s\n", readCounterIdName() );
-#endif
-
- ops_cnt = fwc();
-
- /* Get back previous context from stack */
- if ( sptr > 0 )
- {
- int prevCounter;
-
- sum_stack[sptr] += ops_cnt;
- prevCounter = currCounter;
- setCounter( stack[--sptr] );
- sum_stack[sptr] += sum_stack[sptr + 1];
- sum_curr[prevCounter] += sum_stack[sptr + 1];
- }
- else
- {
- /* current_record = -1; */
- setCounter( 0 );
- }
-
- if ( sum_curr[currCounter] > sum_wc[currCounter] )
- {
- sum_wc[currCounter] = sum_curr[currCounter];
- }
- if ( sum_curr[currCounter] < sum_bc[currCounter] )
- {
- sum_bc[currCounter] = sum_curr[currCounter];
- }
-
- return ops_cnt;
-#else /* if WMOPS */
- return 0;
-#endif /* if WMOPS */
-}
-
-Word32 BASOP_get_wops( void )
-{
- return BASOP_pop_wmops();
-}
-
-
-void WMOPS_destroy( void )
-{
-#ifdef WMOPS
- int i;
-
- /* release the memory allocated for the objectName array */
- for ( i = 0; i < MAXCOUNTERS + 1; i++ )
- {
- if ( NULL != objectName[i] )
- {
- free( objectName[i] );
- objectName[i] = NULL;
- }
- }
-
- maxCounter = 0;
-#endif
-
- return;
-}
-
-
-void WMOPS_output_all( Word16 dtx_mode )
-{
-#ifdef WMOPS
- float ops_cnt = 0.0f;
- int i;
-
- char *sfmts = "%-40s %8s %8s %7s %7s\n";
- char *dfmts = "%-40s %8.2f %8.3f %7.3f %7.3f\n";
- char *sfmt = "%-40s %8s %8s %7s %7s %7s %7s %7s\n";
- char *dfmt = "%-40s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n";
-
- /*fprintf (stderr, "\nInstruction Type Analysis (for worst case frame):\n\n");*/
- fprintf( stderr, "\nInstruction Type Analysis (for worst case frame number %ld):\n\n", (long int) nbframe[0] ); /* added -- JPA */
- for ( i = 0; i < (int) ( sizeof( BasicOperationList ) / sizeof( char * ) ); i++ )
- {
- if ( ( (UWord32 *) &glob_multiCounter )[i] > 0 )
- fprintf( stderr, "\t%16s: %12d\n", BasicOperationList[i], ( (UWord32 *) &glob_multiCounter )[i] );
- }
-
- fprintf( stderr, "\n\nWeighted MOPS Analysis:\n" );
- fprintf( stderr, "%74s %23s\n", "|------ SELF ------|", "|--- CUMULATIVE ---|" );
- fprintf( stderr, sfmt, " routine", " calls", " min ", " max ", " avg ", " min ", " max ", " avg " );
- fprintf( stderr, sfmt, " ------------------------", " ------", "------", "------", "------", "------", "------", "------" );
- for ( i = 1; i <= maxCounter; i++ )
- {
- if ( nbcalls[i] > 0 )
- {
- fprintf( stderr, dfmt,
- objectName[i],
- ( nbframe[i] == 0 ) ? 0 : (float) nbcalls[i] / (float) nbframe[0],
- ( glob_bc[i] == 0 ) ? 0 : frameRate * (float) glob_bc[i],
- ( glob_wc[i] == 0 ) ? 0 : frameRate * (float) glob_wc[i],
- ( nbframe[i] == 0 ) ? 0 : (float) total_wmops[i] / (float) nbframe[i],
- frameRate * ( glob_sum_bc[i] ),
- frameRate * ( glob_sum_wc[i] ),
- ( nbframe[i] == 0 ) ? 0 : (float) ( total_sum[i] / (float) nbframe[i] ) );
- /* frameRate*(glob_bc[i]+wmops_children_bc[i]), */
- /* frameRate*(glob_wc[i]+wmops_children_wc[i]), */
- /* (nbframe[i] == 0) ? 0 : (float)((total_wmops[i] + total_wmops_children[i]) /(float)nbframe[i])); */
- }
- ops_cnt += total_wmops[i];
- }
-
- fprintf( stderr, sfmts, " -----------------", " ------", "------", "------", "------" );
- if ( nbframe[i] > 0 )
- {
- fprintf( stderr, dfmts,
- "total",
- (double) nbframe[0],
- frameRate * glob_bc[0],
- frameRate * glob_wc[0],
- ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] );
- }
-#if 0
- {
- char *sfmtt = "%20s %4s %15s\n";
- char *dfmtt = "%20s %4d ";
-
- fprintf (stderr, "\nCall Tree:\n\n");
- fprintf (stderr, sfmtt, " function", "num", "called by: ");
- fprintf (stderr, sfmtt, "---------------", "---", "--------------");
-
- for (i = 1; i <= maxCounter; i++)
- {
- int j;
-
- fprintf (stderr, dfmtt, objectName[i], i);
- for (j = 0; call_tree[i][j] != -1; j++)
- {
- if (j != 0)
- {
- fprintf (stderr, ", ");
- }
- fprintf (stderr, "%s", objectName[call_tree[i][j]]);
- }
- fprintf (stderr, "\n");
-
- }
- fprintf (stderr, sfmtt, "---------------", "---", "--------------");
- fprintf (stderr, "\n\n");
- }
-#endif
-
-#if 0
- fprintf (stderr, "\n\n");
- for (i=1; i<=maxCounter; i++)
- {
- setCounter(i);
- WMOPS_output(dtx_mode);
- }
-#else
- (void) dtx_mode;
-#endif
-
-#if MAX_CALLERS_SAVED_FRAMES
- for ( i = 1; i <= MAX_CALLERS_SAVED_FRAMES; i++ )
- {
- int j, k, l, m;
- const char *frame_rank[] = { "st", "nd", "rd", "th" };
- float current;
-
- k = 0;
- for ( j = k + 1; j < MAX_CALLERS_SAVED_FRAMES; j++ )
- {
- /* Is it the Max? */
- if ( callers_totals[j] > callers_totals[k] )
- { /* Yes */
- k = j;
- }
- }
- k += 1;
-
- fprintf( stderr, "\nActive Callers Report for %i%s Worst Case Frame #: %i\n",
- i, i <= 3 ? frame_rank[i - 1] : frame_rank[3],
- callers_frames_nos[k - 1] );
- /* Print up to 'MAX_CALLERS_PRINT' Callers */
- current = 0.0f;
- for ( l = 0; l < MAX_CALLERS_PRINT; l++ )
- {
- /* Find Highest Complexity */
- m = 1;
- for ( j = m + 1; j <= maxCounter; j++ )
- {
- if ( callers_frames[k][j] < 0 )
- break;
- if ( callers_frames[k][j] > callers_frames[k][m] )
- m = j;
- }
- /* Done ? */
- if ( callers_frames[k][m] == 0 )
- break;
- fprintf( stderr, " %-52s %10.3f\n", objectName[m], callers_frames[k][m] * frameRate );
- /* Count it */
- current += callers_frames[k][m];
- /* Mark as Done */
- callers_frames[k][m] = 0.0f;
- }
- /* Check if All Printed */
- if ( current + 0.001f < callers_totals[k - 1] )
- {
- fprintf( stderr, " Only first %i Callers have been Printed!\n", MAX_CALLERS_PRINT );
- fprintf( stderr, " %-52s %10.3f\n", "Total for non Printed", ( callers_totals[k - 1] - current ) * frameRate );
- }
- fprintf( stderr, " %-52s %10.3f\n", "Total", callers_totals[k - 1] * frameRate );
- /* Mark as Done */
- callers_totals[k - 1] = 0.0f;
- }
-#endif
- WMOPS_destroy();
-#else
- UNUSED_PARAM( dtx_mode );
-#endif /* if WMOPS */
-}
-void WMOPS_output_all_std( Word16 dtx_mode )
-{
-#ifdef WMOPS
- float ops_cnt = 0.0f;
- int i;
-
- char *sfmts = "%-40s %8s %8s %7s %7s\n";
- char *dfmts = "%-40s %8.2f %8.3f %7.3f %7.3f\n";
- char *sfmt = "%-40s %8s %8s %7s %7s %7s %7s %7s\n";
- char *dfmt = "%-40s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n";
-
- /*fprintf (stdout, "\nInstruction Type Analysis (for worst case frame):\n\n");*/
- fprintf( stdout, "\nInstruction Type Analysis (for worst case frame number %ld):\n\n", (long int) nbframe[0] ); /* added -- JPA */
- if ( nbframe[0] > 0 )
- {
- for ( i = 0; i < (int) ( sizeof( BasicOperationList ) / sizeof( char * ) ); i++ )
- {
- if ( ( (UWord32 *) &glob_multiCounter )[i] > 0 )
- fprintf( stdout, "\t%16s: %12d\n", BasicOperationList[i], ( (UWord32 *) &glob_multiCounter )[i] );
- }
- }
- fprintf( stdout, "\n\nWeighted MOPS Analysis:\n" );
- fprintf( stdout, "%74s %23s\n", "|------ SELF ------|", "|--- CUMULATIVE ---|" );
- fprintf( stdout, sfmt, " routine", "calls/fr", " min ", " max ", " avg ", " min ", " max ", " avg " );
- fprintf( stdout, sfmt, " ------------------------", " ------", "------", "------", "------", "------", "------", "------" );
- for ( i = 1; i <= maxCounter; i++ )
- {
- fprintf( stdout, dfmt,
- objectName[i],
- ( nbframe[i] == 0 ) ? 0 : (float) nbcalls[i] / (float) nbframe[0],
- ( glob_bc[i] == MAX_32 ) ? 0 : frameRate * (float) glob_bc[i],
- ( glob_wc[i] == 0 ) ? 0 : frameRate * (float) glob_wc[i],
- ( nbframe[i] == 0 ) ? 0 : (float) total_wmops[i] / (float) nbframe[i],
- frameRate * ( glob_sum_bc[i] ),
- frameRate * ( glob_sum_wc[i] ),
- ( nbframe[i] == 0 ) ? 0 : (float) ( ( total_sum[i] ) / (float) nbframe[i] ) );
- /* frameRate*(glob_bc[i]+wmops_children_bc[i]), */
- /* frameRate*(glob_wc[i]+wmops_children_wc[i]), */
- /* (nbframe[i] == 0) ? 0 : (float)((total_sum[i]) /(float)nbframe[i])); */
- ops_cnt += total_wmops[i];
- }
-
- fprintf( stdout, sfmts, " -----------------", " ------", "------", "------", "------" );
- if ( nbframe[0] > 0 )
- {
- fprintf( stdout, dfmts,
- "total",
- (double) nbframe[0],
- frameRate * glob_bc[0],
- frameRate * glob_wc[0],
- ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] );
- }
-#if 0
- {
- char *sfmtt = "%20s %4s %15s\n";
- char *dfmtt = "%20s %4d ";
-
- fprintf (stdout, "\nCall Tree:\n\n");
- fprintf (stdout, sfmtt, " function", "num", "called by: ");
- fprintf (stdout, sfmtt, "---------------", "---", "--------------");
-
- for (i = 1; i <= maxCounter; i++)
- {
- int j;
-
- fprintf (stdout, dfmtt, objectName[i], i);
- for (j = 0; call_tree[i][j] != -1; j++)
- {
- if (j != 0)
- {
- fprintf (stdout, ", ");
- }
- fprintf (stdout, "%s", objectName[call_tree[i][j]]);
- }
- fprintf (stdout, "\n");
-
- }
- fprintf (stdout, sfmtt, "---------------", "---", "--------------");
- fprintf (stdout, "\n\n");
- }
-#endif
-
-#if 0
- fprintf (stdout, "\n\n");
- for (i=1; i<=maxCounter; i++)
- {
- setCounter(i);
- WMOPS_output(dtx_mode);
- }
-#else
- (void) dtx_mode;
-#endif
-
-
- WMOPS_destroy();
-
-#else
- UNUSED_PARAM( dtx_mode );
-#endif /* if WMOPS */
-}
-
-
-void Reset_all_WMOPS_counter( void )
-{
-#ifdef WMOPS
- int i;
- int currCounterSave;
-
- currCounterSave = currCounter;
-
- for ( i = 2; i <= maxCounter; i++ )
- {
- setCounter( i );
- Init_WMOPS_counter();
- objectName[i] = 0;
- }
-
- currCounter = currCounterSave;
- maxCounter = 1;
-#endif /* if WMOPS */
-}
-
-/* Returns the total min/max/avg WMOPS values like printed in BASOP_end(). */
-void BASOP_get_total_wmops( double *min, double *max, double *avg )
-{
-#ifdef WMOPS
- if ( min != NULL )
- *min = frameRate * glob_bc[0];
- if ( max != NULL )
- *max = frameRate * glob_wc[0];
- if ( avg != NULL )
- {
- int i;
- double ops_cnt = 0;
- for ( i = 1; i <= maxCounter; i++ )
- ops_cnt += total_wmops[i];
- *avg = ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0];
- }
-#else
- UNUSED_PARAM( min );
- UNUSED_PARAM( max );
- UNUSED_PARAM( avg );
-#endif /* if WMOPS */
-}
-/* end of file */
-#undef WMC_TOOL_SKIP
diff --git a/lib_com/count.h b/lib_com/count.h
deleted file mode 100644
index 03eb7034b82aecb5a722de72f981040f7689be9a..0000000000000000000000000000000000000000
--- a/lib_com/count.h
+++ /dev/null
@@ -1,543 +0,0 @@
-/*
- ===========================================================================
- File: COUNT.H v.2.3 - 30.Nov.2009
- ===========================================================================
-
- ITU-T STL BASIC OPERATORS
-
- PROTOTYPES & DEFINITION FOR COUNTING OPERATIONS
-
- History
- 09.Aug.1999 V1.0.0 Input to UGST from ETSI AMR (count.h);
-
- 26.Jan.2000 V1.1.0 Added counter entries for G.723.1's
- L_mls(), div_l(), i_mult() [from basop32.c]
-
- 05.Jul.2000 V1.2.0 Added counter entries for 32bit shiftless
- operators L_mult0(), L_mac0(), L_msu0()
-
- 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
- operators for the ITU-T Standard Tool Library as
- described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
- TD 11 document and subsequent discussions on the
- wp3audio@yahoogroups.com email reflector.
- March 06 v2.1 Changed to improve portability.
- Dec 06 v2.2 Changed to specify frame rate using setFrameRate()
- Adding WMOPS_output_avg() for global average computation
- L_mls() weight of 5.
- div_l() weight of 32.
- i_mult() weight of 3.
- ============================================================================
-*/
-
-
-/******************************************************************************
- * Functions for counting operations.
- *
- * These functions make it possible to measure the wMOPS of a codec.
- *
- * All functions in this file, and in other *.h files, update a structure so
- * that it will be possible to track how many calls to add(), sub(), L_mult()
- * ... was made by the code and to estimate the wMOPS (and MIPS) for a certain
- * part of the code.
- *
- * It is also possible to measure the wMOPS separatly for different parts
- * of the codec.
- *
- * This is done by creating a counter group (getCounterId) for each part of
- * the code that one wants a seperate measure for. Before a part of the code
- * is executed a call to the "setCounter" function is needed to identify
- * which counter group to use.
- *
- * Currently there is a limit of 255 different counter groups.
- *
- * In the end of this file, there is a piece of code illustrating how the
- * functions can be used.
- *
- ******************************************************************************/
-
-
-#ifndef _COUNT_H
-#define _COUNT_H "$Id$"
-
-#include
-
-
-#define MAXCOUNTERS ( 512 )
-#define MAX_CALLERS_SAVED_FRAMES 5 /* # of Frame for which WMOPS Complexity Details will be saved, 0 = Disabled */
-
-int getCounterId( const char *objectName );
-/*
- * Create a counter group, the "objectname" will be used when printing
- * statistics for this counter group.
- *
- * Returns 0 if no more counter groups are available.
- */
-
-
-int readCounterId( void );
-/*
- * Returns the current CounterId.
- */
-
-
-void setCounter( int counterId );
-/*
- * Defines which counter group to use, default is zero.
- */
-
-
-char *readCounterIdName( void );
-/*
- * Returns the current CounterId name.
- */
-void printStack( char *text, char *Id );
-/*
- * print stack
- * text: Any text to print initially
- * Id: NULL, if no prints are wanted
- * "*", if all prints are wanted (default)
- * "pitch_ol" or any other function name
- */
-
-void incrementNbTimeObjectIsCalled( int counterId );
-/*
- * This function enables to increment by 1 a counter
- * tracking the number of times the application enters a groups of functions.
- * If the counterId is not refering to a defined function counter group, then it is
- * the default function group (0) which is impacted.
- *
- */
-
-
-void ClearNbTimeObjectsAreCalled( void );
-/*
- * This function enables to clear to 0 all the counters enabling to
- * track the number of times the application enters any groups of functions.
- */
-
-
-void Init_WMOPS_counter( void );
-/*
- * Initiates the current counter group.
- */
-
-
-Word32 Reset_WMOPS_counter( void );
-/*
- * Resets the current counter group.
- */
-
-
-void WMOPS_output( Word16 notPrintWorstWorstCase );
-/*
- * Prints the statistics to the screen, if the argument is non zero
- * the statistics for worst worst case will not be printed. This is typically
- * done for dtx frames.
- *
- */
-
-void WMOPS_output_avg( Word16 dtx_mode, Word32 *tot_wm, Word32 *num_frames );
-/*
- * same as WMOPS_output + returns the total wmops counter and the number of frames
- * to support the computation of global average.
- *
- */
-
-
-Word32 fwc( void );
-/*
- * worst worst case counter.
- *
- * This function calculates the worst possible case that can be reached.
- *
- * This is done by calling this function for each subpart of the calculations
- * for a frame. This function then stores the maximum wMOPS for each part.
- *
- * The WMOPS_output function add together all parts and presents the sum.
- */
-
-void setFrameRate( int samplingFreq, int frameLength );
-/*
- * This function can overwrite the value of the frameRate variable that is
- * initialized by the FRAME_RATE constant.
- */
-
-
-#define WMOPS_DATA_FILENAME "wmops_data.txt"
-/*
- * WMOPS_DATA_FILENAME is the macro defining the name of the file
- * where the Weighted Million of Operations per Second (wMOPS)
- * are appended, function group by function group.
- */
-
-
-#define CODE_PROFILE_FILENAME "code_profile.txt"
-/*
- * CODE_PROFILE_FILENAME is the macro defining the name of the file
- * where the Weighted Million of Operations per Second (WMOPS)
- * are appended, basic operation by basic operation.
- */
-
-
-#define WMOPS_TOTAL_FILENAME "wmops_total.txt"
-/*
- * WMOPS_TOTAL_FILENAME is the macro defining the name of the file
- * where the Weighted Million of Operations per Second (WMOPS)
- * are printed, globally for the application.
- */
-
-
-#define FRAME_RATE ( 0.0001F ) /* in this version frame_rate can be overwriten online by the new setFrameRate function */
-/* FRAME_RATE of 0.000025 is corresponding to 40ms frame.*/
-/* FRAME_RATE of 0.00005 is corresponding to 20ms frame.*/
-/* FRAME_RATE of 0.0001 is corresponding to 10ms frame.*/
-/*
- * FRAME_RATE is the macro defining the calling rate of the
- * application to benchmark.
- */
-
-
-/* Global counter variable for calculation of complexity weight */
-typedef struct
-{
- UWord32 add; /* Complexity Weight of 1 */
- UWord32 sub; /* Complexity Weight of 1 */
- UWord32 abs_s; /* Complexity Weight of 1 */
- UWord32 shl; /* Complexity Weight of 1 */
- UWord32 shr; /* Complexity Weight of 1 */
-
- UWord32 extract_h; /* Complexity Weight of 1 */
- UWord32 extract_l; /* Complexity Weight of 1 */
- UWord32 mult; /* Complexity Weight of 1 */
- UWord32 L_mult; /* Complexity Weight of 1 */
- UWord32 negate; /* Complexity Weight of 1 */
-
- UWord32 round; /* Complexity Weight of 1 */
- UWord32 L_mac; /* Complexity Weight of 1 */
- UWord32 L_msu; /* Complexity Weight of 1 */
- UWord32 L_macNs; /* Complexity Weight of 1 */
- UWord32 L_msuNs; /* Complexity Weight of 1 */
-
- UWord32 L_add; /* Complexity Weight of 1 */
- UWord32 L_sub; /* Complexity Weight of 1 */
- UWord32 L_add_c; /* Complexity Weight of 2 */
- UWord32 L_sub_c; /* Complexity Weight of 2 */
- UWord32 L_negate; /* Complexity Weight of 1 */
-
- UWord32 L_shl; /* Complexity Weight of 1 */
- UWord32 L_shr; /* Complexity Weight of 1 */
- UWord32 mult_r; /* Complexity Weight of 1 */
- UWord32 shr_r; /* Complexity Weight of 3 */
- UWord32 mac_r; /* Complexity Weight of 1 */
-
- UWord32 msu_r; /* Complexity Weight of 1 */
- UWord32 L_deposit_h; /* Complexity Weight of 1 */
- UWord32 L_deposit_l; /* Complexity Weight of 1 */
- UWord32 L_shr_r; /* Complexity Weight of 3 */
- UWord32 L_abs; /* Complexity Weight of 1 */
-
- UWord32 L_sat; /* Complexity Weight of 4 */
- UWord32 norm_s; /* Complexity Weight of 1 */
- UWord32 div_s; /* Complexity Weight of 18 */
- UWord32 norm_l; /* Complexity Weight of 1 */
- UWord32 move16; /* Complexity Weight of 1 */
-
- UWord32 move32; /* Complexity Weight of 2 */
- UWord32 Logic16; /* Complexity Weight of 1 */
- UWord32 Logic32; /* Complexity Weight of 2 */
- UWord32 Test; /* Complexity Weight of 2 */
- UWord32 s_max; /* Complexity Weight of 1 */
-
- UWord32 s_min; /* Complexity Weight of 1 */
- UWord32 L_max; /* Complexity Weight of 1 */
- UWord32 L_min; /* Complexity Weight of 1 */
- UWord32 L40_max; /* Complexity Weight of 1 */
- UWord32 L40_min; /* Complexity Weight of 1 */
-
- UWord32 shl_r; /* Complexity Weight of 2 */
- UWord32 L_shl_r; /* Complexity Weight of 2 */
- UWord32 L40_shr_r; /* Complexity Weight of 2 */
- UWord32 L40_shl_r; /* Complexity Weight of 2 */
- UWord32 norm_L40; /* Complexity Weight of 1 */
-
- UWord32 L40_shl; /* Complexity Weight of 1 */
- UWord32 L40_shr; /* Complexity Weight of 1 */
- UWord32 L40_negate; /* Complexity Weight of 1 */
- UWord32 L40_add; /* Complexity Weight of 1 */
- UWord32 L40_sub; /* Complexity Weight of 1 */
-
- UWord32 L40_abs; /* Complexity Weight of 1 */
- UWord32 L40_mult; /* Complexity Weight of 1 */
- UWord32 L40_mac; /* Complexity Weight of 1 */
- UWord32 mac_r40; /* Complexity Weight of 2 */
-
- UWord32 L40_msu; /* Complexity Weight of 1 */
- UWord32 msu_r40; /* Complexity Weight of 2 */
- UWord32 Mpy_32_16_ss; /* Complexity Weight of 2 */
- UWord32 Mpy_32_32_ss; /* Complexity Weight of 2 */
- UWord32 L_mult0; /* Complexity Weight of 1 */
-
- UWord32 L_mac0; /* Complexity Weight of 1 */
- UWord32 L_msu0; /* Complexity Weight of 1 */
- UWord32 lshl; /* Complexity Weight of 1 */
- UWord32 lshr; /* Complexity Weight of 1 */
- UWord32 L_lshl; /* Complexity Weight of 1 */
-
- UWord32 L_lshr; /* Complexity Weight of 1 */
- UWord32 L40_lshl; /* Complexity Weight of 1 */
- UWord32 L40_lshr; /* Complexity Weight of 1 */
- UWord32 s_and; /* Complexity Weight of 1 */
- UWord32 s_or; /* Complexity Weight of 1 */
-
- UWord32 s_xor; /* Complexity Weight of 1 */
- UWord32 L_and; /* Complexity Weight of 1 */
- UWord32 L_or; /* Complexity Weight of 1 */
- UWord32 L_xor; /* Complexity Weight of 1 */
- UWord32 rotl; /* Complexity Weight of 3 */
-
- UWord32 rotr; /* Complexity Weight of 3 */
- UWord32 L_rotl; /* Complexity Weight of 3 */
- UWord32 L_rotr; /* Complexity Weight of 3 */
- UWord32 L40_set; /* Complexity Weight of 1 */
- UWord32 L40_deposit_h; /* Complexity Weight of 1 */
-
- UWord32 L40_deposit_l; /* Complexity Weight of 1 */
- UWord32 L40_deposit32; /* Complexity Weight of 1 */
- UWord32 Extract40_H; /* Complexity Weight of 1 */
- UWord32 Extract40_L; /* Complexity Weight of 1 */
- UWord32 L_Extract40; /* Complexity Weight of 1 */
-
- UWord32 L40_round; /* Complexity Weight of 1 */
- UWord32 L_saturate40; /* Complexity Weight of 1 */
- UWord32 round40; /* Complexity Weight of 1 */
- UWord32 If; /* Complexity Weight of 3 */
- UWord32 Goto; /* Complexity Weight of 2 */
-
- UWord32 Break; /* Complexity Weight of 2 */
- UWord32 Switch; /* Complexity Weight of 6 */
- UWord32 For; /* Complexity Weight of 3 */
- UWord32 While; /* Complexity Weight of 3 */
- UWord32 Continue; /* Complexity Weight of 2 */
-
- UWord32 L_mls; /* Complexity Weight of 1 */
- UWord32 div_l; /* Complexity Weight of 32 */
- UWord32 i_mult; /* Complexity Weight of 1 */
-
-/* New complex basic operators */
-#ifdef COMPLEX_OPERATOR
- UWord32 CL_shr; /* Complexity Weight of 1 */
- UWord32 CL_shl; /* Complexity Weight of 1 */
- UWord32 CL_add; /* Complexity Weight of 1 */
- UWord32 CL_sub; /* Complexity Weight of 1 */
- UWord32 CL_scale; /* Complexity Weight of 1 */
- UWord32 CL_dscale; /* Complexity Weight of 1 */
- UWord32 CL_msu_j; /* Complexity Weight of 1 */
- UWord32 CL_mac_j; /* Complexity Weight of 1 */
- UWord32 CL_move; /* Complexity Weight of 1 */
- UWord32 CL_Extract_real; /* Complexity Weight of 1 */
- UWord32 CL_Extract_imag; /* Complexity Weight of 1 */
- UWord32 CL_form; /* Complexity Weight of 1 */
- UWord32 CL_multr_32x16; /* Complexity Weight of 2 */
- UWord32 CL_negate; /* Complexity Weight of 1 */
- UWord32 CL_conjugate; /* Complexity Weight of 1 */
- UWord32 CL_mul_j; /* Complexity Weight of 1 */
- UWord32 CL_swap_real_imag; /* Complexity Weight of 1 */
- UWord32 C_add; /* Complexity Weight of 1 */
- UWord32 C_sub; /* Complexity Weight of 1 */
- UWord32 C_mul_j; /* Complexity Weight of 1 */
- UWord32 C_multr; /* Complexity Weight of 2 */
- UWord32 C_form; /* Complexity Weight of 1 */
-
- UWord32 C_scale; /* Complexity Weight of 1 */
- UWord32 CL_round32_16; /* Complexity Weight of 1 */
- UWord32 CL_scale_32; /* Complexity Weight of 1 */
- UWord32 CL_dscale_32; /* Complexity Weight of 1 */
- UWord32 CL_multr_32x32; /* Complexity Weight of 2 */
- UWord32 C_mac_r; /* Complexity Weight of 2 */
- UWord32 C_msu_r; /* Complexity Weight of 2 */
- UWord32 C_Extract_real; /* Complexity Weight of 1 */
- UWord32 C_Extract_imag; /* Complexity Weight of 1 */
- UWord32 C_negate; /* Complexity Weight of 1 */
- UWord32 C_conjugate; /* Complexity Weight of 1 */
- UWord32 C_shr; /* Complexity Weight of 1 */
- UWord32 C_shl; /* Complexity Weight of 1 */
-
-#endif /* #ifdef COMPLEX_OPERATOR */
-
-/* New 64 bit basops */
-#ifdef ENH_64_BIT_OPERATOR
- UWord32 move64; /* Complexity Weight of 1 */
- UWord32 W_add_nosat; /* Complexity Weight of 1 */
- UWord32 W_sub_nosat; /* Complexity Weight of 1 */
- UWord32 W_shl; /* Complexity Weight of 1 */
- UWord32 W_shr; /* Complexity Weight of 1 */
- UWord32 W_shl_nosat; /* Complexity Weight of 1 */
- UWord32 W_shr_nosat; /* Complexity Weight of 1 */
- UWord32 W_mac_32_16; /* Complexity Weight of 1 */
- UWord32 W_msu_32_16; /* Complexity Weight of 1 */
- UWord32 W_mult_32_16; /* Complexity Weight of 1 */
- UWord32 W_mult0_16_16; /* Complexity Weight of 1 */
- UWord32 W_mac0_16_16; /* Complexity Weight of 1 */
- UWord32 W_msu0_16_16; /* Complexity Weight of 1 */
- UWord32 W_mult_16_16; /* Complexity Weight of 1 */
- UWord32 W_mac_16_16; /* Complexity Weight of 1 */
- UWord32 W_msu_16_16; /* Complexity Weight of 1 */
- UWord32 W_shl_sat_l; /* Complexity Weight of 1 */
- UWord32 W_sat_l; /* Complexity Weight of 1 */
- UWord32 W_sat_m; /* Complexity Weight of 1 */
- UWord32 W_deposit32_l; /* Complexity Weight of 1 */
- UWord32 W_deposit32_h; /* Complexity Weight of 1 */
- UWord32 W_extract_l; /* Complexity Weight of 1 */
- UWord32 W_extract_h; /* Complexity Weight of 1 */
- UWord32 W_round48_L; /* Complexity Weight of 1 */
- UWord32 W_round32_s; /* Complexity Weight of 1 */
- UWord32 W_norm; /* Complexity Weight of 1 */
-
- UWord32 W_add; /* Complexity Weight of 1 */
- UWord32 W_sub; /* Complexity Weight of 1 */
- UWord32 W_neg; /* Complexity Weight of 1 */
- UWord32 W_abs; /* Complexity Weight of 1 */
- UWord32 W_mult_32_32; /* Complexity Weight of 1 */
- UWord32 W_mult0_32_32; /* Complexity Weight of 1 */
- UWord32 W_lshl; /* Complexity Weight of 1 */
- UWord32 W_lshr; /* Complexity Weight of 1 */
- UWord32 W_round64_L; /* Complexity Weight of 1 */
-
-#endif /* #ifdef ENH_64_BIT_OPERATOR */
-
-#ifdef ENH_32_BIT_OPERATOR
- UWord32 Mpy_32_16_1; /* Complexity Weight of 1 */
- UWord32 Mpy_32_16_r; /* Complexity Weight of 1 */
- UWord32 Mpy_32_32; /* Complexity Weight of 1 */
- UWord32 Mpy_32_32_r; /* Complexity Weight of 1 */
- UWord32 Madd_32_16; /* Complexity Weight of 1 */
- UWord32 Madd_32_16_r; /* Complexity Weight of 1 */
- UWord32 Msub_32_16; /* Complexity Weight of 1 */
- UWord32 Msub_32_16_r; /* Complexity Weight of 1 */
- UWord32 Madd_32_32; /* Complexity Weight of 1 */
- UWord32 Madd_32_32_r; /* Complexity Weight of 1 */
- UWord32 Msub_32_32; /* Complexity Weight of 1 */
- UWord32 Msub_32_32_r; /* Complexity Weight of 1 */
-#endif /* #ifdef ENH_32_BIT_OPERATOR */
-
-#ifdef ENH_U_32_BIT_OPERATOR
- UWord32 UL_addNs; /* Complexity Weight of 1 */
- UWord32 UL_subNs; /* Complexity Weight of 1 */
- UWord32 UL_Mpy_32_32; /* Complexity Weight of 1 */
- UWord32 Mpy_32_32_uu; /* Complexity Weight of 2 */
- UWord32 Mpy_32_16_uu; /* Complexity Weight of 2 */
- UWord32 norm_ul_float; /* Complexity Weight of 1 */
- UWord32 UL_deposit_l; /* Complexity Weight of 1 */
-#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
-
-#ifdef CONTROL_CODE_OPS
- UWord32 LT_16; /* Complexity Weight of 1 */
- UWord32 GT_16; /* Complexity Weight of 1 */
- UWord32 LE_16; /* Complexity Weight of 1 */
- UWord32 GE_16; /* Complexity Weight of 1 */
- UWord32 EQ_16; /* Complexity Weight of 1 */
- UWord32 NE_16; /* Complexity Weight of 1 */
- UWord32 LT_32; /* Complexity Weight of 1 */
- UWord32 GT_32; /* Complexity Weight of 1 */
- UWord32 LE_32; /* Complexity Weight of 1 */
- UWord32 GE_32; /* Complexity Weight of 1 */
- UWord32 EQ_32; /* Complexity Weight of 1 */
- UWord32 NE_32; /* Complexity Weight of 1 */
- UWord32 LT_64; /* Complexity Weight of 1 */
- UWord32 GT_64; /* Complexity Weight of 1 */
- UWord32 LE_64; /* Complexity Weight of 1 */
- UWord32 GE_64; /* Complexity Weight of 1 */
- UWord32 EQ_64; /* Complexity Weight of 1 */
- UWord32 NE_64; /* Complexity Weight of 1 */
-
-#endif /* #ifdef CONTROL_CODE_OPS */
-} BASIC_OP;
-
-
-Word32 TotalWeightedOperation( void );
-Word32 DeltaWeightedOperation( void );
-
-
-void generic_WMOPS_output( Word16 notPrintWorstWorstCase, char *test_file_name );
-/*
- * This function enable to append :
- * - to WMOPS_DATA_FILENAME file, the WMOPS information related
- * to the execution of the application, function group by function
- * group.
- * - to CODE_PROFILE_FILENAME file, the WMOPS information related
- * to the execution of the application, basic operation by basic
- * operation.
- * - to WMOPS_TOTAL_FILENAME file, the total WMOPS information related
- * to the execution of the application.
- *
- * Note that :
- * if the files exists, the data will be written at the end of file.
- *
- * test_file_name : Is a character string referencing each calls to
- * generic_WMOPS_output(). Usually, it is the name of a test
- * sequence file.
- *
- * notPrintWorstWorstCase : Same usage as in WMOPS_output().
- */
-void WMOPS_output_all( Word16 dtx_mode );
-void WMOPS_output_all_std( Word16 dtx_mode );
-
-/*
- * free all allocated counter memory
- */
-void WMOPS_destroy( void );
-
-/* jdr 20120117: add FLC similar functions */
-/* mul 20130729: set BASOP_COUNT_SUBROUTINES to count on a per-BASOP_sub_start()/BASOP_sub_end() base;
- otherwise, count only between BASOP_push_wmops(), BASOP_push_wmops() */
-#define BASOP_COUNT_SUBROUTINES
-void BASOP_push_wmops( const char *label );
-Word32 BASOP_pop_wmops( void );
-
-#define BASOP_init \
- { \
- setFrameRate( 32000, 640 ); \
- Init_WMOPS_counter(); /* 20ms frames */ \
- }
-#define BASOP_end \
- { \
- WMOPS_output_all_std( 0 ); \
- }
-/*#define BASOP_end { WMOPS_output_all(0); }*/
-#define BASOP_end_noprint \
- { \
- WMOPS_destroy(); \
- }
-
-#ifdef BASOP_COUNT_SUBROUTINES
-#define BASOP_sub_start( label ) \
- { \
- BASOP_push_wmops( label ); \
- }
-#define BASOP_sub_end() \
- { \
- BASOP_pop_wmops(); \
- }
-#else
-#define BASOP_sub_start( label )
-#define BASOP_sub_end()
-#endif
-
-void BASOP_frame_update( void );
-void Reset_all_WMOPS_counter( void );
-
-Word32 BASOP_get_wops( void );
-
-/*! Returns the total min/max/avg WMOPS values like printed in BASOP_end(). */
-void BASOP_get_total_wmops( double *min, double *max, double *avg );
-
-
-#define SUB_WMOPS_INIT( label ) BASOP_sub_start( label )
-#define END_SUB_WMOPS BASOP_sub_end()
-
-
-#endif /* _COUNT_H */
-
-
-/* end of file */
diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c
index 28a5ed44adb89fe0d83c735cf750ce43c3ea0fc3..301b666660a15d1530083c6acffda04ee43247dd 100644
--- a/lib_com/edct_fx.c
+++ b/lib_com/edct_fx.c
@@ -228,6 +228,67 @@ void edct_fx(
return;
}
+void edct_ivas_fx(
+ const Word32 *x, /* i : input signal Qq */
+ Word32 *y, /* o : output transform Qq */
+ Word16 length, /* i : length Q0*/
+ Word16 *q /* i : Q value of input signal */
+)
+{
+ Word16 i;
+ const Word16 *edct_table; /*Q16 */
+ Word32 re[L_FRAME_PLUS / 2];
+ Word32 im[L_FRAME_PLUS / 2];
+ Word32 L_tmp;
+ Word16 tmp;
+ Word16 len1;
+
+ edct_table = get_edct_table( length, q ); /*q*/
+ len1 = shr( length, 1 ); /*Q0*/
+ /* Twiddling and Pre-rotate */
+ FOR( i = 0; i < len1; i++ )
+ {
+ L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */
+ re[i] = Madd_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */
+ move32();
+
+ L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Q(q+1) */
+ im[i] = Msub_32_16( L_tmp, x[( i * 2 )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */
+ move32();
+ }
+
+ *q = sub( 31, *q );
+ move16();
+ tmp = sub( s_min( getScaleFactor32( re, len1 ), getScaleFactor32( im, len1 ) ), find_guarded_bits_fx( len1 ) );
+ scale_sig32( re, len1, tmp );
+ scale_sig32( im, len1, tmp );
+
+ fft_fx( re, im, len1, 1 );
+ *q = sub( *q, tmp );
+ move16();
+
+ tmp = div_s( 4, length ); /*Q17 */
+ tmp = round_fx( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ) ); /*Q15 */
+ FOR( i = 0; i < len1; i++ )
+ {
+ L_tmp = Msub_32_16( re[i], im[i], tmp );
+ im[i] = Madd_32_16( im[i], re[i], tmp ); /*Q(q+1) */
+ re[i] = L_tmp; /*Q(q+1) */
+ move32();
+ move32();
+ }
+ FOR( i = 0; i < len1; i++ )
+ {
+ y[2 * i] = L_add( Mult_32_16( re[i], edct_table[i] ), Mult_32_16( im[i], edct_table[( len1 - ( 1 + i ) )] ) ); /*Q(q+2)*/
+ move32();
+ y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( re[i], edct_table[( len1 - ( 1 + i ) )] ), Mult_32_16( im[i], edct_table[i] ) ); /*Q(q+2)*/
+ move32();
+ } /*Q(q-2) */
+
+ *q = sub( 31 + 2, *q );
+ move16();
+ return;
+}
/*-------------------------------------------------------------------------*
* FUNCTION : edst_fx()
*
diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c
index 1e6c41a0ef9ccb5b558dbb021ee700875ad16f2c..04c22ae97c40afa265e386e9fc2f3e268ef10795 100644
--- a/lib_com/enh1632.c
+++ b/lib_com/enh1632.c
@@ -58,12 +58,6 @@
#define WMC_TOOL_SKIP
-#ifdef WMOPS
-extern BASIC_OP multiCounter[MAXCOUNTERS];
-extern int currCounter;
-#endif /* ifdef WMOPS */
-
-
/*****************************************************************************
*
* Constants and Globals
diff --git a/lib_com/enh1632.h b/lib_com/enh1632.h
index 1477c6c8093b3048dcf64e3fbc2b874d49dc9945..eed55ccad44963372710d7919bbb3e9f13eed012 100644
--- a/lib_com/enh1632.h
+++ b/lib_com/enh1632.h
@@ -35,14 +35,6 @@
#include "stl.h"
-
-#ifdef WMOPS
-#include "count.h"
-extern BASIC_OP multiCounter[MAXCOUNTERS];
-extern int currCounter;
-#endif /* ifdef WMOPS */
-
-
/*****************************************************************************
*
* Prototypes for enhanced 16/32 bit arithmetic operators
diff --git a/lib_com/enh32.c b/lib_com/enh32.c
index d2466ce6423561dc4139627fcb0c8e1ac3bb7493..64afe89869987ec7073e0cdef0dfe2965f57926f 100644
--- a/lib_com/enh32.c
+++ b/lib_com/enh32.c
@@ -21,15 +21,10 @@
*****************************************************************************/
#include
#include
-#include "enh32.h"
+#include "stl.h"
#define WMC_TOOL_SKIP
-#ifdef WMOPS
-extern BASIC_OP multiCounter[MAXCOUNTERS];
-extern int currCounter;
-#endif /* if WMOPS */
-
#ifdef ENH_32_BIT_OPERATOR
/*****************************************************************************
*
diff --git a/lib_com/enh64.c b/lib_com/enh64.c
index a5c0879c03aa148556104431b7a25a8625484236..9eb58c4d399848547a585ff714a0f212adecad7d 100644
--- a/lib_com/enh64.c
+++ b/lib_com/enh64.c
@@ -16,16 +16,10 @@
*****************************************************************************/
#include
#include
-#include "enh64.h"
+#include "stl.h"
#define WMC_TOOL_SKIP
-#ifdef WMOPS
-extern BASIC_OP multiCounter[MAXCOUNTERS];
-extern int currCounter;
-#endif /* if WMOPS */
-
-
/*****************************************************************************
*
* Local Functions
diff --git a/lib_com/enhUL32.c b/lib_com/enhUL32.c
index 1fb529104902e45f3aaf110d64c3e165bd20b56a..5650821200a63bc8404fbb31286f78d2d60c27ef 100644
--- a/lib_com/enhUL32.c
+++ b/lib_com/enhUL32.c
@@ -25,16 +25,10 @@
#include
#include
#include "stl.h"
-#include "enhUL32.h"
+#include "stl.h"
#define WMC_TOOL_SKIP
-#ifdef WMOPS
-extern BASIC_OP multiCounter[MAXCOUNTERS];
-extern int currCounter;
-#endif /* if WMOPS */
-
-
/*****************************************************************************
*
* Constants and Globals
diff --git a/lib_com/enhUL32.h b/lib_com/enhUL32.h
index 39a79d700d330a41545a87b301b5ae1745581495..d200342b4b24e054ba0e5b92fea5b34d3ed37718 100644
--- a/lib_com/enhUL32.h
+++ b/lib_com/enhUL32.h
@@ -24,12 +24,6 @@
#define UWord64 unsigned long long /* for local use inside UL_Mpy_32_* */
#endif
-#ifdef WMOPS
-#include "count.h"
-extern BASIC_OP multiCounter[MAXCOUNTERS]; /* existing signed counters are reused for unsigedn operators */
-extern int currCounter;
-#endif /* if WMOPS */
-
/*****************************************************************************
*
* Prototypes for enhanced unsigned 32 bit arithmetic operators
diff --git a/lib_com/est_tilt.c b/lib_com/est_tilt.c
deleted file mode 100644
index e7ff1a63da5d19126d519598afb50fbc44e97071..0000000000000000000000000000000000000000
--- a/lib_com/est_tilt.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------*
- * est_tilt()
- *
- * Estimate spectral tilt based on the relative E of adaptive
- * and innovative excitations
- *-------------------------------------------------------------------*/
-
-/*! r: tilt of the code */
-float est_tilt(
- const float *adpt_exc, /* i : adaptive excitation vector */
- const float gain_pit, /* i : adaptive gain */
- const float *fixe_exc, /* i : algebraic exctitation vector */
- const float gain_code, /* i : algebraic code gain */
- float *voice_fac, /* o : voicing factor */
- const int16_t L_subfr, /* i : subframe size */
- const int16_t flag_tilt /* i : flag for special tilt */
-)
-{
- float ener, tmp, tilt_code;
-
- ener = dotp( adpt_exc, adpt_exc, L_subfr );
- ener *= gain_pit * gain_pit; /* energy of pitch excitation */
-
- tmp = dotp( fixe_exc, fixe_exc, L_subfr );
- tmp *= gain_code * gain_code; /* energy of innovative code excitation */
-
- /* find voice factor (1=voiced, -1=unvoiced) */
- *voice_fac = (float) ( ( ener - tmp ) / ( ener + tmp + 0.01f ) );
-
- /* find tilt of code for next subframe */
- if ( flag_tilt == 0 )
- {
- /*Between 0 (=unvoiced) and 0.5 (=voiced)*/
- tilt_code = (float) ( 0.25f * ( 1.0f + *voice_fac ) );
- }
- else if ( flag_tilt == 1 )
- {
- /*Between 0.25 (=unvoiced) and 0.5 (=voiced)*/
- tilt_code = (float) ( 0.25f + ( *voice_fac + 1.0f ) * 0.125f );
- }
- else
- {
- /*Between 0.28 (=unvoiced) and 0.56 (=voiced)*/
- tilt_code = (float) ( 0.28f + ( *voice_fac + 1.0f ) * 0.14f );
- }
-
- return tilt_code;
-}
diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c
index 64a4c8be2d23ba1d0ceb7aeebd581bcf0e542314..ba895d83c85f9b0f71100e94f7616a59e0d6fa94 100644
--- a/lib_com/fft_fx.c
+++ b/lib_com/fft_fx.c
@@ -7257,20 +7257,54 @@ Word16 find_guarded_bits_fx( Word32 n )
}
}
-Word16 L_norm_arr( Word32 *arr, Word16 size )
+Word16 L_norm_arr( const Word32 *arr, Word16 size )
{
Word16 q = 31;
move16();
FOR( Word16 i = 0; i < size; i++ )
+#ifndef FIX_1103_OPT_L_NORM_ARR
IF( arr[i] != 0 )
{
q = s_min( q, norm_l( arr[i] ) );
}
+#else
+ {
+ Word16 q_tst;
+
+ q_tst = norm_l( arr[i] );
+ if ( arr[i] != 0 )
+ {
+ q = s_min( q, q_tst );
+ }
+ }
+
+#endif
+ return q;
+}
+
+Word16 norm_arr( Word16 *arr, Word16 size )
+{
+ Word16 q = 15;
+ Word16 exp = 0;
+ move16();
+ move16();
+ FOR( Word16 i = 0; i < size; i++ )
+ {
+ if ( arr[i] != 0 )
+ {
+ exp = norm_s( arr[i] );
+ }
+ if ( arr[i] != 0 )
+ {
+ q = s_min( q, exp );
+ }
+ }
return q;
}
Word16 get_min_scalefactor( Word32 x, Word32 y )
{
+#ifndef FIX_1104_OPT_GETMINSCALEFAC
Word16 scf = Q31;
move16();
test();
@@ -7287,8 +7321,34 @@ Word16 get_min_scalefactor( Word32 x, Word32 y )
scf = s_min( scf, norm_l( y ) );
}
return scf;
+#else
+ Word16 scf_y;
+ Word16 scf = Q31;
+ move16();
+
+ test();
+ if ( x == 0 && y == 0 )
+ {
+ scf = 0;
+ move16();
+ }
+
+ if ( x != 0 )
+ {
+ scf = norm_l( x );
+ }
+
+ scf_y = norm_l( y );
+ if ( y != 0 )
+ {
+ scf = s_min( scf_y, scf );
+ }
+
+ return scf;
+#endif
}
+
Flag is_zero_arr( Word32 *arr, Word16 size )
{
FOR( Word16 i = 0; i < size; i++ )
@@ -7299,3 +7359,14 @@ Flag is_zero_arr( Word32 *arr, Word16 size )
return 1;
}
+
+Flag is_zero_arr16( Word16 *arr, Word16 size )
+{
+ FOR( Word16 i = 0; i < size; i++ )
+ IF( arr[i] != 0 )
+ {
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/lib_com/fine_gain_bits.c b/lib_com/fine_gain_bits.c
deleted file mode 100644
index fd9c0d49017bd7223ac3770b1597e852b3af5ce8..0000000000000000000000000000000000000000
--- a/lib_com/fine_gain_bits.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "rom_com.h"
-#include "prot.h"
-#include
-#include "wmc_auto.h"
-
-#ifndef IVAS_FLOAT_FIXED
-/*--------------------------------------------------------------------------
- * subband_gain_bits()
- *
- * HQ core encoder
- *--------------------------------------------------------------------------*/
-
-static void subband_gain_bits(
- const int16_t *Rk, /* i : bit allocation per band (Q3)*/
- const int16_t N, /* i : number of bands */
- int16_t *bits, /* o : gain bits per band */
- const int16_t *sfmsize /* i : Size of bands */
-)
-{
- int16_t i, b, tot;
- int16_t bps;
-
- tot = 0;
-
- for ( i = 0; i < N; i++ )
- {
- bps = ( Rk[i] * fg_inv_tbl_fx[sfmsize[i] >> 3] ) >> 18;
- if ( ( ( sfmsize[i] * ( bps + 1 ) ) << 3 ) - Rk[i] == 0 )
- { /* correct approx. division result, to obtain exact integer division output */
- bps++;
- }
- bps = min( 7, bps );
-
- b = fine_gain_bits[bps];
- bits[i] = b;
- tot += b;
- }
-
- if ( tot == 0 )
- {
- /* If no gain bits were assigned, use one bit anyway for potential PVQ overage */
- bits[0] = 1;
- }
-
- return;
-}
-
-/*--------------------------------------------------------------------------*
- * assign_gain_bits()
- *
- * Assign gain adjustment bits and update bit budget
- *--------------------------------------------------------------------------*/
-
-/*! r: Number of assigned gain bits */
-int16_t assign_gain_bits(
- const int16_t core, /* i : HQ core */
- const int16_t BANDS, /* i : Number of bands */
- const int16_t *band_width, /* i : Sub band bandwidth */
- int16_t *Rk, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
- int16_t *gain_bits_array, /* o : Assigned gain bits */
- int16_t *Rcalc /* o : Bit budget for shape quantizer (Q3) */
-)
-{
- int16_t gain_bits_tot;
- int16_t i;
-
- /* Allocate gain bits for every subband used, based on bitrate and bandwidth */
- if ( core == HQ_CORE )
- {
- subband_gain_bits( Rk, BANDS, gain_bits_array, band_width );
- }
- else
- {
- set_s( gain_bits_array, 0, BANDS );
- }
-
- /* Re-adjust bit budget for gain quantization */
- gain_bits_tot = 0;
- *Rcalc = 0;
- for ( i = 0; i < BANDS; i++ )
- {
- if ( Rk[i] > 0 )
- {
- Rk[i] -= gain_bits_array[i] * 8;
- gain_bits_tot += gain_bits_array[i];
- *Rcalc += Rk[i];
- }
- }
-
- return gain_bits_tot;
-}
-#endif
diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c
index b6871307a427b8fcbd6aadc7f915c487fb2f024d..e9075a02497f53a2a1858bf29e13a3a85b1b99ef 100644
--- a/lib_com/frame_ener_fx.c
+++ b/lib_com/frame_ener_fx.c
@@ -47,47 +47,6 @@
* Estimation of pitch-synchronous (voiced sounds) or half-frame energy
*----------------------------------------------------------------------------------*/
-#ifndef IVAS_FLOAT_FIXED
-void fer_energy(
- const int16_t L_frame, /* i : frame length */
- const int16_t clas, /* i : frame classification */
- const float *synth, /* i : synthesized speech at Fs = 12k8 Hz */
- const float pitch, /* i : pitch period */
- float *enr, /* o : pitch-synchronous or half_frame energy */
- const int16_t offset /* i : speech pointer offset (0 or L_frame) */
-)
-{
- int16_t len;
- const float *pt_synth;
-
- if ( clas == VOICED_CLAS || clas == ONSET || clas == SIN_ONSET ) /* Voiced or Onset current frame */
- {
- len = (int16_t) ( pitch + 0.5f ); /* pitch value */
-
- pt_synth = synth;
- if ( offset != 0 )
- {
- pt_synth = synth + L_frame - len;
- }
-
- emaximum( pt_synth, len, enr ); /* pitch synchronous E */
- }
- else
- {
- pt_synth = synth;
- if ( offset != 0 )
- {
- pt_synth = synth + L_frame / 2;
- }
-
- *enr = dotp( pt_synth, pt_synth, L_frame / 2 );
- *enr /= (float) ( L_frame / 2 );
- }
- return;
-}
-#endif
-
-#ifdef IVAS_FLOAT_FIXED
void fer_energy_fx(
const Word16 L_frame, /* i : frame length */
const Word16 clas, /* i : frame classification */
@@ -143,50 +102,6 @@ void fer_energy_fx(
}
return;
}
-#endif // IVAS_FLOAT_FIXED
-
-#ifndef IVAS_FLOAT_FIXED
-/*------------------------------------------------------------------------*
- * frame_energy()
- *
- * Compute pitch-synchronous energy at the frame end
- *------------------------------------------------------------------------*/
-
-float frame_energy(
- const int16_t L_frame, /* i : length of the frame */
- const float *pitch, /* i : pitch values for each subframe */
- const float *speech, /* i : pointer to speech signal for E computation */
- const float lp_speech, /* i : long-term active speech energy average */
- float *frame_ener /* o : pitch-synchronous energy at frame end */
-)
-{
- float enern;
- const float *pt1;
- int16_t len;
- float dotProd;
-
- len = (int16_t) ( 0.5f * ( pitch[2] + pitch[3] ) + 0.5f );
- if ( len < L_SUBFR )
- {
- len *= 2;
- }
-
- pt1 = speech + L_frame - len;
-
- dotProd = dotp( pt1, pt1, len );
- if ( 0 == dotProd )
- {
- *frame_ener = MIN_LOG_VAL_60dB;
- }
- else
- {
- *frame_ener = 10.0f * (float) log10( dotProd / (float) len );
- }
- enern = *frame_ener - lp_speech;
-
- return enern;
-}
-#endif
/*----------------------------------------------------------------------------------*
* frame_ener()
diff --git a/lib_com/get_gain_fx.c b/lib_com/get_gain_fx.c
index de5f6e80df1efd3012f61d993aab59f432512ec1..be4d063e75f103c5905a7d52f8cd3cde6d4eaa9d 100644
--- a/lib_com/get_gain_fx.c
+++ b/lib_com/get_gain_fx.c
@@ -46,34 +46,6 @@
*
*----------------------------------------------------------------------------------*/
-#ifndef IVAS_FLOAT_FIXED
-/*! r: codebook gain (adaptive or fixed) */
-float get_gain_flt(
- const float x[], /* i : target signal */
- const float y[], /* i : filtered codebook excitation */
- const int16_t n, /* i : segment length */
- float *en_y /* o : energy of y (sum of y[]^2, optional) */
-)
-{
- float corr = 0.0f, ener = 1e-6f;
- int16_t i;
-
- for ( i = 0; i < n; i++ )
- {
- corr += x[i] * y[i];
- ener += y[i] * y[i];
- }
-
- if ( en_y )
- {
- *en_y = ener;
- }
-
- return ( corr / ener );
-}
-#endif
-
-#ifdef IVAS_FLOAT_FIXED
Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */
const Word16 x[], /* input : target signal Qx */
const Word16 y[], /* input : filtered codebook excitation Qx */
@@ -178,4 +150,3 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed)
return Lgain;
}
-#endif
diff --git a/lib_com/gs_bitallocation.c b/lib_com/gs_bitallocation.c
deleted file mode 100644
index b787a201857b27bffa1b7d71ed757c08cf045a7d..0000000000000000000000000000000000000000
--- a/lib_com/gs_bitallocation.c
+++ /dev/null
@@ -1,1077 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "ivas_prot.h"
-#include "wmc_auto.h"
-
-
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------*
- * Local function prototypes
- *-------------------------------------------------------------------*/
-
-static float Find_bit_frac( const int16_t nb_band, const int16_t remaining_bits );
-
-static void reajust_bits( float *bits_per_bands, const int16_t st_band, const int16_t end_band, const int16_t sum_bit_in, const int16_t bit_bdgt_in );
-
-#define Q15_0_33 10922 /* 0.33 */
-#define Q18_0_1 26214 /* 0.1 */
-#define Q18_0_50 131072 /* 0.50 */
-#define Q18_0_75 196608 /* 0.75 */
-#define Q18_0_76 199229 /* 76/100 */
-#define Q18_1_0 262144 /* 1.0 */
-#define Q18_1_2 314573 /* 1.2 */
-#define Q18_112 29360128 /* 112 */
-#define Q18_DSR_NB_PULSE 1179648 /* 4.5 */
-#define Q18_1_5xDSR_NB_PULSE 1769472 /* 1.5x4.5 */
-#define Q18_2_0xDSR_NB_PULSE ( Q18_DSR_NB_PULSE << 1 ) /* 2.0x4.5 */
-
-#define Q31_0_00125 2684355 /* 0.125/100 */
-#define Q31_0_0125 26843546 /* 0.0125 */
-#define Q31_0_015 32212255 /* 0.0125 */
-#define Q31_0_02 42949673 /* 0.02 */
-#define Q31_0_17 365072220 /* 0.17 */
-#define Q31_0_23 493921239 /* 0.23 */
-
-static Word16 Find_norm_inv( const Word32 ToDivide, Word16 *e_div );
-static Word16 Find_bit_alloc_IVAS_int( const Word32 core_brate, const Word16 GSC_IVAS_mode, const Word16 Diff_len, const Word16 nb_tot_bands, const Word16 L_frame, Word16 *bit, Word16 *max_ener_band, float *ener_vec, float *bits_per_bands );
-static Word16 maximum_fx( const Word16 *vec_fx, const Word16 lvec_fx, Word16 *max_fx );
-
-/*-------------------------------------------------------------------*
- * bands_and_bit_alloc()
- *
- * AC mode (GSC) bands and bits allocation
- *-------------------------------------------------------------------*/
-
-void bands_and_bit_alloc(
- const int16_t cor_strong_limit, /* i : HF correlation */
- const int16_t noise_lev, /* i : dwn scaling factor */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
- const int16_t bits_used, /* i : Number of bit used before frequency Q */
- int16_t *bit, /* i/o: Number of bit allowed for frequency quantization */
- float *Ener_per_bd_iQ, /* i/o: Quantized energy vector */
- int16_t *max_ener_band, /* o : Sorted order */
- int16_t *bits_per_bands_s, /* i/o: Number of bit allowed per allowed subband (Q3) */
- int16_t *nb_subbands, /* o : Number of subband allowed */
- const float *exc_diff, /* i : Difference signal to quantize (encoder side only) */
- float *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */
- int16_t *pvq_len, /* o : Number of bin covered with the PVQ */
- const int16_t coder_type, /* i : coding type */
- const int16_t bwidth, /* i : input signal bandwidth */
- const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
- const int16_t L_frame, /* i : frame length */
- const int16_t element_mode, /* i : element mode */
- const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
-)
-{
- int16_t bandoffset, i, j, nb_bands_max, bit_new_bands, bit_tmp, st_band, nb_bands;
- float bit_fracf, etmp;
- float sum_bit;
- float ener_vec[MBANDS_GN_BITALLOC16k];
- int16_t nb_tot_bands;
- int16_t bit_index, bit_index_mem, imax;
- int16_t pos, band;
- float SWB_bit_budget;
- float bits_per_bands[MBANDS_GN_BITALLOC16k];
- float fzero_val;
-
- /* initializations */
- nb_tot_bands = 16;
- set_f( bits_per_bands, 0.0f, MBANDS_GN_BITALLOC16k );
-
- if ( L_frame == L_FRAME16k )
- {
- nb_tot_bands = MBANDS_GN_BITALLOC16k;
- }
-
- /* To adapt current energy band to PVQ freq band for sorting*/
- ener_vec[0] = Ener_per_bd_iQ[0] + Ener_per_bd_iQ[1];
- mvr2r( Ener_per_bd_iQ + 1, ener_vec, 15 );
- ener_vec[15] = ener_vec[14];
-
- if ( L_frame == L_FRAME16k )
- {
- ener_vec[16] = Ener_per_bd_iQ[16];
- ener_vec[17] = ( Ener_per_bd_iQ[16] + Ener_per_bd_iQ[17] ) * 0.5f;
- ener_vec[18] = Ener_per_bd_iQ[17];
- ener_vec[19] = Ener_per_bd_iQ[17] * 0.8f;
- }
-
- for ( i = 0; i < nb_tot_bands; i++ )
- {
- ener_vec[i] = (float) ( (int16_t) ( ener_vec[i] * 4096.f + 0.5f ) );
- }
-
- /*------------------------------------------------------------------------
- * Determination of the number of bits available to the frequency domain
- * Allocation of a maximum number of band to be encoded
- *-----------------------------------------------------------------------*/
-
- nb_bands_max = nb_tot_bands;
- bit_new_bands = 5;
-
- if ( core_brate > ACELP_16k40 && L_frame == L_FRAME16k )
- {
- bit_new_bands = 7;
- }
-
- i = 0;
- while ( i < SIZE_BRATE_INTERMED_TBL )
- {
- if ( core_brate <= brate_intermed_tbl[i] )
- {
- break;
- }
-
- if ( brate_intermed_tbl[i] == ACELP_24k40 )
- {
- break;
- }
-
- i++;
- }
-
- if ( element_mode > EVS_MONO && coder_type == AUDIO &&
- core_brate <= STEREO_GSC_BIT_RATE_ALLOC && 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--;
- }
-
- bit_index = BRATE2IDX( brate_intermed_tbl[i] ) * 17;
-
- bit_index_mem = bit_index;
-
- if ( ( coder_type == AUDIO || coder_type == INACTIVE ) && bwidth == NB )
- {
- if ( core_brate >= ACELP_9k60 )
- {
- *bit = (int16_t) ( core_brate * ( 1.0f / FRAMES_PER_SEC ) + 0.5f ) - bits_used - 25;
- }
- else
- {
- *bit = (int16_t) ( core_brate * ( 1.0f / FRAMES_PER_SEC ) + 0.5f ) - bits_used - 21;
- }
-
- nb_tot_bands = 10;
- }
- else
- {
- *bit = (int16_t) ( core_brate * ( 1.0f / FRAMES_PER_SEC ) + 0.5f ) - bits_used - GSC_freq_bits[bit_index];
- }
-
- if ( L_frame == L_FRAME16k )
- {
- *bit -= 8;
- }
-
- if ( coder_type == INACTIVE && core_brate <= GSC_LRES_GAINQ_LIMIT ) /* can happen only for 2nd channel inactive */
- {
- *bit += GSC_LRES_NB_NITS;
- }
-
- if ( *bit > 0 )
- {
- if ( GSC_IVAS_mode > 0 )
- {
- nb_tot_bands = Find_bit_alloc_IVAS_int( core_brate, GSC_IVAS_mode, Diff_len, nb_tot_bands, L_frame, bit, max_ener_band, ener_vec, bits_per_bands );
- nb_bands = nb_tot_bands;
- }
- else if ( GSC_noisy_speech )
- {
- SWB_bit_budget = *bit;
- nb_bands = 5;
-
- fzero_val = 0.0f;
- if ( element_mode > EVS_MONO )
- {
- fzero_val = MIN16B_FLT;
- }
-
- if ( coder_type == UNVOICED && element_mode > EVS_MONO )
- {
- nb_bands = 3;
- if ( SWB_bit_budget > 20 )
- {
- nb_bands = 5;
- }
- }
- else if ( bwidth < SWB )
- {
- nb_bands = 7;
- }
-
- st_band = nb_bands;
-
- set_f( bits_per_bands, 0, MBANDS_GN );
-
- bit_fracf = Find_bit_frac( nb_bands, (int16_t) SWB_bit_budget ); /* Supplementary bits distributed only on first bands */
-
- nb_tot_bands = nb_bands_max - 6;
-
- if ( nb_tot_bands > 16 )
- {
- nb_tot_bands = 16;
- }
-
- for ( j = 0; j < 2; j++ )
- {
- i = j;
- max_ener_band[j] = i;
- ener_vec[i] = fzero_val;
- }
-
- if ( bwidth < SWB )
- {
- if ( coder_type == UNVOICED && element_mode > EVS_MONO )
- {
- nb_tot_bands = 5;
- }
-
- for ( ; j < nb_bands; j++ )
- {
- i = maximum( ener_vec, nb_tot_bands, &etmp );
- max_ener_band[j] = i;
- ener_vec[i] = fzero_val;
- }
- }
- else
- {
- for ( ; j < nb_bands; j++ )
- {
- i = maximum( ener_vec, nb_tot_bands, &etmp );
- max_ener_band[j] = i;
- ener_vec[i] = fzero_val;
- }
- }
-
- set_f( bits_per_bands, bit_fracf, nb_bands );
- }
- else
- {
- bit_index++;
- bit_tmp = *bit - GSC_freq_bits[bit_index];
- bit_index++;
- nb_bands_max += GSC_freq_bits[bit_index];
- bit_index++;
-
- *pvq_len = 112;
- st_band = 7;
-
- if ( L_frame == L_FRAME16k && core_brate > ACELP_16k40 )
- {
- *pvq_len = 160;
- st_band = 10;
- nb_bands = *pvq_len / 16;
- bit_tmp -= 35;
- bit_new_bands = 5;
- }
-
- if ( core_brate <= ACELP_9k60 )
- {
- *pvq_len = 80;
- st_band = 5;
- if ( Diff_len == 0 )
- {
- nb_bands_max += 2;
- bit_tmp -= 13;
- }
- }
- else if ( Diff_len == 0 )
- {
- nb_bands_max += 2;
- bit_tmp -= 17;
- }
-
- nb_bands = *pvq_len / 16;
- nb_bands_max = min( nb_bands_max, MBANDS_GN_BITALLOC16k );
-
- /*------------------------------------------------------------------------
- * Adjustement of the maximum number of bands in function of the
- * dynamics of the spectrum (more or less speech like)
- *-----------------------------------------------------------------------*/
-
- if ( coder_type == INACTIVE || noise_lev >= NOISE_LEVEL_SP3 )
- {
- /* Probably classification error -> concentrate bits on LF */
- if ( L_frame == L_FRAME16k && core_brate >= ACELP_24k40 )
- {
- nb_bands_max = nb_tot_bands - 2;
- }
- else if ( core_brate >= ACELP_16k40 )
- {
- nb_bands_max = nb_bands + 2;
- }
- else if ( core_brate >= ACELP_8k00 )
- {
- nb_bands_max = nb_bands + 1;
- }
- else
- {
- nb_bands_max = nb_bands;
- }
- }
- else if ( noise_lev >= NOISE_LEVEL_SP2 || ( core_brate <= ACELP_13k20 && core_brate >= ACELP_9k60 && cor_strong_limit == 0 ) ) /* Very low dynamic, tend to speech, do not try to code HF at all */
- {
- nb_bands_max -= 2;
- }
- else if ( noise_lev >= NOISE_LEVEL_SP1 ) /* Very low dynamic, tend to speech, code less HF */
- {
- nb_bands_max -= 1;
- }
-
- if ( L_frame == L_FRAME16k )
- {
- if ( core_brate < ACELP_24k40 )
- {
- nb_bands_max -= 4;
- }
- else if ( core_brate < ACELP_32k )
- {
- if ( Diff_len > 0 || noise_lev >= NOISE_LEVEL_SP2 )
- {
- nb_bands_max -= 2;
- bit_new_bands *= 2;
- }
- }
- else if ( core_brate >= ACELP_32k )
- {
- bit_new_bands *= 2;
- }
- }
-
- if ( bwidth == NB && nb_bands_max > 10 )
- {
- nb_bands_max = 10;
- }
-
- /*------------------------------------------------------------------------
- * Find extra number of band to code according to bitrate availables
- *-----------------------------------------------------------------------*/
-
- while ( bit_tmp >= bit_new_bands && nb_bands <= nb_bands_max - 1 )
- {
- bit_tmp -= bit_new_bands;
- nb_bands++;
- }
-
- /*------------------------------------------------------------------------
- * Fractional bits to distribute on the first x bands
- *-----------------------------------------------------------------------*/
-
- if ( L_frame == L_FRAME16k && core_brate > ACELP_32k )
- {
- bit_fracf = 0;
- }
- else
- {
- bit_fracf = Find_bit_frac( st_band, bit_tmp ); /* Supplementary bits distributed only on first bands */
- }
-
- /*------------------------------------------------------------------------
- * Complete the bit allocation per frequency band
- *-----------------------------------------------------------------------*/
-
- imax = 5;
- if ( core_brate > ACELP_9k60 )
- {
- imax = 7;
- }
-
- for ( i = 0; i < imax; i++ )
- {
- bits_per_bands[i] = GSC_freq_bits[bit_index] + bit_fracf;
- bit_index++;
- }
-
- if ( L_frame == L_FRAME16k && core_brate > ACELP_16k40 )
- {
- bit_index = 0;
- i = imax - 1;
- bits_per_bands[i] += Compl_GSC_freq_bits[bit_index];
- i++;
- bit_index++;
-
- for ( ; i < 10; i++ )
- {
- bits_per_bands[i] += Compl_GSC_freq_bits[bit_index] + bit_fracf;
- bit_index++;
- }
- }
-
- if ( Diff_len == 0 )
- {
- bit_index = bit_index_mem + 10;
- for ( i = 0; i < 7; i++ )
- {
- bits_per_bands[i] += GSC_freq_bits[bit_index];
- bit_index++;
- }
- }
-
- if ( bit_fracf < 0 )
- {
- for ( j = 0; j < nb_tot_bands; j++ )
- {
- bits_per_bands[j] = max( bits_per_bands[j], 0 );
- }
- }
-
- /*--------------------------------------------------------------------------
- * Complete the bit allocation per frequency band for 16kHz high brate mode
- *--------------------------------------------------------------------------*/
-
- if ( L_frame == L_FRAME16k && core_brate > ACELP_32k )
- {
- for ( j = st_band; j < nb_bands; j++ )
- {
- bits_per_bands[j] = bit_new_bands;
- }
-
- bit_fracf = ( 1.0f / nb_bands ) * ( bit_tmp );
-
- etmp = 2.0f * bit_fracf / ( nb_bands + 1 );
- bit_fracf = etmp;
- for ( j = nb_bands - 1; j >= 0; j-- )
- {
- bits_per_bands[j] += etmp;
- etmp += bit_fracf;
- }
- }
- else
- {
- for ( j = st_band; j < nb_bands; j++ )
- {
- bits_per_bands[j] = bit_new_bands;
- }
- }
-
- /*--------------------------------------------------------------------------
- * Compute a maximum band (band offset) for the search on maximal energy
- * This is function of the spectral dynamic and the bitrate
- *--------------------------------------------------------------------------*/
-
- bandoffset = nb_tot_bands - ( nb_bands + 2 );
-
- if ( noise_lev <= NOISE_LEVEL_SP1a )
- {
- bandoffset--;
- }
- else if ( ( core_brate <= ACELP_13k20 && ( coder_type == INACTIVE || noise_lev >= NOISE_LEVEL_SP3 ) ) || ( core_brate <= ACELP_13k20 && core_brate >= ACELP_9k60 && cor_strong_limit == 0 ) )
- {
- bandoffset++;
- }
-
- if ( bandoffset < 0 )
- {
- bandoffset = 0;
- }
-
- /*--------------------------------------------------------------------------
- * Initiazed sorted vector
- * For the first x bands to be included in th final sorted vector
- * Sort the remaining bands in decrease energy order
- *--------------------------------------------------------------------------*/
-
- for ( j = 0; j < nb_tot_bands; j++ )
- {
- max_ener_band[j] = -10;
- }
-
- for ( j = 0; j < st_band; j++ )
- {
- max_ener_band[j] = j;
- ener_vec[j] = -10;
- }
-
- pos = st_band;
- for ( ; j < nb_bands; j++ )
- {
- i = maximum( ener_vec, nb_tot_bands - bandoffset, &etmp );
- if ( i > pos )
- {
- pos = i;
- }
- max_ener_band[j] = i;
- ener_vec[i] = -10;
- }
-
- /* re-allocate bits to the frames such that the highest band with allocated bits is higher than the threshold */
- if ( nb_tot_bands - bandoffset > nb_bands && ( pos > 7 && core_brate == ACELP_8k00 ) && bwidth == WB )
- {
- band = nb_tot_bands - bandoffset - nb_bands;
- for ( j = 0; j < band; j++ )
- {
- i = maximum( ener_vec, nb_tot_bands - bandoffset, &etmp );
- max_ener_band[nb_bands + j] = i;
- ener_vec[i] = -10;
- bits_per_bands[nb_bands + j] = 5;
- }
- nb_bands += band;
-
- bit_tmp = 5 * band;
- if ( band <= 2 )
- {
- for ( j = st_band - 1; j < nb_bands; j++ )
- {
- bits_per_bands[j] += 1;
- }
- bit_tmp += nb_bands - st_band + 1;
- }
-
- i = 0;
- j = 0;
- while ( bit_tmp > 0 )
- {
- bits_per_bands[j] -= 1;
-
- if ( j == st_band - 1 - i )
- {
- j = 0;
- }
- else
- {
- ++j;
- }
-
- if ( j == 0 && i < st_band - 1 )
- {
- i++;
- }
-
- bit_tmp -= 1;
- }
- }
-
- /*--------------------------------------------------------------------------
- * Bit sum verification for GSC inactive at very high rate
- * The maximum number of bits per band of length 16 is 112
- * Redistribute the overage bits if needed
- *--------------------------------------------------------------------------*/
-
- sum_bit = 0;
- j = 0;
- for ( i = 0; i < nb_bands; i++ )
- {
- if ( bits_per_bands[i] > 112 )
- {
- sum_bit += bits_per_bands[i] - 112;
- bits_per_bands[i] = 112;
- j = i + 1;
- }
-
- /* safety check for overage bit reallocation */
- else if ( bits_per_bands[i] + sum_bit / 3 > 112 )
- {
- j = i + 1;
- }
- }
-
- if ( sum_bit != 0 )
- {
- sum_bit /= ( nb_bands - j );
- for ( i = j; i < nb_bands; i++ )
- {
- bits_per_bands[i] += sum_bit;
- }
- }
- }
-
- /*--------------------------------------------------------------------------
- * second step of bit sum verification, normally sum_bit == *bit
- *--------------------------------------------------------------------------*/
-
- sum_bit = 0.00f;
- for ( i = 0; i < nb_bands; i++ )
- {
- bits_per_bands[i] = (float) floor( bits_per_bands[i] );
- sum_bit += bits_per_bands[i];
- }
-
- if ( GSC_IVAS_mode != 0 && sum_bit < *bit ) /* If we need to add bits, we are doing it on the LF */
- {
- reajust_bits( bits_per_bands, 0, nb_bands, (int16_t) sum_bit, *bit );
- }
- else
- {
- reajust_bits( bits_per_bands, nb_bands - 1, 0, (int16_t) sum_bit, *bit );
- }
-
- /*--------------------------------------------------------------------------
- * Recompute the real number/length of frequency bands to encode
- *--------------------------------------------------------------------------*/
-
- *nb_subbands = nb_bands;
- *pvq_len = *nb_subbands * 16;
-
- /*--------------------------------------------------------------------------
- * Concatenate bands (encoder only)
- *--------------------------------------------------------------------------*/
-
- if ( exc_diff != NULL )
- {
- for ( j = 0; j < nb_bands; j++ )
- {
- mvr2r( exc_diff + max_ener_band[j] * 16, concat_in + j * 16, 16 );
- }
- }
-
- set_s( bits_per_bands_s, 0, nb_tot_bands );
-
- for ( j = 0; j < nb_bands; j++ )
- {
- bits_per_bands_s[j] = ( (int16_t) bits_per_bands[j] ) << 3;
- }
- }
- else /* *bit == 0 */
- {
- set_s( bits_per_bands_s, 0, nb_tot_bands );
- *nb_subbands = 0;
- *pvq_len = 0;
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * reajust_bits()
- *
- *
- *-------------------------------------------------------------------*/
-
-static void reajust_bits(
- float *bits_per_bands,
- const int16_t st_band,
- const int16_t end_band,
- const int16_t sum_bit_in,
- const int16_t bit_bdgt_in )
-{
- int16_t i, amount_to_add, incr;
- int16_t bit_bdgt, sum_bit;
-
- incr = 1;
- if ( end_band < st_band )
- {
- incr = -1;
- }
-
- if ( bit_bdgt_in < sum_bit_in )
- {
- amount_to_add = -1;
- bit_bdgt = sum_bit_in;
- sum_bit = bit_bdgt_in;
- }
- else
- {
- bit_bdgt = bit_bdgt_in;
- sum_bit = sum_bit_in;
- amount_to_add = 1;
- }
-
- i = st_band;
- while ( bit_bdgt > sum_bit )
- {
- if ( amount_to_add > 0 || ( amount_to_add < 0 && bits_per_bands[i] > 1 ) )
- {
- bits_per_bands[i] += amount_to_add;
- sum_bit += (int16_t) abs( amount_to_add );
- }
-
- i += incr;
- if ( i == end_band )
- {
- i = st_band;
- }
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * Find_bit_frac()
- *
- * Computes the fraction of the remaining bit budget to allocate to the bands
- *-------------------------------------------------------------------*/
-
-static float Find_bit_frac(
- const int16_t nb_band,
- const int16_t remaining_bits )
-{
- float var_out;
- int16_t inv_bandQ15;
- int32_t L_num;
-
- inv_bandQ15 = 6553;
- if ( nb_band == 7 )
- {
- inv_bandQ15 = 4681;
- }
- else if ( nb_band == 3 )
- {
- inv_bandQ15 = 10922;
- }
- else if ( nb_band == 4 )
- {
- inv_bandQ15 = 8192;
- }
- else if ( nb_band == 5 )
- {
- inv_bandQ15 = 6536;
- }
- else if ( nb_band == 10 )
- {
- inv_bandQ15 = 3277;
- }
- else
- {
- inv_bandQ15 = (int16_t) ( ( 1.0f / nb_band ) * 32678 + 0.5f );
- }
-
- L_num = inv_bandQ15 * remaining_bits;
- L_num *= 8;
- var_out = L_num / 262144.0f;
-
- return ( var_out );
-}
-
-static Word16 Find_bit_alloc_IVAS_int( /* o : Number of band to encode */
- const Word32 core_brate, /* i : core bit rate */
- const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */
- const Word16 Diff_len, /* i : Length of the difference signal (before pure spectral)*/
- const Word16 nb_tot_bands_in, /* i : total number of band */
- const Word16 L_frame, /* i : frame length */
- Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */
- Word16 *max_ener_band, /* i/o: Energy based sorted order */
- float *ener_vec_io, /* i/o: Energy per band order */
- float *bits_per_bands_o /* o : Number of bit allowed per allowed sub-band Q3 */
-)
-{
- Word32 mp, mb, nb_bands_adj, bit_adj;
- Word16 nb_pulse_per_band[MBANDS_GN_BITALLOC16k];
- Word32 SWB_bit_budget; // Q0 -> Q18
- Word16 i, j, nb_bands_max, st_band, nb_tot_bands_loc, etmp;
- Word32 sum_bit /*Q18*/, bit_fracf /*Q18*/;
- Word16 d_tmp, e_div, tmp16, ener_vec[MBANDS_GN_BITALLOC16k];
- Word32 Ltmp, etmp_32fx, bits_per_bands[MBANDS_GN_BITALLOC16k];
-
- SWB_bit_budget = *bit; // Q0
- st_band = 5;
- nb_bands_max = nb_tot_bands_in;
-
- for ( i = 0; i < MBANDS_GN; i++ )
- {
- ener_vec[i] = (short) ( ener_vec_io[i] ); /* Q12 -> Q12 */
- }
-
- if ( L_frame == L_FRAME16k )
- {
- for ( i = MBANDS_GN; i < MBANDS_GN_BITALLOC16k; i++ )
- {
- ener_vec[i] = (short) ( ener_vec_io[i] * 4096.0 + 0.5f ); /* Q0 -> Q12 */
- }
- }
-
- set_l( bits_per_bands, 0, MBANDS_GN_BITALLOC16k );
-
- /* Decide the pourcentage of bits allocated to LF (between 50-75%) depending of the temporal contribution in GSC */
- /* bit_fracf = ( -0.125f * Diff_len + 76.0f ) / 100; */
- bit_fracf = L_add( Mpy_32_32( -Q31_0_00125, L_shl( Diff_len, 18 ) ), Q18_0_76 ); /* Q18 */
-
- /* bit_fracf = check_bounds(bit_fracf, 0.50f, 0.75f); */
- bit_fracf = min( max( bit_fracf, Q18_0_50 ), Q18_0_75 );
-
- /* Adjusment of the bitrate between LF and HF base on the content type */
- /* 1 = new GSC bit alloc
- 2 = GSC bit alloc for tc frame
- 3 = more music like (should not happen often given music is coded with dft) */
-
- if ( GSC_IVAS_mode <= 3 )
- {
- nb_bands_max -= 6;
- }
-
- if ( GSC_IVAS_mode == 2 )
- {
- /* bit_fracf += 0.1f; */
- bit_fracf += Q18_0_1; /* Q18*/
- nb_bands_max -= 1;
- }
-
- if ( GSC_IVAS_mode == 3 )
- {
- /* bit_fracf -= 0.1f; */
- bit_fracf -= Q18_0_1; /* Q18*/
- nb_bands_max += 3;
- }
-
- /* First find how much we want to share between LF and HF, at low bitrate, a miminum of bits is needed in LF by limitating the number of bands*/
- /* Adjust the number of band based on the content type and bitrate */
-
- /* nb_bands_adj = 1.0f; */
- nb_bands_adj = Q18_1_0;
- if ( GSC_IVAS_mode == 1 && core_brate < GSC_L_RATE_STG )
- {
- /* nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f;*/
- nb_bands_adj = L_sub( Mpy_32_32( Q31_0_0125, L_shl( SWB_bit_budget, 18 ) ), Q18_0_75 ); // Q18
- }
- else if ( GSC_IVAS_mode != 2 && core_brate > GSC_H_RATE_STG )
- {
- /*nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f;*/
- nb_bands_adj = L_sub( Mpy_32_32( Q31_0_02, L_shl( SWB_bit_budget, 18 ) ), Q18_1_2 ); // Q18
- }
- /*nb_bands_max = (int16_t)(nb_bands_max * nb_bands_adj + 0.5f);*/
-
- nb_bands_max = round_fx( Mpy_32_16_1( L_shl( nb_bands_adj, 5 ), shl( nb_bands_max, 10 - 2 ) ) ); /* Q0 */
- nb_bands_max = check_bounds_s( nb_bands_max, 5, nb_tot_bands_in );
-
- /* bit_fracf *= SWB_bit_budget;*/
- /* At this point bit_fracf has a value below 1.0 */
- bit_fracf = Mpy_32_16_1( L_shl( bit_fracf, 10 ), extract_l( L_shl( SWB_bit_budget, 5 ) ) ); /* (Q(18+10)*Q(0+5) + 1 - 16 = Q18 */
-
- /* Estimation of the number of bit used in HF */
- /* with only the first weighting The number of bits in max_ener_band[st_band-1] = 17% of bit_fracf */
- /* mb = .17f * bit_fracf;*/
- mb = Mpy_32_32( Q31_0_17, bit_fracf ); /* Q18 */
-
- /* mp = 2 * DSR_NB_PULSE;*/
- mp = Q18_2_0xDSR_NB_PULSE;
- if ( core_brate < GSC_L_RATE_STG && GSC_IVAS_mode == 3 )
- {
- /* mp = 1.5f * DSR_NB_PULSE;*/
- mp = Q18_1_5xDSR_NB_PULSE;
- }
- else if ( core_brate < GSC_L_RATE_STG )
- {
- /* mp = DSR_NB_PULSE;*/
- mp = Q18_DSR_NB_PULSE;
- }
-
- /* We want max_ener_band[st_band] <= max_ener_band[st_band-1] and max_ener_band[nb_bands_max-1] <= max_ener_band[st_band]*/
- /* We will estimate the number of bits to allocate of HF and put the remaining bits, if any, back on LF */
- /* compute the total possible number of band to be coded */
-
- /* nb_tot_bands = (int16_t)((SWB_bit_budget - bit_fracf) / (mp + (mb - mp) / 2.0f)); */
- d_tmp = Find_norm_inv( L_add( mp, mb ), &e_div );
- Ltmp = Mpy_32_16_1( L_sub( L_shl( SWB_bit_budget, 18 ), bit_fracf ), d_tmp ); /* Perform mult by 1/den */
- nb_tot_bands_loc = extract_h( L_shl( Ltmp, sub( 1, e_div ) ) ); /* adjust exponent: 1 is to take into account the / 2.0f, and e_div for the num and den of the division*/
-
- mp = min( mp, mb );
- tmp16 = sub( add( nb_tot_bands_loc, st_band ), nb_bands_max );
- if ( tmp16 > 0 )
- {
- /* bit_adj = ( ( mb + mp ) / 2 ) * ( nb_tot_bands_loc + st_band - nb_bands_max ); */
- bit_adj = Mpy_32_16_1( L_shl( L_add( mb, mp ), 5 ), shl( tmp16, 10 - 1 ) ); /* Q18+5 * Q0+10 + 1 -1 - 16 = Q18 (-1 is to cover for the /2 in the equation) */
- bit_adj = L_max( 0, bit_adj );
- nb_tot_bands_loc = nb_bands_max - st_band;
- bit_fracf += bit_adj; /* Q18 */
- }
- nb_tot_bands_loc += st_band;
-
- /* Allocate bits to LF */
- /* etmp = 0.23f; */
- etmp_32fx = Q31_0_23;
- for ( j = 0; j < st_band; j++ )
- {
- i = j;
- max_ener_band[j] = i;
- ener_vec[i] = MIN16B;
- /* bits_per_bands[j] = etmp * bit_fracf; */
- bits_per_bands[j] = Mpy_32_32( bit_fracf, etmp_32fx ); /* 18 + 31 + 1 - 32 = Q18 */
- /* etmp -= 0.015f; */
- etmp_32fx -= Q31_0_015; /* Q18 */
- }
-
- /* SWB_bit_budget -= bit_fracf; */
- SWB_bit_budget = L_sub( L_shl( SWB_bit_budget, 18 ), bit_fracf ); /* Q0->Q18 */
-
- /* Find low energy band in HF */
- set_s( nb_pulse_per_band, 2, MBANDS_GN_BITALLOC16k );
- for ( i = st_band + 2; i < nb_tot_bands_loc - 1; i++ )
- {
- if ( ener_vec[i] < ener_vec[i - 1] && ener_vec[i] < ener_vec[i + 1] ) /* i +1 and i -1 can be considered as 2 ptrs */
- {
- nb_pulse_per_band[i] = 1;
- }
- }
-
- for ( j = st_band; j < nb_tot_bands_loc; j++ )
- {
- if ( j > 6 )
- {
- i = maximum_fx( ener_vec, nb_tot_bands_loc, &etmp );
- }
- else
- {
- i = j;
- }
- max_ener_band[j] = i;
- ener_vec[i] = MIN16B;
- }
-
- /* Recompute the final bit distribution for HF */
- if ( nb_tot_bands_loc > st_band )
- {
- /* This is not bit exact because of the precision lost */
- /* mb = ( SWB_bit_budget * 2 / ( nb_tot_bands_loc - st_band ) ) - mp; */
- d_tmp = Find_norm_inv( L_deposit_h( sub( nb_tot_bands_loc, st_band ) ), &e_div );
- mb = L_sub( L_shr( Mpy_32_16_1( L_shl( SWB_bit_budget, 1 ), d_tmp ), e_div ), mp ); /* Q18 */
- /* bit_fracf = ( mb - mp ) / ( nb_tot_bands_loc - st_band ); */
- bit_fracf = L_shr( Mpy_32_16_1( L_sub( mb, mp ), d_tmp ), e_div ); /* Q18 */
-
- mb -= bit_fracf;
- /* Do the distribution */
- for ( j = st_band; j < nb_tot_bands_loc; j++ )
- {
- bits_per_bands[max_ener_band[j]] = Q18_DSR_NB_PULSE;
- if ( nb_pulse_per_band[max_ener_band[j]] > 1 )
- {
- bits_per_bands[max_ener_band[j]] = mb;
- }
- mb -= bit_fracf;
- SWB_bit_budget -= bits_per_bands[max_ener_band[j]]; // Q18
- }
- }
-
- /* Series of verification in case bit allocated != the budget */
- if ( SWB_bit_budget > 0 )
- {
- i = st_band - 1;
- while ( SWB_bit_budget > 0 )
- {
- /* bits_per_bands[i]++; */
- bits_per_bands[i] += Q18_1_0;
- /* SWB_bit_budget--; */
- SWB_bit_budget -= Q18_1_0;
- i--;
- if ( i == -1 )
- {
- i = st_band - 1;
- }
- }
- }
-
- /*nb_bands = nb_tot_bands_loc;*/
-
- sum_bit = 0;
- j = 0;
- for ( i = 0; i < nb_tot_bands_loc; i++ )
- {
- /* if (bits_per_bands[i] > 112) */
- if ( bits_per_bands[i] > Q18_112 )
- {
- /* sum_bit += bits_per_bands[i] - 112; */
- sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], Q18_112 ) );
- /* bits_per_bands[i] = 112; */
- bits_per_bands[i] = Q18_112;
- j = add( j, add( i, 1 ) );
- }
-
- /* safety check for overage bit reallocation */
- /* else if (bits_per_bands[i] + sum_bit / 3 > 112) */
- else if ( L_add( bits_per_bands[i], Mpy_32_16_1( sum_bit, Q15_0_33 ) ) > Q18_112 )
- {
- j = add( j, add( i, 1 ) );
- }
- }
-
- if ( sum_bit != 0 )
- {
- /* sum_bit /= (nb_bands - j); */
- d_tmp = Find_norm_inv( L_deposit_h( sub( nb_tot_bands_loc, j ) ), &e_div );
- sum_bit = L_shr( Mpy_32_16_1( sum_bit, d_tmp ), e_div ); /* Q18 */
- for ( i = j; i < nb_tot_bands_loc; i++ )
- {
- bits_per_bands[i] = L_add( bits_per_bands[i], sum_bit );
- }
- }
-
- for ( i = 0; i < MBANDS_GN_BITALLOC16k; i++ )
- {
- bits_per_bands_o[i] = (float) bits_per_bands[i] / 262144.0f; /* Q18 -> float */
- }
-
- return nb_tot_bands_loc;
-}
-
-/* Find normalized 1 / ToDivide */
-static Word16 Find_norm_inv(
- const Word32 ToDivide,
- Word16 *e_div )
-{
- Word16 d_tmp, e_tmp;
-
- e_tmp = norm_l( ToDivide );
- d_tmp = round_fx( L_shl( ToDivide, e_tmp ) );
- d_tmp = div_s( 16384, d_tmp ); /* 1.0 in Q14, dividend is normalize so >= 16384 as required for the division */
- *e_div = sub( 14, e_tmp );
-
- return d_tmp;
-}
-
-static Word16 maximum_fx( /* o : index of the maximum value in the input vector */
- const Word16 *vec_fx, /* i : input vector */
- const Word16 lvec_fx, /* i : length of input vector */
- Word16 *max_fx /* o : maximum value in the input vector */
-)
-{
- Word16 j, ind, tmp;
-
- ind = 0;
- move16();
- tmp = vec_fx[0];
- move16();
-
- FOR( j = 1; j < lvec_fx; j++ )
- {
- if ( GT_16( vec_fx[j], tmp ) )
- {
- ind = j;
- move16();
- }
- tmp = s_max( tmp, vec_fx[j] );
- }
- *max_fx = tmp;
- move16();
-
- return ind;
-}
-#endif
diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c
index aa74215b04494078ebba3d25059cb45cbc0d71f9..787d562c74404faf382b0a45929405c3fe75ceed 100644
--- a/lib_com/gs_bitallocation_ivas_fx.c
+++ b/lib_com/gs_bitallocation_ivas_fx.c
@@ -1007,7 +1007,7 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number
/*nb_bands_max = (int16_t)(nb_bands_max * nb_bands_adj + 0.5f);*/
nb_bands_max = round_fx( Mpy_32_16_1( L_shl( nb_bands_adj, 5 ), shl( nb_bands_max, 10 - 2 ) ) ); /* Q0 */
- nb_bands_max = check_bounds_s( nb_bands_max, 5, nb_tot_bands_in );
+ nb_bands_max = check_bounds_s_fx( nb_bands_max, 5, nb_tot_bands_in );
/* bit_fracf *= SWB_bit_budget;*/
diff --git a/lib_com/gs_gains.c b/lib_com/gs_gains.c
index 7f0be1c7958577bc4994a1e5428a4c49c1cc38d8..13fdbd67ca68c7cf8f20b01fa974dea2859a4cf1 100644
--- a/lib_com/gs_gains.c
+++ b/lib_com/gs_gains.c
@@ -43,234 +43,6 @@
#include "prot_fx.h"
#include "wmc_auto.h"
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------*
- * Local function prototypes
- *-------------------------------------------------------------------*/
-
-static int16_t VDQ_vec( float *Qvec_out, const float *mean_dic, const float *dic, const int16_t index, const int16_t vec_en );
-#endif
-
-/*-------------------------------------------------------------------*
- * Comp_and_apply_gain()
- *
- * Compute and apply the quantized per band gain
- *-------------------------------------------------------------------*/
-
-#ifndef IVAS_FLOAT_FIXED
-void Comp_and_apply_gain(
- float exc_diffQ[], /* i/o: Quantized excitation */
- float Ener_per_bd_iQ[], /* o : Target ener per band */
- float Ener_per_bd_yQ[], /* o : Ener per band for norm vector */
- int16_t Mbands_gn, /* i : number of bands */
- const int16_t ReUseGain /* i : Reuse the gain in Ener_per_bd_yQ */
-)
-{
- int16_t i, i_band;
- int16_t StartBin, NB_Qbins;
- float y_gain;
-
- /* Recreate excitation for local synthesis and decoder */
- StartBin = 0;
- NB_Qbins = 0;
- for ( i_band = 0; i_band < Mbands_gn; i_band++ )
- {
- StartBin += NB_Qbins;
- NB_Qbins = mfreq_bindiv_loc[i_band];
- if ( ReUseGain == 1 )
- {
- y_gain = Ener_per_bd_yQ[i_band];
- }
- else
- {
- y_gain = (float) pow( 10, ( Ener_per_bd_iQ[i_band] - Ener_per_bd_yQ[i_band] ) );
- Ener_per_bd_yQ[i_band] = y_gain;
- }
-
- for ( i = StartBin; i < NB_Qbins + StartBin; i++ )
- {
- exc_diffQ[i] *= y_gain;
- }
- }
-
- return;
-}
-#endif
-
-#ifndef IVAS_FLOAT_FIXED
-/*------------------------------------------------------------------*
- * Ener_per_band_comp()
- *
- * Compute the energy per band in log domain for quantization purposes
- * Loops are decomposed to accomodate the PVQ quantization
- *------------------------------------------------------------------*/
-
-void Ener_per_band_comp(
- const float exc_diff[], /* i : target signal */
- float y_gain4[], /* o : Energy per band to quantize */
- const int16_t Mband, /* i : Max band */
- const int16_t Eflag, /* i : flag of highest band */
- const int16_t L_frame /* i : frame length */
-)
-{
- float etmp;
- const float *pt;
- int16_t i, j;
-
- pt = exc_diff;
- for ( j = 0; j < 2; j++ )
- {
- y_gain4[j] = 0;
- etmp = 0.02f;
-
- pt = exc_diff + j * 8;
- for ( i = 0; i < 8; i++ )
- {
- etmp += ( *pt * *pt );
- pt++;
- }
-
- /* normalized to 16 bins to easy the quantization */
- y_gain4[j] = (float) log10( sqrt( 2 * etmp ) );
- }
-
- for ( j = 1; j < Mband - 2; j++ )
- {
- etmp = 0.01f;
-
- pt = exc_diff + j * 16;
- for ( i = 0; i < 16; i++ )
- {
- etmp += ( *pt * *pt );
- pt++;
- }
-
- y_gain4[j + 1] = (float) log10( sqrt( etmp ) );
- }
-
- if ( Eflag == 1 )
- {
- etmp = 0.01f;
-
- pt = exc_diff + j * 16;
- for ( i = 0; i < 32; i++ )
- {
- etmp += ( *pt * *pt );
- pt++;
- }
-
- y_gain4[j + 1] = (float) log10( sqrt( etmp / 2 ) );
- }
-
- if ( L_frame == L_FRAME16k )
- {
- etmp = 0.01f;
-
- for ( i = 0; i < 32; i++ )
- {
- etmp += ( *pt * *pt );
- pt++;
- }
-
- y_gain4[j + 2] = (float) log10( sqrt( etmp / 2 ) );
-
- for ( i = 0; i < 32; i++ )
- {
- etmp += ( *pt * *pt );
- pt++;
- }
-
- y_gain4[j + 3] = (float) log10( sqrt( etmp / 2 ) );
- }
-
- return;
-}
-#endif
-
-
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------*
- * GSC_gain_DQ()
- *
- * Form the final vector after gain quantization/Dequantization
- * Common to both encoder and decoder
- *-------------------------------------------------------------------*/
-
-static void GSC_gain_DQ(
- const int16_t element_mode, /* i : element mode */
- const int16_t enc_dec, /* i : encoder/decoder flag */
- const int16_t coder_type, /* i : Coder type */
- const int16_t Mbands_gn, /* i : Number of band */
- const int32_t core_brate, /* i : Core bitrate */
- const float mean_g, /* i : Average gain */
- const float *Gain_in, /* i : Unquantized gain vector */
- float *Gain_out /* o : Level adjusted unquantized gain vector */
-)
-{
- float Gain_off;
- int16_t i;
-
- /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
- Gain_off = 0.0f;
- if ( coder_type == INACTIVE || coder_type == UNVOICED )
- {
- if ( core_brate <= ACELP_5k00 && coder_type == UNVOICED )
- {
- Gain_off = 9.f;
- }
- else if ( core_brate <= ACELP_7k20 )
- {
- Gain_off = 8.f; /* 0 dB */
- }
- else if ( core_brate <= ACELP_8k00 )
- {
- Gain_off = 6.6f; /* ~-3.3 dB */
- }
- else if ( core_brate <= ACELP_9k60 )
- {
- Gain_off = 4.8f; /* ~-2.4 dB */
- }
- else if ( core_brate <= ACELP_11k60 )
- {
- Gain_off = 3.5f; /* ~-2.4 dB */
- }
- else if ( core_brate <= ACELP_13k20 )
- {
- Gain_off = 3.0f; /* ~-2.4 dB */
- }
- }
-
- if ( coder_type != INACTIVE && coder_type != UNVOICED )
- {
- for ( i = 0; i < Mbands_gn; i++ )
- {
- Gain_out[i] = Gain_in[i] + mean_g;
- }
- }
- else
- {
- /*mimic ACELP decay of energy for low rates*/
- if ( element_mode == EVS_MONO && 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] += mean_g - i * ( Gain_off / 20.f ) / ( (float) Mbands_gn );
- }
- }
- else
- {
- for ( i = 0; i < Mbands_gn; i++ )
- {
- Gain_out[i] = Gain_in[i] + mean_g - ( i * ( Gain_off / 20.f ) / ( (float) Mbands_gn ) );
- }
- }
- }
-
- return;
-}
-#endif
-
static void GSC_gain_DQ_fx(
const Word16 element_mode, /* i : element mode */
const Word16 enc_dec, /* i : encoder/decoder flag */
@@ -362,240 +134,6 @@ static void GSC_gain_DQ_fx(
return;
}
-
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------*
- * gsc_gainQ()
- *
- * Quantization of the energy per band
- *-------------------------------------------------------------------*/
-
-float gsc_gainQ(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t element_mode, /* i : element mode */
- const int16_t idchan, /* i : channel ID */
- const float y_gain4[], /* i : Energy per band */
- float y_gainQ[], /* o : quantized energy per band */
- 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 */
-)
-{
- float y_gain_tmp[MBANDS_GN16k], y_gain_tmp2[MBANDS_GN16k];
- int16_t i, idx_g = 0;
- float mean_4g[1], ftmp1;
- int16_t Mbands_gn = MBANDS_GN;
- float y_gain_tmp3[MBANDS_GN];
-
- if ( L_frame == L_FRAME16k )
- {
- Mbands_gn = MBANDS_GN16k;
- }
-
- mean_4g[0] = 0;
-
- if ( ( coder_type == AUDIO || coder_type == INACTIVE ) && bwidth == NB )
- {
- ftmp1 = mean( y_gain4, 10 ) - 0.6f;
- for ( i = 0; i < Mbands_gn; i++ )
- {
- if ( y_gain4[i] < ftmp1 )
- {
- y_gain_tmp2[i] = ftmp1;
- }
- else
- {
- y_gain_tmp2[i] = y_gain4[i];
- }
- }
-
- /* Quantized mean gain without clipping */
- mean_4g[0] = mean( y_gain_tmp2, 10 );
- idx_g = (int16_t) vquant( mean_4g, Gain_meanNB, mean_4g, Gain_mean_dicNB, 1, 64 );
- push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
-
- for ( i = 0; i < Mbands_gn; i++ )
- {
- y_gain_tmp[i] = y_gain_tmp2[i] - mean_4g[0];
- }
-
- if ( y_gain_tmp[9] < -0.3f )
- {
- y_gain_tmp[9] = -0.3f;
- }
-
- set_f( y_gain_tmp + 10, 0.0f, MBANDS_GN - 10 );
- idx_g = (int16_t) vquant( y_gain_tmp, Mean_dic_NB, y_gain_tmp, Gain_dic1_NB, 3, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- if ( core_brate < ACELP_9k60 )
- {
- idx_g = vquant( y_gain_tmp + 3, Mean_dic_NB + 3, y_gain_tmp + 3, Gain_dic2_NB, 3, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- idx_g = vquant( y_gain_tmp + 6, Mean_dic_NB + 6, y_gain_tmp + 6, Gain_dic3_NB, 4, 16 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 );
- }
- else
- {
- idx_g = vquant( y_gain_tmp + 3, Mean_dic_NB + 3, y_gain_tmp + 3, Gain_dic2_NBHR, 3, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant( y_gain_tmp + 6, Mean_dic_NB + 6, y_gain_tmp + 6, Gain_dic3_NBHR, 4, 128 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 );
- }
-
- if ( 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( y_gain_tmp + 6, 3 );
- y_gain_tmp[11] = mean( y_gain_tmp + 7, 3 );
- y_gain_tmp[12] = mean( y_gain_tmp + 8, 3 );
- y_gain_tmp[13] = mean( y_gain_tmp + 9, 3 );
- y_gain_tmp[14] = mean( y_gain_tmp + 10, 3 );
- y_gain_tmp[15] = mean( y_gain_tmp + 11, 3 );
- }
- else
- {
- set_f( y_gain_tmp + 10, 0, MBANDS_GN - 10 );
- }
- }
- else
- {
- ftmp1 = mean( y_gain4, 16 );
- for ( i = 0; i < Mbands_gn; i++ )
- {
- if ( y_gain4[i] < ftmp1 - 0.6f )
- {
- y_gain_tmp2[i] = ftmp1 - .6f;
- }
- else if ( y_gain4[i] > ftmp1 + 0.6f )
- {
- y_gain_tmp2[i] = ftmp1 + 0.6f;
- }
- else
- {
- y_gain_tmp2[i] = y_gain4[i];
- }
- }
-
- mean_4g[0] = mean( y_gain_tmp2, 16 );
- idx_g = vquant( mean_4g, mean_m, mean_4g, mean_gain_dic, 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] = y_gain_tmp2[i] - mean_4g[0];
- }
-
- if ( 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
- *--------------------------------------------------------------------------------------*/
-
- mvr2r( y_gain_tmp, y_gain_tmp2, 8 );
-
- y_gain_tmp2[8] = y_gain_tmp[8];
- y_gain_tmp2[9] = y_gain_tmp[10];
- y_gain_tmp2[10] = y_gain_tmp[12];
- y_gain_tmp2[11] = y_gain_tmp[14];
-
- idx_g = 0;
- idx_g = vquant( y_gain_tmp2, YGain_mean_LR, y_gain_tmp2, YGain_dic1_LR, 3, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- if ( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && idchan == 1 ) || core_brate_inp > GSC_LRES_GAINQ_LIMIT )
- {
- idx_g = vquant( y_gain_tmp2 + 3, YGain_mean_LR + 3, y_gain_tmp2 + 3, YGain_dic2_LR, 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( y_gain_tmp2 + 7, YGain_mean_LR + 7, y_gain_tmp2 + 7, YGain_dic3_LR, 5, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- set_f( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 );
-
- /* Update to quantized vector */
- mvr2r( y_gain_tmp2, y_gain_tmp, 8 );
-
- mvr2r( y_gain_tmp2 + 8, y_gain_tmp3, 4 );
- set_f( y_gain_tmp + 8, 0, 8 );
- fft_rel( y_gain_tmp2 + 8, 4, 2 );
-
- mvr2r( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 );
- y_gain_tmp[15] = y_gain_tmp2[11];
- ifft_rel( y_gain_tmp + 8, 8, 3 );
-
- for ( i = 8; i < 16; i++ )
- {
- y_gain_tmp[i] *= 1.41f;
- }
-
- y_gain_tmp[8] = y_gain_tmp3[0];
- y_gain_tmp[10] = y_gain_tmp3[1];
- y_gain_tmp[12] = y_gain_tmp3[2];
- y_gain_tmp[14] = y_gain_tmp3[3];
- }
- else
- {
- mvr2r( y_gain_tmp2, y_gain_tmp, 3 );
- set_f( y_gain_tmp + 3, 0.0f, MBANDS_GN16k - 3 );
- }
- }
- else
- {
- if ( L_frame == L_FRAME )
- {
- idx_g = vquant( y_gain_tmp, YG_mean16, y_gain_tmp, YG_dicMR_1, 4, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant( y_gain_tmp + 4, YG_mean16 + 4, y_gain_tmp + 4, YG_dicMR_2, 4, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- idx_g = vquant( y_gain_tmp + 8, YG_mean16 + 8, y_gain_tmp + 8, YG_dicMR_3, 4, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- idx_g = vquant( y_gain_tmp + 12, YG_mean16 + 12, y_gain_tmp + 12, YG_dicMR_4, 4, 16 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 );
- }
- else
- {
- idx_g = vquant( y_gain_tmp, YG_mean16HR, y_gain_tmp, YG_dicHR_1, 4, 128 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 );
-
- idx_g = vquant( y_gain_tmp + 4, YG_mean16HR + 4, y_gain_tmp + 4, YG_dicHR_2, 4, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant( y_gain_tmp + 8, YG_mean16HR + 8, y_gain_tmp + 8, YG_dicHR_3, 4, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant( y_gain_tmp + 12, YG_mean16HR_16kHz, y_gain_tmp + 12, YG_dicHR_4_16kHz, 4, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant( y_gain_tmp + 16, YG_meanL2G_16kHz, y_gain_tmp + 16, YG_dicL2G_16kHz, 2, 8 );
- push_indice( hBstr, IND_Y_GAIN_HF, idx_g, 3 );
- }
- }
- }
-
- GSC_gain_DQ( element_mode, ENC, coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp, y_gainQ );
-
- return mean_4g[0];
-}
-#endif
-
Word16 gsc_gainQ_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 element_mode, /* i : element mode */
@@ -886,203 +424,3 @@ Word16 gsc_gainQ_ivas_fx(
return mean_4g_fx[0];
}
-
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------*
- * gsc_gaindec()
- *
- * Generic signal frequency band decoding and application
- *-------------------------------------------------------------------*/
-
-/*! r: average frequency gain */
-float gsc_gaindec(
- Decoder_State *st, /* i/o: decoder state structure */
- float y_gainQ[], /* o : quantized gain per band */
- const int32_t core_brate, /* i : core used */
- float old_y_gain[], /* i/o: AR gain quantizer for low rate */
- const int16_t coder_type, /* i : coding type */
- const int16_t bwidth /* i : input signal bandwidth */
-)
-{
- int16_t idx_g, i;
- float mean_4g;
- int16_t Mbands_gn = MBANDS_GN;
- float y_gain_tmp3[MBANDS_GN];
-
- if ( st->L_frame == L_FRAME16k )
- {
- Mbands_gn = MBANDS_GN16k;
- }
-
- if ( ( coder_type == AUDIO || coder_type == INACTIVE ) && bwidth == NB )
- {
- idx_g = get_next_indice( st, 6 );
- VDQ_vec( &mean_4g, Gain_meanNB, Gain_mean_dicNB, idx_g, 1 );
-
- idx_g = get_next_indice( st, 6 );
- VDQ_vec( y_gainQ, Mean_dic_NB, Gain_dic1_NB, idx_g, 3 );
-
- if ( core_brate < ACELP_9k60 )
- {
- idx_g = get_next_indice( st, 5 );
- VDQ_vec( y_gainQ + 3, Mean_dic_NB + 3, Gain_dic2_NB, idx_g, 3 );
-
- idx_g = get_next_indice( st, 4 );
- VDQ_vec( y_gainQ + 6, Mean_dic_NB + 6, Gain_dic3_NB, idx_g, 4 );
- }
- else
- {
- idx_g = get_next_indice( st, 6 );
- VDQ_vec( y_gainQ + 3, Mean_dic_NB + 3, Gain_dic2_NBHR, idx_g, 3 );
-
- idx_g = get_next_indice( st, 7 );
- VDQ_vec( y_gainQ + 6, Mean_dic_NB + 6, Gain_dic3_NBHR, idx_g, 4 );
- }
-
- if ( 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_gainQ[10] = mean( y_gainQ + 6, 3 );
- y_gainQ[11] = mean( y_gainQ + 7, 3 );
- y_gainQ[12] = mean( y_gainQ + 8, 3 );
- y_gainQ[13] = mean( y_gainQ + 9, 3 );
- y_gainQ[14] = mean( y_gainQ + 10, 3 );
- y_gainQ[15] = mean( y_gainQ + 11, 3 );
- }
- else
- {
- set_f( y_gainQ + 10, 0, MBANDS_GN - 10 );
- }
- }
- else
- {
- idx_g = get_next_indice( st, 6 );
- VDQ_vec( &mean_4g, mean_m, mean_gain_dic, idx_g, 1 );
-
- if ( core_brate < ACELP_9k60 )
- {
- /*--------------------------------------------------------------------------------------*
- * UQ of the first 8 bands and half of the last 8 bands
- *--------------------------------------------------------------------------------------*/
-
- idx_g = get_next_indice( st, 5 );
- VDQ_vec( y_gainQ, YGain_mean_LR, YGain_dic1_LR, idx_g, 3 );
-
- if ( !( coder_type == INACTIVE && st->tdm_LRTD_flag == 0 && st->idchan == 1 ) || st->core_brate > GSC_LRES_GAINQ_LIMIT )
- {
- idx_g = get_next_indice( st, 5 );
- VDQ_vec( y_gainQ + 3, YGain_mean_LR + 3, YGain_dic2_LR, idx_g, 4 );
-
- /*----------------------------------------------------------------------*
- * Interpolation of the last 4 Q bands to create bands 8-16
- * And scaling
- *----------------------------------------------------------------------*/
-
- idx_g = get_next_indice( st, 5 );
- VDQ_vec( y_gainQ + 7, YGain_mean_LR + 7, YGain_dic3_LR, idx_g, 5 );
-
- mvr2r( y_gainQ + 8, y_gain_tmp3, 4 );
- set_f( y_gainQ + 12, 0.0f, 4 );
-
- fft_rel( y_gainQ + 8, 4, 2 );
-
- y_gainQ[15] = y_gainQ[11];
- y_gainQ[11] = 0.0f;
-
- ifft_rel( y_gainQ + 8, 8, 3 );
-
- for ( i = 8; i < 16; i++ )
- {
- y_gainQ[i] *= 1.41f;
- }
-
- /*----------------------------------------------------------------------*
- * Copy the true Q values in the specific bands
- *----------------------------------------------------------------------*/
-
- y_gainQ[8] = y_gain_tmp3[0];
- y_gainQ[10] = y_gain_tmp3[1];
- y_gainQ[12] = y_gain_tmp3[2];
- y_gainQ[14] = y_gain_tmp3[3];
- }
- else
- {
- set_f( y_gainQ + 3, 0.0f, MBANDS_GN16k - 3 );
- }
- }
- else
- {
- if ( st->L_frame == L_FRAME )
- {
- idx_g = get_next_indice( st, 6 );
- VDQ_vec( y_gainQ, YG_mean16, YG_dicMR_1, idx_g, 4 );
-
- idx_g = get_next_indice( st, 5 );
- VDQ_vec( y_gainQ + 4, YG_mean16 + 4, YG_dicMR_2, idx_g, 4 );
-
- idx_g = get_next_indice( st, 5 );
- VDQ_vec( y_gainQ + 8, YG_mean16 + 8, YG_dicMR_3, idx_g, 4 );
-
- idx_g = get_next_indice( st, 4 );
- VDQ_vec( y_gainQ + 12, YG_mean16 + 12, YG_dicMR_4, idx_g, 4 );
- }
- else
- {
- idx_g = get_next_indice( st, 7 );
- VDQ_vec( y_gainQ, YG_mean16HR, YG_dicHR_1, idx_g, 4 );
-
- idx_g = get_next_indice( st, 6 );
- VDQ_vec( y_gainQ + 4, YG_mean16HR + 4, YG_dicHR_2, idx_g, 4 );
-
- idx_g = get_next_indice( st, 6 );
- VDQ_vec( y_gainQ + 8, YG_mean16HR + 8, YG_dicHR_3, idx_g, 4 );
-
- idx_g = get_next_indice( st, 6 );
- VDQ_vec( y_gainQ + 12, YG_mean16HR_16kHz, YG_dicHR_4_16kHz, idx_g, 4 );
-
- idx_g = get_next_indice( st, 3 );
- VDQ_vec( y_gainQ + 16, YG_meanL2G_16kHz, YG_dicL2G_16kHz, idx_g, 2 );
- }
- }
- }
-
- mvr2r( y_gainQ, old_y_gain, Mbands_gn );
-
- GSC_gain_DQ( st->element_mode, DEC, coder_type, Mbands_gn, core_brate, mean_4g, y_gainQ, y_gainQ );
-
- return mean_4g;
-}
-#endif
-
-
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------*
- * VDQ_vec()
- *
- * Return the dequantized vector of index
- *-------------------------------------------------------------------*/
-
-static int16_t VDQ_vec(
- float *Qvec_out, /* o : Quanitzed vector */
- const float *mean_dic, /* i : average codebook */
- const float *dic, /* i : codebook */
- const int16_t index, /* i : index of codebook*/
- const int16_t vec_en /* i : vector length */
-)
-{
- int16_t i, j;
-
- j = index * vec_en;
- for ( i = 0; i < vec_en; i++ )
- {
- Qvec_out[i] = dic[j++];
- }
-
- for ( i = 0; i < vec_en; i++ )
- {
- Qvec_out[i] += mean_dic[i];
- }
-
- return index;
-}
-#endif
diff --git a/lib_com/gs_noisefill.c b/lib_com/gs_noisefill.c
deleted file mode 100644
index c2074100a8ae534b782cb02a1ec06259e5f35361..0000000000000000000000000000000000000000
--- a/lib_com/gs_noisefill.c
+++ /dev/null
@@ -1,841 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------*
- * gs_noisf()
- *
- * Noise fill-in function
- *-------------------------------------------------------------------*/
-
-static void gs_noisf(
- const int16_t Start_BIN, /* i : First bin for noise fill */
- const int16_t NB_Qbins, /* i : Number of bin per band */
- const float Noise_fac, /* i : Noise level */
- const float *y_norm, /* i : Quantized pulses */
- float *exc_diffQ, /* o : Quantized pulses with noise added */
- int16_t *seed_tcx, /* i : Random generator seed */
- const int16_t coder_type /* i : coder type */
-)
-{
- float ftmp;
- int16_t i, k;
- int16_t NB_zer = NB_Qbins / 2;
-
- if ( coder_type == INACTIVE )
- {
- NB_zer = 2;
- }
-
- /*----------------------------------------------*
- * noise fill-in on unquantized subvector *
- * injected only from 1066Hz to 6400Hz. *
- *----------------------------------------------*/
-
- for ( k = Start_BIN; k < NB_Qbins + Start_BIN; k += NB_zer )
- {
- ftmp = 0.0;
- for ( i = k; i < k + NB_zer; i++ )
- {
- exc_diffQ[i] = (float) y_norm[i];
- ftmp += exc_diffQ[i] * exc_diffQ[i];
- }
-
- if ( ftmp < .5 )
- {
- for ( i = k; i < k + NB_zer; i++ )
- {
- exc_diffQ[i] += Noise_fac * ( (float) own_random( seed_tcx ) / PCM16_TO_FLT_FAC );
- }
- }
- else
- {
- /* This is added only to keep the seed in sync between different compilers */
- for ( i = k; i < k + NB_zer; i++ )
- {
- own_random( seed_tcx );
- }
- }
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * EstimateNoiseLevel_inner()
- *
- * Estimate noise level from the power spectrum
- *-------------------------------------------------------------------*/
-
-static void EstimateNoiseLevel_inner(
- float *noisepb, /* o : Noise per band */
- const int32_t bitrate, /* i : Bitrate of the codec */
- const int16_t i_band, /* i : First band to compute the noise */
- const int16_t Mbands_gn /* i : number of bands */
-)
-{
- int16_t i;
- float noise_offset;
-
- noise_offset = 0.25f;
- if ( bitrate > ACELP_24k40 )
- {
- noise_offset = .2f;
- }
- else if ( bitrate >= ACELP_22k60 )
- {
- noise_offset = .3f;
- }
- else if ( bitrate >= ACELP_9k60 )
- {
- noise_offset = 0.35f;
- }
- else
- {
- noise_offset = .4f;
- }
-
- set_f( noisepb + i_band, noise_offset, Mbands_gn - i_band );
-
- for ( i = i_band; i < 5; i++ )
- {
- if ( noisepb[i] > 0.2f )
- {
- noisepb[i] = 0.2f;
- }
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * EstimateNoiseLevel()
- *
- *
- *-------------------------------------------------------------------*/
-
-static void EstimateNoiseLevel(
- float *noisepb, /* o : Noise per band */
- const int32_t bitrate, /* i : Bitrate of the codec */
- const int16_t Diff_len, /* i : number of bin before cut-off frequency */
- const int16_t Mbands_gn, /* i : number of bands */
- const int16_t coder_type, /* i : coder type */
- const int16_t noise_lev, /* i : pulses dynamic */
- const int16_t pit_band_idx, /* i : bin position of the cut-off frequency */
- const int16_t last_bin, /* i : the last bin of bit allocation */
- const int16_t bwidth,
- const int16_t L_frame /* i : frame length */
-)
-{
- int16_t i_band;
-
- i_band = 0;
-
- if ( Diff_len < L_frame )
- {
- EstimateNoiseLevel_inner( noisepb, bitrate, i_band, Mbands_gn );
-
- if ( coder_type != INACTIVE )
- {
- if ( ( bitrate == ACELP_8k00 && last_bin > 8 ) && bwidth != NB )
- {
- while ( Mbands_gn > i_band )
- {
- noisepb[i_band] *= 2.0f;
- i_band++;
- }
- }
- else
- {
- while ( pit_band_idx > i_band )
- {
- noisepb[i_band] /= 2.0f;
- i_band++;
- }
- }
- }
- }
-
- if ( ( coder_type == INACTIVE || noise_lev >= NOISE_LEVEL_SP3 ) && L_frame == L_FRAME )
- {
- for ( i_band = 9; i_band < Mbands_gn; i_band++ )
- {
- noisepb[i_band] *= 1.15f;
- }
- }
- else if ( L_frame == L_FRAME16k )
- {
- if ( bitrate == ACELP_13k20 )
- {
- set_f( noisepb, .45f, Mbands_gn );
- }
-
- if ( coder_type == INACTIVE )
- {
- for ( ; i_band < Mbands_gn; i_band++ )
- {
- noisepb[i_band] = .4f;
- }
- }
- else if ( ( noise_lev <= NOISE_LEVEL_SP1 ) && bitrate > ACELP_16k40 )
- {
- for ( ; i_band < Mbands_gn - 4; i_band++ )
- {
- noisepb[i_band] *= .6f;
- }
- }
- else if ( ( noise_lev <= NOISE_LEVEL_SP2 ) && bitrate > ACELP_16k40 )
- {
- for ( ; i_band < Mbands_gn - 4; i_band++ )
- {
- noisepb[i_band] *= .8f;
- }
- }
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * Apply_NoiseFill()
- *
- *
- *-------------------------------------------------------------------*/
-
-static void Apply_NoiseFill(
- float *exc_diffQ, /* i/o: Noise per band */
- int16_t *seed_tcx, /* i : Seed for noise */
- const float *noisepb, /* i : Noise per band */
- const int16_t Diff_len, /* i : number of bin before cut-off frequency */
- const int16_t Mbands_gn, /* i : number of bands */
- const int16_t coder_type, /* i : coder type */
- const int16_t *freq_nsbin_per_band /* i : bin per bands tables */
-)
-{
- int16_t StartBin, NB_Qbins, i_band;
- StartBin = 0;
- NB_Qbins = 0;
-
- for ( i_band = 0; i_band < Mbands_gn; i_band++ )
- {
- StartBin += NB_Qbins;
- NB_Qbins = freq_nsbin_per_band[i_band];
-
- if ( Diff_len < L_FRAME )
- {
- gs_noisf( StartBin, NB_Qbins, noisepb[i_band], exc_diffQ, exc_diffQ, seed_tcx, coder_type );
- }
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * freq_dnw_scaling()
- *
- *
- *-------------------------------------------------------------------*/
-
-void freq_dnw_scaling(
- const int16_t cor_strong_limit, /* i : HF correlation */
- const int16_t coder_type, /* i : coder type */
- const int16_t noise_lev, /* i : Noise level */
- const int32_t core_brate, /* i : Core bitrate */
- float fy_norm[], /* i/o: Frequency quantized parameter */
- const int16_t L_frame /* i : frame length */
-)
-{
- float sc_dyn;
- int16_t start_sc, i;
-
- sc_dyn = 1.0f;
- start_sc = L_frame;
-
- if ( core_brate <= ACELP_8k00 && coder_type == INACTIVE )
- {
- sc_dyn *= .15f;
- start_sc = 64;
- }
- else if ( coder_type == INACTIVE )
- {
- sc_dyn *= .25f;
- start_sc = 80;
- }
- else
- {
- sc_dyn = (float) ( NOISE_LEVEL_SP3 - noise_lev ) / 10.0f + 0.4f;
- start_sc = 112 + ( NOISE_LEVEL_SP3 - noise_lev ) * 16;
-
- if ( noise_lev == NOISE_LEVEL_SP0 )
- {
- start_sc = L_FRAME;
- }
- }
-
- if ( L_frame == L_FRAME16k && core_brate <= ACELP_24k40 )
- {
- sc_dyn += 0.125f;
- if ( sc_dyn > 1.0f )
- {
- sc_dyn = 1.0f;
- }
- }
-
- for ( i = start_sc; i < L_frame; i++ )
- {
- fy_norm[i] *= sc_dyn;
- }
-
- if ( ( core_brate < ACELP_13k20 && cor_strong_limit == 0 ) || core_brate < ACELP_9k60 )
- {
- for ( i = 160; i < L_frame; i++ )
- {
- if ( fy_norm[i] > 1.0f )
- {
- fy_norm[i] = 1.0f;
- }
-
- if ( fy_norm[i] < -1.0f )
- {
- fy_norm[i] = -1.0f;
- }
- }
- }
- else if ( core_brate < ACELP_22k60 )
- {
- for ( i = 160; i < L_frame; i++ )
- {
- if ( fy_norm[i] > 1.5f )
- {
- fy_norm[i] = 1.5f;
- }
-
- if ( fy_norm[i] < -1.5f )
- {
- fy_norm[i] = -1.5f;
- }
- }
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * Decreas_freqPeak()
- *
- *
- *-------------------------------------------------------------------*/
-
-static void Decreas_freqPeak(
- const float *lsf_new, /* i : ISFs at the end of the frame */
- float *exc_diffQ, /* i/o: frequency coefficients of per band */
- float thr_rat /* i : threshold of ratio between consecutive lsf_new_diff */
-)
-{
- int16_t i, j, k;
- int16_t last_bin = 0;
- int16_t pos = 0;
- float *src;
- float avrg, max_val;
- float lsf_new_diff[M];
- lsf_new_diff[0] = 0; /* prevent unitialized value */
- for ( j = 1; j < ( M - 1 ); j++ )
- {
- lsf_new_diff[j] = lsf_new[j] - lsf_new[j - 1];
- }
-
- avrg = 0.0f;
- /* This is to prevent a possible div by 0 in the '*(src) = (*src > 0) ?...'
- loop. The value of 'max' is not important because it will be mutiplied
- by 'avrg' and the result will be close to 0. The 'fabs(*src)/max'
- div by 0 error will be avoided. */
- max_val = 0.001f;
- for ( i = 160; i < L_FRAME; i++ )
- {
- if ( fabs( exc_diffQ[i] ) > max_val )
- {
- max_val = (float) fabs( exc_diffQ[i] );
- pos = i;
- }
- avrg += (float) fabs( exc_diffQ[i] );
- }
- avrg /= 96;
- last_bin = M - 1; /* When the search is false, should equate the end of the vector, not the beginning */
- for ( i = 0; i < ( M - 1 ); i++ )
- {
- if ( lsf_new[i] > 4000 )
- {
- last_bin = i;
- break;
- }
- }
-
- for ( i = last_bin; i < 14; i++ )
- {
- if ( lsf_new_diff[i] < thr_rat * lsf_new_diff[i - 1] )
- {
- src = &exc_diffQ[( i - 1 ) * 16];
- for ( j = 0; j < 2; j++ )
- {
- for ( k = 0; k < 16; k++ )
- {
- if ( fabs( *src ) > 2.0f * avrg )
- {
- *( src ) = ( *src > 0 ) ? (float) ( avrg * ( 2.0f - fabs( *src ) / max_val ) ) : (float) ( -avrg * ( 2.0f - fabs( *src ) / max_val ) );
- }
- src++;
- }
- }
- }
- }
-
- if ( fabs( exc_diffQ[pos] ) == max_val && max_val > 4.0f * avrg )
- {
- for ( i = pos - 1; i < pos + 2; i++ )
- {
- exc_diffQ[pos] *= 0.5f;
- }
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * envelop_modify()
- *
- *
- *-------------------------------------------------------------------*/
-
-static void envelop_modify(
- float *exc_diffQ, /* i/o: frequency coefficients of per band */
- int16_t *seed_tcx, /* i : Seed for noise */
- int16_t last_bin, /* i : last bin of bit allocation */
- float *Ener_per_bd_iQ /* i : Quantized energy of targeted vector */
-)
-{
- int16_t i, j, end_band;
- float Ener, Ener1, *src;
- float weight = 1.0f;
-
- end_band = L_FRAME;
- Ener = 0.1f;
- for ( i = last_bin * 16; i < end_band; i++ )
- {
- Ener += exc_diffQ[i] * exc_diffQ[i];
- }
- Ener = (float) sqrt( ( end_band - last_bin * 16 ) / Ener );
-
- weight = 0.5f;
-
- src = &exc_diffQ[16 * last_bin];
- for ( i = last_bin; i < last_bin + 4; i++ )
- {
- Ener1 = (float) ( 0.4f * pow( 10, Ener_per_bd_iQ[i + 1] ) );
- for ( j = 0; j < 16; j++ )
- {
- *src = Ener1 * ( weight * ( *src ) * Ener + ( 1.0f - weight ) * own_random( seed_tcx ) / PCM16_TO_FLT_FAC );
- src++;
- }
- }
-
- Ener1 = (float) ( 0.4f * pow( 10, Ener_per_bd_iQ[15] ) );
-
- src = &exc_diffQ[224];
- for ( j = 0; j < 32; j++ )
- {
- *src = Ener1 * ( weight * ( *src ) * Ener + ( 1.0f - weight ) * own_random( seed_tcx ) / PCM16_TO_FLT_FAC );
- src++;
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * highband_exc_dct_in()
- *
- *
- *-------------------------------------------------------------------*/
-
-void highband_exc_dct_in(
- const int32_t core_brate, /* i : core bitrate */
- const int16_t *mfreq_bindiv, /* i : bin per bands tables */
- int16_t last_bin, /* i : last bin of bit allocation */
- int16_t Diff_len, /* i : number of bin before cut-off frequency */
- int16_t noise_lev, /* i : pulses dynamic */
- int16_t pit_band_idx, /* i : bin position of the cut-off frequency */
- float *exc_diffQ, /* i : frequency coefficients of per band */
- int16_t *seed_tcx, /* i : Seed for noise */
- float *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */
- int16_t nb_subfr, /* i : Number of subframe considered */
- float *exc_dct_in, /* o : dct of residual signal */
- int16_t last_coder_type, /* i : coding type of last frame */
- int16_t *bitallocation_band, /* i : bit allocation flag of each band */
- const float *lsf_new, /* i : LSFs at the end of the frame */
- float *last_exc_dct_in, /* i : dct of residual signal of last frame */
- float *last_ener, /* i : frequency energy of last frame */
- int16_t *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */
- int16_t *bitallocation_exc, /* i : flag of decoded coefficients */
- const int16_t bfi, /* i : bad frame indicator */
- const int16_t coder_type, /* i : coder type */
- const int16_t bwidth, /* i : audio bandwidth */
- float *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */
- const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
- float *lt_ener_per_band, /* i/o: Average per band energy */
- const int16_t L_frame, /* i : frame length */
- const int16_t element_mode, /* i : IVAS element mode */
- const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
-)
-{
- int16_t i, j;
- int16_t MAX_Bin = 0;
- int16_t last_bin_tmp;
- float noisepb[MBANDS_GN16k];
- float Ener_per_bd_yQ[MBANDS_GN16k];
- float *src, *dst, *end;
- float ener = 0.0f;
- int16_t length_bin, bwe_flag = 0;
-
- for ( j = 10; j < MBANDS_GN; j++ )
- {
- ener += (float) pow( 10, Ener_per_bd_iQ[j] );
- }
-
- if ( core_brate == ACELP_8k00 && bwidth != NB )
- {
- if ( last_coder_type != AUDIO )
- {
- *last_ener = ener;
- }
-
- if ( ( last_bin > 8 || Diff_len != 0 ) && last_coder_type == AUDIO )
- {
- MAX_Bin = 10;
- bwe_flag = 1;
- }
- else
- {
- MAX_Bin = 15;
- }
-
- last_bin_tmp = last_bin;
- if ( last_bin < MAX_Bin )
- {
- last_bin = MAX_Bin;
- }
- last_bin += 1;
- }
- else
- {
- if ( L_frame == L_FRAME16k )
- {
- last_bin = MBANDS_GN16k;
- }
- else
- {
- last_bin = MBANDS_GN;
- }
- last_bin_tmp = last_bin;
- }
-
-
- if ( bfi || core_brate < 6000 || ( core_brate < 8600 && coder_type == UNVOICED ) )
- {
- set_f( noisepb, 0.4f, MBANDS_GN );
- }
- else if ( GSC_IVAS_mode == 3 || ( GSC_IVAS_mode > 0 && GSC_noisy_speech == 1 ) )
- {
- set_f( noisepb, 0.4f, MBANDS_GN16k );
- }
- else
- {
- EstimateNoiseLevel( noisepb, core_brate, Diff_len, last_bin, coder_type, noise_lev, pit_band_idx, last_bin_tmp, bwidth, L_frame );
- }
-
- if ( exc_wo_nf != NULL )
- {
- mvr2r( exc_diffQ, exc_wo_nf, L_frame );
- }
-
- if ( GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && element_mode <= IVAS_SCE )
- {
- set_f( noisepb, 0.1f, MBANDS_GN );
- }
-
- if ( core_brate < 6000 && coder_type <= UNVOICED )
- {
- for ( i = 0; i < L_frame; i++ )
- {
- if ( exc_diffQ[i] == 0.0f )
- {
- exc_diffQ[i] += 2.0f * noisepb[0] * ( (float) own_random( seed_tcx ) / PCM16_TO_FLT_FAC );
- }
- }
- }
- else
- {
- Apply_NoiseFill( exc_diffQ, seed_tcx, noisepb, Diff_len, last_bin, coder_type, mfreq_bindiv );
- }
-
- /*--------------------------------------------------------------------------------------*
- * Quantize average gain
- * Subtract Q averaged gain
- * VQ of remaining gain per band
- *--------------------------------------------------------------------------------------*/
-
- if ( core_brate == ACELP_8k00 && bwidth != NB )
- {
- Ener_per_band_comp( exc_diffQ, Ener_per_bd_yQ, last_bin + 1, 0, L_frame );
- }
- else
- {
- Ener_per_band_comp( exc_diffQ, Ener_per_bd_yQ, MBANDS_GN, 1, L_frame );
-
- if ( nb_subfr < 4 && L_frame < L_FRAME16k )
- {
- for ( i = L_FRAME - 16; i < L_FRAME; i++ )
- {
- exc_diffQ[i] *= ( 0.067f * i - 15.0f );
- }
- }
- }
-
- /*--------------------------------------------------------------------------------------*
- * Check potential energy excitation overshoot
- *--------------------------------------------------------------------------------------*/
-
- if ( bfi )
- {
- if ( GSC_noisy_speech == 0 && coder_type > UNVOICED ) /* Here coder_type == last_coder_type because of the bfi */
- {
- for ( i = 0; i < last_bin; i++ )
- {
- Ener_per_bd_iQ[i] = min( Ener_per_bd_iQ[i], ( lt_ener_per_band[i] - 0.0376f ) - Ener_per_bd_yQ[i] );
- lt_ener_per_band[i] -= 0.0188f;
- }
- for ( ; i < MBANDS_GN; i++ )
- {
- Ener_per_bd_iQ[i] = min( Ener_per_bd_iQ[i], ( lt_ener_per_band[i] - 0.0376f ) );
- lt_ener_per_band[i] -= 0.0188f;
- }
- }
- else
- {
- for ( i = 0; i < last_bin; i++ )
- {
- Ener_per_bd_iQ[i] = min( Ener_per_bd_iQ[i], ( lt_ener_per_band[i] + 0.3f ) - Ener_per_bd_yQ[i] );
- lt_ener_per_band[i] -= 0.0188f;
- }
- for ( ; i < MBANDS_GN; i++ )
- {
- Ener_per_bd_iQ[i] = min( Ener_per_bd_iQ[i], ( lt_ener_per_band[i] + 0.3f ) );
- lt_ener_per_band[i] -= 0.0188f;
- }
- }
- }
-
- /*--------------------------------------------------------------------------------------*
- * Apply decoded gain onto the difference signal
- *--------------------------------------------------------------------------------------*/
-
- if ( GSC_IVAS_mode >= 1 )
- {
- float scale_factLF = 0.9f;
- float scale_factHF = 0.9f;
-
- if ( GSC_IVAS_mode == 1 && GSC_noisy_speech == 0 )
- {
- scale_factHF = 0.8f;
- }
- else if ( GSC_IVAS_mode == 2 || GSC_noisy_speech == 1 )
- {
- scale_factHF = 0.71f;
- }
- else if ( GSC_IVAS_mode == 3 )
- {
- scale_factHF = 0.9f;
- }
- for ( i = 0; i < pit_band_idx * 16; i++ )
- {
- exc_diffQ[i] *= scale_factLF;
- }
- for ( ; i < L_frame; i++ )
- {
- exc_diffQ[i] *= scale_factHF;
- }
- }
- else if ( GSC_noisy_speech )
- {
- float scale_fact = 0.9f;
-
- if ( element_mode == IVAS_CPE_TD )
- {
- if ( coder_type == INACTIVE )
- {
- scale_fact = 1.0f;
- }
- else
- {
- scale_fact = 0.95f;
- }
- }
- else if ( element_mode > IVAS_SCE )
- {
- scale_fact = 0.71f;
- }
-
- for ( i = 0; i < L_frame; i++ )
- {
- exc_diffQ[i] *= scale_fact;
- }
- }
-
- if ( GSC_noisy_speech && element_mode > IVAS_SCE && core_brate < ACELP_7k20 )
- {
- for ( i = 80; i < L_frame; i++ )
- {
- exc_diffQ[i] *= ( +0.0024f * (float) i + 1.192f );
- }
- }
-
- Comp_and_apply_gain( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0 );
-
- if ( exc_wo_nf != NULL )
- {
- Comp_and_apply_gain( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1 );
-
- v_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
- }
-
- /*--------------------------------------------------------------------------------------*
- * add the correction layer to the LF bins,
- * and add the quantized pulses or the noise for the higher part of the spectrum
- * (non valuable temporal content already zeroed)
- * DC is Zeroed
- *--------------------------------------------------------------------------------------*/
-
- v_add( exc_dct_in, exc_diffQ, exc_dct_in, L_frame );
-
- if ( core_brate == ACELP_8k00 && bwidth != NB )
- {
- if ( bwe_flag == 1 )
- {
- last_bin -= 1;
- src = &exc_diffQ[L_FRAME - 1];
- dst = &exc_dct_in[MAX_Bin * 16 - 1];
- end = &exc_diffQ[last_bin * 16 - 1];
-
- while ( src > end )
- {
- *src-- = *dst--;
- }
-
- if ( ( bitallocation_exc[0] != 0 || bitallocation_exc[1] != 0 ) && core_brate == ACELP_8k00 )
- {
- exc_diffQ[160] = 0.0f;
- }
-
- envelop_modify( exc_diffQ, seed_tcx, last_bin, Ener_per_bd_iQ );
-
- mvr2r( &exc_diffQ[last_bin * 16], &exc_dct_in[last_bin * 16], L_FRAME - last_bin * 16 );
- }
-
- if ( nb_subfr < 4 )
- {
- for ( i = L_FRAME - 16; i < L_FRAME; i++ )
- {
- exc_dct_in[i] *= ( 0.067f * i - 15.f );
- }
- }
-
- if ( ener < 2 * ( *last_ener ) && ener > 0.5f * ( *last_ener ) )
- {
- length_bin = 6;
- if ( last_coder_type != AUDIO )
- {
- set_s( last_bitallocation_band, 0, 6 );
- mvr2r( &exc_dct_in[( 4 + length_bin ) * 16], &last_exc_dct_in[( 4 + length_bin ) * 16], length_bin * 16 );
- }
-
- for ( i = 4; i < ( 4 + length_bin ); i++ )
- {
- if ( !( bitallocation_band[i] == 0 && last_bitallocation_band[i - 4] == 0 ) )
- {
- src = &exc_dct_in[( i + length_bin ) * 16];
- dst = &last_exc_dct_in[( i + length_bin ) * 16];
- for ( j = 0; j < 16; j++ )
- {
- if ( fabs( *src ) > 3.0f * fabs( *dst ) )
- {
- *src = ( *src > 0 ) ? (float) ( 0.5f * ( *src + fabs( *dst ) ) ) : (float) ( 0.5f * ( *src - fabs( *dst ) ) );
- }
- else if ( fabs( *dst ) > 3.0f * fabs( *src ) )
- {
- *src = ( *src > 0 ) ? (float) ( 0.7f * ( *src ) + 0.3f * fabs( *dst ) ) : (float) ( 0.7f * ( *src ) - 0.3f * fabs( *dst ) );
- }
- src++;
- dst++;
- }
- }
- }
- }
-
- if ( bwe_flag == 1 )
- {
- Decreas_freqPeak( lsf_new, exc_dct_in, 0.3f );
- }
- else
- {
- Decreas_freqPeak( lsf_new, exc_dct_in, 0.5f );
- }
- }
-
- mvr2r( &exc_dct_in[64], &last_exc_dct_in[64], L_frame - 64 );
- mvs2s( &bitallocation_band[4], last_bitallocation_band, 6 );
- *last_ener = ener;
-
- return;
-}
-#endif
diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c
index 9e3c73a1da2e84dd7c680344dd1801376993160c..548cba204f55601d6cfc57deb9ea5944478db8bf 100644
--- a/lib_com/gs_preech_fx.c
+++ b/lib_com/gs_preech_fx.c
@@ -48,106 +48,10 @@
*-------------------------------------------------------------------*/
#define ATT_LENGHT16k 80
-#ifndef IVAS_FLOAT_FIXED
-#define INV_L_FRAME16k ( 1.0f / L_FRAME16k )
-#endif
#define ATT_LENGHT 64
#define ATT_SEG_LEN ( L_FRAME / ATT_LENGHT )
-#ifndef IVAS_FLOAT_FIXED
-#define INV_ATT_SEG_LEN ( 1.0f / ATT_SEG_LEN )
-#define INV_L_FRAME ( 1.0f / L_FRAME )
-#endif
-
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------*
- * pre_echo_att()
- *
- * Attenuation of the pre-echo when encoder specifies an attack
- *-------------------------------------------------------------------*/
-
-void pre_echo_att(
- float *Last_frame_ener, /* i/o: Energy of the last frame */
- float *exc, /* i/o: Excitation of the current frame */
- const int16_t attack_flag, /* i : attack flag (GSC or TC) */
- const int16_t last_coder_type, /* i : Last coder type */
- const int16_t L_frame /* i : frame length */
-)
-{
- float etmp;
- float etmp1;
- float finc[ATT_LENGHT16k], ratio_float, inv_l_frame;
- int16_t att_len;
- int16_t attack_pos, i;
-
- if ( attack_flag > 0 && last_coder_type == AUDIO )
- {
- /*-------------------------------------------------------------------------*
- * Find where the onset (attack) occurs by computing the energy per section
- * The inverse weighting aims to favor the first maxima in case of
- * gradual onset
- *-------------------------------------------------------------------------*/
-
- att_len = ATT_LENGHT;
- if ( L_frame == L_FRAME16k )
- {
- att_len = ATT_LENGHT16k;
- }
- for ( i = 0; i < att_len; i++ )
- {
- finc[i] = sum2_f( exc + i * ATT_SEG_LEN, ATT_SEG_LEN ) * ( (float) ( att_len - i ) / ( att_len ) );
- }
- etmp = -1;
- attack_pos = maximum( finc, att_len, &etmp );
-
- /* Scaled the maximum energy and allowed 6 dB increase*/
- etmp *= INV_ATT_SEG_LEN;
- etmp1 = etmp;
- *Last_frame_ener *= 4.0f;
-
- /* If the maximum normalized energy > last frame energy + 6dB */
- if ( etmp > *Last_frame_ener && attack_pos > 0 )
- {
- /* Find the average energy before the attack */
- etmp = sum_f( finc, attack_pos ) + 0.01f;
- etmp /= ( attack_pos * ATT_SEG_LEN );
-
- /* Find the correction factor and apply it before the attack */
- ratio_float = (float) sqrt( *Last_frame_ener / etmp );
-
-
- /* Pre-echo atttenuation should never increase the energy */
- ratio_float = min( ratio_float, 1.0f );
- for ( i = 0; i < attack_pos * ATT_SEG_LEN; i++ )
- {
- exc[i] *= ratio_float;
- }
- }
- *Last_frame_ener = etmp1;
- }
- else
- {
- /*-------------------------------------------------------*
- * In normal cases, just compute the energy of the frame
- *-------------------------------------------------------*/
-
- etmp = sum2_f( exc, L_frame ) + 0.01f;
- inv_l_frame = INV_L_FRAME;
- if ( L_frame == L_FRAME16k )
- {
- inv_l_frame = INV_L_FRAME16k;
- }
- etmp *= inv_l_frame;
- *Last_frame_ener = etmp;
- }
-
- return;
-}
-#endif
-
-#ifdef IVAS_FLOAT_FIXED
-#ifdef IVAS_FLOAT_FIXED
void pre_echo_att_fx(
Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/
Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/
@@ -271,7 +175,6 @@ void pre_echo_att_fx(
return;
}
-#endif
void pre_echo_att_ivas_fx(
@@ -398,4 +301,3 @@ void pre_echo_att_ivas_fx(
return;
}
-#endif
diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c
index 92dad39ffdc11f79e851eb676935bd8042837e72..78e358a80881101ca146b9e16c50d2452ec748bf 100644
--- a/lib_com/hp50_fx.c
+++ b/lib_com/hp50_fx.c
@@ -51,90 +51,8 @@
* void
*/
-#ifndef IVAS_FLOAT_FIXED
-void hp20_flt(
- Float32 signal[],
- const Word16 lg,
- Float32 mem[],
- const Word32 Fs )
-{
- Word16 i;
- Float32 x0, x1, x2, y0, y1, y2;
- Float32 a1, a2, b1, b2;
-
- y1 = mem[0];
- y2 = mem[1];
- x0 = mem[2];
- x1 = mem[3];
-
- if ( Fs == 8000 )
- {
- /* hp filter 20Hz at 3dB for 8000KHz input sampling rate
- [b,a] = butter(2, 20.0/4000.0, 'high');
- b = [0.988954248067140 -1.977908496134280 0.988954248067140]
- a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/
- a1 = 1.977786483776764f;
- a2 = -0.978030508491796f;
- b1 = -1.977908496134280f;
- b2 = 0.988954248067140f;
- }
- else if ( Fs == 16000 )
- {
- /* hp filter 20Hz at 3dB for 16000KHz sampling rate
- [b,a] = butter(2, 20.0/8000.0, 'high');
- b =[ 0.994461788958195 -1.988923577916390 0.994461788958195]
- a =[1.000000000000000 -1.988892905899653 0.988954249933127] */
- a1 = 1.988892905899653f;
- a2 = -0.988954249933127f;
- b1 = -1.988923577916390f;
- b2 = 0.994461788958195f;
- }
- else if ( Fs == 32000 )
- {
- /* hp filter 20Hz at 3dB for 32000KHz sampling rate
- [b,a] = butter(2, 20.0/16000.0, 'high');
- b =[0.997227049904470 -1.994454099808940 0.997227049904470]
- a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/
- a1 = 1.994446410541927f;
- a2 = -0.994461789075954f;
- b1 = -1.994454099808940f;
- b2 = 0.997227049904470f;
- }
- else
- {
- /* hp filter 20Hz at 3dB for 48000KHz sampling rate
- [b,a] = butter(2, 20.0/24000.0, 'high');
- b =[ 0.998150511190452 -1.996301022380904 0.998150511190452]
- a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/
- a1 = 1.996297601769122f;
- a2 = -0.996304442992686f;
- b1 = -1.996301022380904f;
- b2 = 0.998150511190452f;
- }
-
- for ( i = 0; i < lg; i++ )
- {
- x2 = x1;
- x1 = x0;
- x0 = signal[i];
- y0 = ( y1 * a1 ) + ( y2 * a2 ) + ( x0 * b2 ) + ( x1 * b1 ) + ( x2 * b2 );
- signal[i] = y0;
- y2 = y1;
- y1 = y0;
- }
-
- mem[0] = ( ( y1 > 1e-10 ) | ( y1 < -1e-10 ) ) ? y1 : 0;
- mem[1] = ( ( y2 > 1e-10 ) | ( y2 < -1e-10 ) ) ? y2 : 0;
- mem[2] = ( ( x0 > 1e-10 ) | ( x0 < -1e-10 ) ) ? x0 : 0;
- mem[3] = ( ( x1 > 1e-10 ) | ( x1 < -1e-10 ) ) ? x1 : 0;
-
- return;
-}
-#endif
-
#define HP20_COEFF_SCALE ( 2 )
-#ifdef IVAS_FLOAT_FIXED
/*
* hp20
*
@@ -797,4 +715,3 @@ void hp20_fx_32(
return;
}
#endif
-#endif
diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c
index 12bedd1fb66e9f1c04ac692d049ccc1f46e58839..c37ae1236e3e30a092fe30396e3aaca1207e1986 100644
--- a/lib_com/hq2_noise_inject_fx.c
+++ b/lib_com/hq2_noise_inject_fx.c
@@ -35,7 +35,6 @@
#include "prot_fx.h"
#include "oper_32b.h"
#include "move.h"
-#include "count.h"
/*--------------------------------------------------------------------------*
* hq2_noise_inject()
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
index eb529b37c50d98bec9f5aca76c181ae7871bccae..b440299451557260c33eb4bbae825587dab3d6d0 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -36,6 +36,7 @@
#include
#include "options.h"
#include "cnst.h"
+#include "typedef.h"
/* clang-format off */
@@ -52,7 +53,7 @@
#define PI_OVER_180_Q25 ( 585635 ) // Q25
#define _180_IN_Q22 ( 754974720 ) // Q22
#define _360_IN_Q22 ( 1509949440 ) // Q22
-#define _180_OVER_PI_FX ( (Word32) ( ( 180.0f / EVS_PI ) * ONE_IN_Q10 ) )
+#define _180_OVER_PI_FX ( 58670 ) // Q10
#define PI_OVER_180_Q15 ( 572 ) // Q15
#define _180_OVER_PI_Q9 ( 29335 ) // Q9
#define PI_OVER_4_Q29 ( 421657440 ) // Q29
@@ -60,7 +61,7 @@
#define PI_OVER_Q29 ( 1686629760 ) // Q29
#define Q31_0_99 ( 2126008811 ) // Q31
#define Q31_0_01 ( 21474836 ) // Q31
-#define PI_OVER_180_FX ( (Word32) ( ( EVS_PI / 180.0f ) * ONE_IN_Q31 ) ) // Q31
+#define PI_OVER_180_FX ( 37480660 ) // Q31
#define PI_OVER_4_Q29 ( 421657440 ) // Q29
#define PI_OVER_Q29 ( 1686629760 ) // Q29
#define PI2_C_ADP_RATE_Q31 ( 449767936 ) // Q31 (2.0f * EVS_PI * pOTR->centerAdaptationRate)
@@ -1389,7 +1390,8 @@ typedef enum
#define MCMASA_LFE_THETA_Q14 (21299) // Q14
#define MCMASA_LFE_QLOW_Q12 (-26624) // Q12
#define MCMASA_LFE_DELTA_Q11 (2048) // Q11
-
+#define MCMASA_LFE_QLOW_Q11 (-13312) // Q11
+#define MCMASA_LFE_DELTA_Q10 (1024) // Q10
#define NUM_ELEVATED_SPEAKERS 4
#define MCMASA_MIN_SPEAKERS_SEPARATE_CENTER 4
diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c
index 6a6fbe47c48fa623a508c3545f850fb16e219f3e..6aeff8ec548fe8a13aba886d138eebbfb0f3db7d 100644
--- a/lib_com/ivas_dirac_com.c
+++ b/lib_com/ivas_dirac_com.c
@@ -610,7 +610,12 @@ void computeDirectionVectors_fixed(
Word32 *direction_vector_x, /* o: Q30*/
Word32 *direction_vector_y, /* o: Q30*/
Word32 *direction_vector_z, /* o: Q30*/
- Word16 i_e /*Exponent of all the intensity buffers*/ )
+ Word16 i_e /*Exponent of all the intensity buffers*/
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ Word16 *i_e_band
+#endif
+)
{
Word16 i;
Word32 intensityNorm;
@@ -628,9 +633,25 @@ void computeDirectionVectors_fixed(
scaled_x = L_shl( *intensity_real_x, norm_x );
scaled_y = L_shl( *intensity_real_y, norm_y );
scaled_z = L_shl( *intensity_real_z, norm_z );
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ IF( i_e_band != NULL )
+ {
+ e_x = sub( i_e_band[i - enc_param_start_band], norm_x );
+ e_y = sub( i_e_band[i - enc_param_start_band], norm_y );
+ e_z = sub( i_e_band[i - enc_param_start_band], norm_z );
+ }
+ ELSE
+ {
+ e_x = sub( i_e, norm_x );
+ e_y = sub( i_e, norm_y );
+ e_z = sub( i_e, norm_z );
+ }
+#else
+
e_x = sub( i_e, norm_x );
e_y = sub( i_e, norm_y );
e_z = sub( i_e, norm_z );
+#endif
temp1 = BASOP_Util_Add_Mant32Exp( Mult_32_32( scaled_x, scaled_x ), shl( e_x, 1 ), Mult_32_32( scaled_y, scaled_y ), shl( e_y, 1 ), &exp1 );
intensityNorm = BASOP_Util_Add_Mant32Exp( temp1, exp1, Mult_32_32( scaled_z, scaled_z ), shl( e_z, 1 ), &intensityNorm_e );
@@ -1480,14 +1501,16 @@ void calculate_hodirac_sector_parameters_fx(
tmp16 = BASOP_util_atan2( *p_sec_I_vec_smth_y_fx, *p_sec_I_vec_smth_x_fx, sub( *p_sec_I_vec_smth_y_exp, *p_sec_I_vec_smth_x_exp ) ); // Q13
*p_azi_fx = Mpy_32_32( L_deposit_h( tmp16 ), _180_OVER_PI_Q25 ); // (Q13 + 16) + Q25 - 31 = 54 - 31 = Q23
- tmp16 = BASOP_util_atan2( *p_sec_I_vec_smth_z_fx, tmp_xy_hypo, sub( *p_sec_I_vec_smth_z_exp, tmp_e ) ); // Q13
- *p_ele_fx = Mpy_32_32( L_deposit_h( tmp16 ), _180_OVER_PI_Q25 ); // (Q13 + 16) + Q25 - 31 = 54 - 31 = Q23
+ move32();
+ tmp16 = BASOP_util_atan2( *p_sec_I_vec_smth_z_fx, L_add( tmp_xy_hypo, EPSILON_FX_SMALL ), sub( *p_sec_I_vec_smth_z_exp, tmp_e ) ); // Q13
+ *p_ele_fx = Mpy_32_32( L_deposit_h( tmp16 ), _180_OVER_PI_Q25 ); // (Q13 + 16) + Q25 - 31 = 54 - 31 = Q23
+ move32();
*p_ene_fx = *p_energy_smth_fx;
move32();
*p_ene_exp = *p_energy_smth_exp;
move16();
- tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( normI_fx, *p_energy_smth_fx, &tmp_e ) );
+ tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( normI_fx, L_add( *p_energy_smth_fx, EPSILON_FX_SMALL ), &tmp_e ) );
tmp_e = add( tmp_e, sub( normI_exp, *p_energy_smth_exp ) );
tmp32 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, L_negate( tmp32 ), tmp_e, &tmp_e );
*p_diff_fx = tmp32;
@@ -1500,16 +1523,17 @@ void calculate_hodirac_sector_parameters_fx(
move32();
tmp_diff_exp = *p_diff_exp;
move16();
+ if ( tmp_diff_fx < 0 )
+ {
+ tmp_diff_fx = 0;
+ move32();
+ }
+
tmp_diff_fx = L_shr( tmp_diff_fx, sub( 2, tmp_diff_exp ) ); // Q29
tmp_diff_exp = 2;
move16();
- IF( tmp_diff_fx < 0 )
- {
- *p_diff_fx = 0;
- move32();
- }
- IF( GT_32( tmp_diff_fx, ( ONE_IN_Q29 / 2 ) ) )
+ IF( GT_32( tmp_diff_fx, ONE_IN_Q28 ) )
{
IF( hDirAC->firstrun_sector_params )
{
diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c
index 44135df2f48931e4c6bdedf0e95380cd8e605abf..78603c1db43c9d913d5cff69c6bcb7fce4d16d27 100644
--- a/lib_com/ivas_fb_mixer.c
+++ b/lib_com/ivas_fb_mixer.c
@@ -31,12 +31,13 @@
*******************************************************************************************************/
#include
-#include "options.h"
+#include
#include
+#include "options.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "rom_com.h"
#include "ivas_rom_com.h"
-#include
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#include "prot_fx.h"
@@ -743,6 +744,7 @@ void ivas_fb_mixer_process_fx(
const Word32 *pFilterbank_bin_to_band_re_fx;
const Word32 *pFilterbank_bin_to_band_im_fx;
+ Word16 q_pMdft_out_fx[2];
Word32 *pMdft_out_fx[2];
Word32 *pOut_fr_re_fx, *pOut_fr_im_fx;
Word16 q_pOut_fr_fx = 31;
@@ -837,11 +839,17 @@ void ivas_fb_mixer_process_fx(
move16();
}
}
+ Word16 scale = sub( s_min( L_norm_arr( pOut_fr_re_fx, frame_len ), L_norm_arr( pOut_fr_im_fx, frame_len ) ), find_guarded_bits_fx( shl( frame_len, 1 ) ) );
+ scale_sig32( pOut_fr_re_fx, frame_len, scale );
+ scale_sig32( pOut_fr_im_fx, frame_len, scale );
ivas_imdft_fx( pOut_fr_re_fx, pOut_fr_im_fx, pMdft_out_fx[hist], frame_len );
+ q_pMdft_out_fx[hist] = add( q_pOut_fr_fx, scale );
+ move16();
}
-
+ scale_sig32( pMdft_out_fx[0], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[0] ) );
+ scale_sig32( pMdft_out_fx[1], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[1] ) );
ivas_fb_mixer_cross_fading_fx( hFbMixer, ppOut_pcm_fx, pMdft_out_fx[0], pMdft_out_fx[1], ch, frame_len, frame_len );
- q_ppOut_pcm_fx[ch] = q_pOut_fr_fx;
+ q_ppOut_pcm_fx[ch] = s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] );
move16();
}
@@ -853,7 +861,6 @@ void ivas_fb_mixer_process_fx(
*
*
*-----------------------------------------------------------------------------------------*/
-#ifdef IVAS_FLOAT_FIXED
void ivas_fb_mixer_get_in_out_mapping_fx(
const IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */
Word16 in_out_mixer_map[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i/o: mixing mapping */
@@ -887,7 +894,6 @@ void ivas_fb_mixer_get_in_out_mapping_fx(
return;
}
-#endif
/*-----------------------------------------------------------------------------------------*
* Function ivas_calculate_abs_fr()
diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c
index 283f79cf18527eae065088750e430f2e1472ff30..1dd7f0f8784132b4f3c550fc6d28041dc2058e00 100644
--- a/lib_com/ivas_ism_com.c
+++ b/lib_com/ivas_ism_com.c
@@ -49,13 +49,7 @@
* Local constants
*-----------------------------------------------------------------------*/
-#define BITS_ISM_INACTIVE ( BRATE_ISM_INACTIVE / FRAMES_PER_SEC )
-
-#ifndef IVAS_FLOAT_FIXED
-#define BETA_ISM_LOW_IMP 0.6f
-#define BETA_ISM_MEDIUM_IMP 0.8f
-#endif
-
+#define BITS_ISM_INACTIVE ( BRATE_ISM_INACTIVE / FRAMES_PER_SEC )
#define BETA_ISM_LOW_IMP_Q31 ( 1288490189 ) // 0.6 in Q31
#define BETA_ISM_MEDIUM_IMP_Q31 ( 1717986918 ) // 0.8 in Q31
#define BETA_ISM_MEDIUM_IMP_BY_8_Q31 ( 214748365 ) // 0.8 in Q29
diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h
index 46eb5f12a6aae256f1dc4d5f98fa79375d42d06b..b554072343587a06c5f450f124676b3763827869 100644
--- a/lib_com/ivas_prot.h
+++ b/lib_com/ivas_prot.h
@@ -69,10 +69,10 @@ void stereo_dmx_evs_enc(
/*! r: number of channels to be analysed */
-void copy_encoder_config(
+void copy_encoder_config_ivas_fx(
Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
Encoder_State *st, /* o : encoder state structure */
- const int16_t flag_all /* i : flag 1==update all, 0=partial update */
+ const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/
);
@@ -95,7 +95,7 @@ ivas_error create_cpe_enc(
const int32_t element_brate /* i : element bitrate */
);
-ivas_error create_mct_enc(
+ivas_error create_mct_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
@@ -112,7 +112,7 @@ void destroy_cpe_enc(
CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
);
-void ivas_mct_enc_close(
+void ivas_mct_enc_close_fx(
MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */
);
@@ -200,107 +200,94 @@ ivas_error pre_proc_front_ivas(
ivas_error pre_proc_front_ivas_fx(
SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 element_brate, /* i : SCE/CPE element bitrate */
- const Word16 nb_bits_metadata, /* i : number of metadata bits */
- const Word16 input_frame, /* i : frame length */
- const Word16 n, /* i : channel number */
- Word16 old_inp_12k8_fx[], /* o : (Q-1) buffer of old input signal */
- Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q-1 */
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r */
- Word16 *relE_fx, /* o : frame relative energy Q8 */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */
- Word32 epsP_fx[M + 1], /* o : LP prediction errors */
+ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
+ const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 n, /* i : channel number Q0*/
+ Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 *relE_fx, /* o : frame relative energy Q8*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
Word16 *epsP_fx_q,
- Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15 */
- Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15 */
- Word16 *vad_hover_flag, /* o : VAD hangover flag */
- Word16 *attack_flag, /* o : flag signaling attack */
- Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf) */
- Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf) */
- Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
- Word16 old_wsp[], /* o : weighted input signal buffer q_old_wsp*/
+ Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
+ Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
+ Word16 *attack_flag, /* o : flag signaling attack Q0*/
+ Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
+ Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
+ Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
+ Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
Word16 *q_old_wsp,
- Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6 */
- Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15 */
- Word16 *loc_harm, /* o : harmonicity flag */
- Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8 */
- Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
- Word16 *enerBuffer_fx_exp, /* o : energy buffer */
- Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer */
- Word16 *fft_buff_fx_q, /* o : FFT buffer */
- const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12 */
- const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15 */
- const Word16 currFlatness_fx, /* i : flatness parameter Q7 */
- const Word16 tdm_ratio_idx, /* i : Current Ratio_L index */
- Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) */
- Word16 fr_bands_LR_fx_q,
- const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
- Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q) */
+ Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
+ Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
+ Word16 *loc_harm, /* o : harmonicity flag Q0*/
+ Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
+ Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 *enerBuffer_fx_exp, /* o : energy buffer */
+ Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
+ Word16 *fft_buff_fx_q, /* o : FFT buffer */
+ const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
+ const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
+ const Word16 currFlatness_fx, /* i : flatness parameter Q7*/
+ const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
+ Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/
+ Word16 fr_bands_LR_fx_q[CPE_CHANNELS],
+ const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
+ Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/
Word16 lf_E_LR_fx_q,
- const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q) */
+ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/
Word16 band_energies_LR_fx_q,
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
- const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */
- const Word16 force_front_vad, /* i : flag to force VAD decision */
- const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word32 ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
+ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
+ const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
+ Word16 *Q_new
#ifdef DEBUG_MODE_INFO
,
const Word16 ch_idx
#endif
);
-ivas_error pre_proc_ivas(
+ivas_error pre_proc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 element_brate, /* i : element bitrate */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 input_frame, /* i : frame length */
- Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal */
- Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz */
- Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame*/
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q6 */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */
- Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q */
- Word16 *epsP_fx_q, /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */
- Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
- Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */
- Word16 old_wsp_fx[], /* i : weighted input signal buffer */
+ const Word16 last_element_mode, /* i : last element mode Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word32 last_element_brate, /* i : last element bitrate Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */
+ Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */
+ Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
+ Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/
+ Word16 *epsP_fx_q, /* i : LP prediction errors */
+ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
+ Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/
+ Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/
+ Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/
Word16 e_old_wsp,
- const Word16 loc_harm, /* i : harmonicity flag */
- const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ const Word16 loc_harm, /* i : harmonicity flag Q0*/
+ const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */
Word16 e_enerBuffer,
- Word16 fft_buff_fx[2 * L_FFT],
- Word16 cor_map_sum_fx, // Q8
+ Word16 fft_buff_fx[2 * L_FFT], /* Qx */
+ Word16 cor_map_sum_fx, /* Q8 */
Word16 *Q_new
);
/*! r: number of clipped samples */
-uint32_t ivas_syn_output(
- float *synth[], /* i/o: float synthesis signal */
- const int16_t output_frame, /* i : output frame length (one channel) */
- const int16_t n_channels, /* i : number of output channels */
- int16_t *synth_out /* o : integer 16 bits synthesis signal */
-);
-
-void ivas_syn_output_f(
- float *synth[], /* i/o: float synthesis signal */
- const int16_t output_frame, /* i : output frame length (one channel) */
- const int16_t n_channels, /* i : number of output channels */
- float *synth_out /* o : integer 16 bits synthesis signal */
-);
-
-void ivas_initialize_handles_enc(
+void ivas_initialize_handles_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
@@ -308,16 +295,16 @@ ivas_error ivas_init_encoder(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
-void ivas_destroy_enc(
+void ivas_destroy_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
-ivas_error ivas_initialize_MD_bstr_enc(
+ivas_error ivas_initialize_MD_bstr_enc_fx(
BSTR_ENC_HANDLE *hBstr, /* o : encoder MD bitstream handle */
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
-void ivas_destroy_MD_bstr_enc(
+void ivas_destroy_MD_bstr_enc_fx(
BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */
);
@@ -415,36 +402,37 @@ void ivas_initialize_handles_dec(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
-ivas_error ivas_core_enc(
+ivas_error ivas_core_enc_fx(
SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- const int16_t n_CoreChannels, /* i : number of core channels to be coded */
- Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal */
- Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal */
- Word32 ener_fx[], /* i : residual energy from Levinson-Durbin Q6*/
- Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes*/
- Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q */
- Word16 epsP_fx_q[], /* i : LP prediction errors */
- Word16 lsp_new[][M], /* i : LSPs at the end of the frame Q15 */
- Word16 lsp_mid[][M], /* i : LSPs in the middle of the frame Q15 */
- const int16_t vad_hover_flag[], /* i : VAD hanglover flag */
- int16_t attack_flag[], /* i : attack flag (GSC or TC) */
- Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
- Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
+ const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/
+ Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/
+ Word16 Q_new[],
+ Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/
+ Word16 epsP_fx_q[], /* i : LP prediction errors */
+ Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/
+ Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/
+ Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/
+ Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/
Word16 *q_re_im_buf,
- Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer */
+ Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/
Word16 e_old_wsp[],
- const int16_t loc_harm[], /* i : harmonicity flag */
- const Word16 cor_map_sum[], /* i : speech/music clasif. parameter Q8 */
- const int16_t vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO */
- Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
- Word16 enerBuffer_fx_exp[], /* o : energy buffer */
- Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer */
- const int16_t tdm_SM_flag, /* i : channel combination scheme flag */
- const int16_t ivas_format, /* i : IVAS format */
- const int16_t flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */
+ const Word16 loc_harm[], /* i : harmonicity flag Q0*/
+ const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/
+ const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 enerBuffer_fx_exp[], /* o : energy buffer */
+ Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/
+ const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/
+ const Word16 ivas_format, /* i : IVAS format Q0*/
+ const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
);
@@ -654,11 +642,6 @@ void TonalMdctConceal_whiten_noise_shape_ivas(
const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE
);
-
-float rand_triangular_signed(
- int16_t *seed );
-
-
void dtx_read_padding_bits(
DEC_CORE_HANDLE st,
const int16_t num_bits
@@ -792,7 +775,7 @@ Word16 ism_quant_meta_fx(
const Word16 cbsize /* i : codebook size */
);
-ivas_error ivas_ism_metadata_enc_create(
+ivas_error ivas_ism_metadata_enc_create_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t n_ISms, /* i : number of objects */
int32_t element_brate_tmp[] /* o : element bitrate per object */
@@ -835,11 +818,11 @@ ivas_error ivas_ism_metadata_dec(
/*! r: ISM format mode */
-ivas_error ivas_param_ism_enc_open(
+ivas_error ivas_param_ism_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
-void ivas_param_ism_enc_close(
+void ivas_param_ism_enc_close_fx(
PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */
const int32_t input_Fs /* i : input sampling_rate */
);
@@ -907,7 +890,7 @@ void ivas_ism_dtx_dec(
int16_t *nb_bits_metadata /* o : number of metadata bits */
);
-void ivas_ism_metadata_sid_enc(
+void ivas_ism_metadata_sid_enc_fx(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
const int16_t flag_noisy_speech, /* i : noisy speech flag */
const int16_t nchan_ism, /* i : number of objects */
@@ -934,7 +917,7 @@ void ivas_ism_metadata_sid_dec(
);
-void ivas_param_ism_compute_noisy_speech_flag(
+void ivas_param_ism_compute_noisy_speech_flag_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
@@ -945,18 +928,6 @@ void update_last_metadata(
const int16_t updt_flag[] /* i : last metadata update flag */
);
-#ifndef IVAS_FLOAT_FIXED
-void ivas_get_ism_sid_quan_bitbudget(
- const int16_t nchan_ism, /* i : number of objects */
- int16_t *nBits_azimuth, /* o : number of Q bits for azimuth */
- int16_t *nBits_elevation, /* o : number of Q bits for elevation */
- float *q_step, /* o : quantization step */
- float *q_step_border, /* o : quantization step at the border */
- int16_t *nBits_coh, /* o : number of Q bits for coherence */
- int16_t *nBits_sce_id /* o : number of Q bits for sce_id_dtx */
-);
-#endif
-
void ivas_ism_dtx_limit_noise_energy_for_near_silence(
SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */
const int16_t sce_id_dtx, /* i : SCE DTX ID */
@@ -1681,9 +1652,9 @@ void InternalTCXDecoder(
void stereo_mdct_core_enc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples */
- Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */
- Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */
+ Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/
+ Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/
+ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/
);
void initMdctStereoEncData(
@@ -1960,12 +1931,12 @@ void splitAvailableBits(
int16_t *bits_ch1 /* o : bits for channel 1 */
);
-int16_t write_stereo_to_bitstream
+Word16 write_stereo_to_bitstream_fx
(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
Encoder_State **sts, /* i/o: Encoder state structure */
- int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
+ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
);
@@ -1993,28 +1964,6 @@ void convert_coeffs_to_higher_res(
const int16_t len /* i : length of subframes */
);
-#ifndef IVAS_FLOAT_FIXED
-void sns_compute_scf(
- float spectrum[],
- const PsychoacousticParameters *pPsychParams,
- const int16_t L_frame,
- float *scf
-);
-
-void sns_interpolate_scalefactors(
- float *scf_int, /* o : interpolated scalefactors for spectrum shaping */
- const float *scf, /* i : sns scalefactors as derived from the signal or read from the bitstream */
- int16_t encoder_side /* i : flag, if scalefactors have to be inverted */
-);
-
-void sns_shape_spectrum(
- float spectrum[], /* i/o: spectrum to be shaped */
- const PsychoacousticParameters *pPsychParams, /* i : psychoacoustic parameters used to get the frequency bands */
- const float *scf_int, /* i : already interpolated SNS scalefactors */
- const int16_t L_frame /* i : frame length */
-);
-#endif
-
int16_t quantize_sns(
float sns_in[CPE_CHANNELS][NB_DIV][M],
float snsQ_out[CPE_CHANNELS][NB_DIV][M],
@@ -2186,112 +2135,13 @@ void dtx_enc_init(
* Framework general prototypes
*----------------------------------------------------------------------------------*/
-void mvr2r_inc(
- const float x[], /* i : input vector */
- const int16_t x_inc, /* i : increment for vector x[] */
- float y[], /* o : output vector */
- const int16_t y_inc, /* i : increment for vector y[] */
- const int16_t n /* i : vector size */
-);
-
-void v_add_inc(
- const float x1[], /* i : Input vector 1 */
- const int16_t x_inc, /* i : Increment for input vector 1 */
- const float x2[], /* i : Input vector 2 */
- const int16_t x2_inc, /* i : Increment for input vector 2 */
- float y[], /* o : Output vector that contains vector 1 + vector 2 */
- const int16_t y_inc, /* i : increment for vector y[] */
- const int16_t N /* i : Vector length */
-);
-
-void v_mult_inc(
- const float x1[], /* i : Input vector 1 */
- const int16_t x1_inc, /* i : Increment for input vector 1 */
- const float x2[], /* i : Input vector 2 */
- const int16_t x2_inc, /* i : Increment for input vector 1 */
- float y[], /* o : Output vector that contains vector 1 .* vector 2 */
- const int16_t y_inc, /* i : increment for vector y[] */
- const int16_t N /* i : Vector length */
-);
-
-void v_addc(
- const float x[], /* i : Input vector */
- const float c, /* i : Constant */
- float y[], /* o : Output vector that contains c*x */
- const int16_t N /* i : Vector length */
-);
-
-void v_min(
- 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_sqrt(
- const float x[], /* i : Input vector */
- float y[], /* o : Output vector that contains sqrt(x) */
- const int16_t N /* i : Vector length */
-);
-
-/*! r: sum abs of all vector elements */
-float sumAbs(
- const float *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-);
-
void mvc2c(
const uint8_t x[], /* i : input vector */
uint8_t y[], /* o : output vector */
const int16_t n /* i : vector size */
);
-/*! r: the dot product x'*A*A'*x */
-float dot_product_cholesky(
- const float *x, /* i : vector x */
- const float *A, /* i : Cholesky matrix A */
- const int16_t N /* i : vector & matrix size */
-);
-
-void v_mult_mat(
- float *y, /* o : the product x*A */
- const float *x, /* i : vector x */
- const float *A, /* i : matrix A */
- const int16_t N, /* i : number of rows */
- const int16_t C /* i : number of columns */
-);
-
-/*! r: log(sum(exp(X)) of the input array X */
-float logsumexp(
- const float X[], /* i : input array X */
- const int16_t N /* i : number of elements in array X */
-);
-
-/*! r: mapped output value */
-float lin_interp(
- const float x, /* i : the value to be mapped */
- const float x1, /* i : source range interval: low end */
- const float y1, /* i : source range interval: high end */
- const float x2, /* i : target range interval: low */
- const float y2, /* i : target range interval: high */
- const int16_t flag_sat /* i : flag to indicate whether to apply saturation */
-);
-
-/*! r: Adjusted value */
-float check_bounds(
- const float value, /* i : Input value */
- const float low, /* i : Low limit */
- const float high /* i : High limit */
-);
-
/*! r: Adjusted value */
-int16_t check_bounds_s(
- const int16_t value, /* i : Input value */
- const int16_t low, /* i : Low limit */
- const int16_t high /* i : High limit */
-);
-
-
ivas_error stereo_memory_dec(
const int32_t ivas_total_brate, /* i : IVAS total bitrate */
CPE_DEC_HANDLE hCPE, /* i : CPE decoder structure */
@@ -2380,15 +2230,6 @@ void write_mct_bitstream(
const int16_t nchan /* i : number of channels */
);
-#ifndef IVAS_FLOAT_FIXED
-void splitAvailableBitsMCT(
- void **sts, /* i/o: encoder/decoder state structure */
- const int16_t total_bits, /* i : total number of available bits */
- const int16_t split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits */
- const int16_t enc_dec, /* i : encoder or decoder flag */
- const int16_t nchan /* i : number of channels */
-);
-#else
void splitAvailableBitsMCT_fx(
void **sts, /* i/o: encoder/decoder state structure */
const Word16 total_bits, /* i : total number of available bits */
@@ -2396,7 +2237,6 @@ void splitAvailableBitsMCT_fx(
const Word16 enc_dec, /* i : encoder or decoder flag */
const Word16 nchan /* i : number of channels */
);
-#endif
void getChannelEnergies(
Encoder_State **sts, /* i : Encoder state structure */
@@ -2488,14 +2328,6 @@ void mctStereoIGF_dec(
const int16_t bfi /* i : bad frame flag */
);
-#ifndef IVAS_FLOAT_FIXED
-void ivas_mdct_tcx10_bit_distribution(
- int16_t target_bitsTCX10[NB_DIV], /* o : target bit distribution */
- const int16_t bits_frame_channel, /* i : bits frame channel */
- const int16_t nTnsBitsTCX10[NB_DIV] /* i : TNS bits */
-);
-#endif
-
void enc_prm_igf_mdct(
Encoder_State *st, /* i : Encoder state handle */
BSTR_ENC_HANDLE hBstr /* i/o: Bitstream handle */
@@ -2524,21 +2356,12 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512(
const int16_t bits_sp_coh
);
-#ifndef IVAS_FLOAT_FIXED
void deindex_sph_idx(
const uint16_t sphIndex, /* i : Spherical index */
const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */
float *theta, /* o : Elevation */
float *phi /* o : Azimuth */
);
-#else
-void deindex_sph_idx_fx(
- const UWord16 sphIndex, /* i : Spherical index */
- const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */
- Word32 *theta_fx, /* o : Elevation Q22*/
- Word32 *phi_fx /* o : Azimuth Q22 */
-);
-#endif
/*! r: output index for direction */
uint16_t index_theta_phi_16(
@@ -2609,14 +2432,6 @@ void ivas_qmetadata_azimuth_elevation_to_direction_vector(
float *dv /* o : direction vector */
);
-#ifndef IVAS_FLOAT_FIXED
-void ivas_qmetadata_direction_vector_to_azimuth_elevation(
- const float *dv, /* i : direction vector */
- float *az, /* o : azimuth */
- float *el /* o : elevation */
-);
-#endif
-
ivas_error only_reduce_bits_direction(
int16_t *reduce_bits_out,
IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */
@@ -2653,32 +2468,6 @@ int16_t quantize_direction2D(
const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */
);
-#ifndef IVAS_FLOAT_FIXED
-/*! r :companded azimuth value */
-float companding_azimuth(
- const float azi, /* i : input azimuth value */
- const MC_LS_SETUP mc_format, /* i : input channel format */
- const int16_t theta_flag, /* i : zero/non zero elevation flag */
- const int16_t direction /* i : direction of companding (direct or inverse)*/
-);
-
-/*! r: index azimuth */
-int16_t quantize_phi_chan_lbr(
- const float phi, /* i : azimuth value */
- float *phi_hat, /* o : quantized azimuth */
- const int16_t n /* i : azimuth codebook size */
-);
-
-/*! r: index azimuth */
-int16_t quantize_phi_chan_compand(
- float phi, /* i : azimuth value */
- float *phi_hat, /* o : quantized azimuth */
- const int16_t n, /* i : azimuth codebook size */
- const int16_t theta_flag, /* i : flag signaling high elevation */
- const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */
-);
-#endif
-
void quantize_direction_frame2D(
IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */
float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input azimuth values */
@@ -2923,11 +2712,11 @@ void ivas_dirac_dec_get_response(
-ivas_error ivas_mc_paramupmix_enc_open(
+ivas_error ivas_mc_paramupmix_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
);
-void ivas_mc_paramupmix_enc_close(
+void ivas_mc_paramupmix_enc_close_fx(
MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */
const int32_t input_Fs /* i : input sampling rate */
);
@@ -3018,63 +2807,6 @@ UWord16 ivas_param_mc_get_configuration_index_fx(
const Word32 ivas_total_brate /* i : IVAS total bitrate */
);
-int16_t matrix_product(
- const float *X, /* i : left hand matrix */
- const int16_t rowsX, /* i : number of rows of the left hand matrix */
- const int16_t colsX, /* i : number of columns of the left hand matrix */
- const int16_t transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */
- const float *Y, /* i : right hand matrix */
- const int16_t rowsY, /* i : number of rows of the right hand matrix */
- const int16_t colsY, /* i : number of columns of the right hand matrix */
- const int16_t transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */
- float *Z /* o : resulting matrix after the matrix multiplication */
-);
-
-
-int16_t matrix_diag_product(
- const float *X, /* i : left hand matrix */
- const int16_t rowsX, /* i : number of rows of the left hand matrix */
- const int16_t colsX, /* i : number of columns of the left hand matrix */
- const int16_t transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */
- const float *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements */
- const int16_t entriesY, /* i : number of entries in the diagonal */
- float *Z /* o : resulting matrix after the matrix multiplication */
-);
-
-int16_t diag_matrix_product(
- const float *Y, /* i : left hand diagonal matrix as vector containing the diagonal elements */
- const int16_t entriesY, /* i : length of the diagonal of the left hand matrix */
- const float *X, /* i : right hand matrix */
- const int16_t rowsX, /* i : number of rows of the right hand matrix */
- const int16_t colsX, /* i : number of columns of the right hand matrix */
- const int16_t transpX, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */
- float *Z /* o : resulting matrix after the matrix multiplication */
-);
-
-int16_t matrix_product_diag(
- const float *X, /* i : left hand matrix */
- const int16_t rowsX, /* i : number of rows of the left hand matrix */
- const int16_t colsX, /* i : number of columns of the left hand matrix */
- const int16_t transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */
- const float *Y, /* i : right hand matrix */
- const int16_t rowsY, /* i : number of rows of the right hand matrix */
- const int16_t colsY, /* i : number of columns of the right hand matrix */
- const int16_t transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */
- float *Z /* o : resulting matrix after the matrix multiplication */
-);
-
-void cmplx_matrix_square(
- const float *realX, /* i : real part of the matrix */
- const float *imagX, /* i : imaginary part of the matrix */
- const int16_t mRows, /* i : number of rows of the matrix */
- const int16_t nCols, /* i : number of columns of the matrix */
- float *realZ, /* o : real part of the resulting matrix */
- float *imagZ /* o : imaginary part of the resulting matrix */
-);
-
-
-
-
ivas_error ivas_dirac_dec_output_synthesis_cov_open(
DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */
DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: handle for the covariance synthesis state */
@@ -3609,85 +3341,17 @@ void ivas_pca_dec(
float *pcm_out[] /* o : output audio channels */
);
-#ifndef IVAS_FLOAT_FIXED
-/* PCA utilities */
-void eye_matrix(
- float *mat,
- const int16_t n,
- const float d
-);
-
-void cov_subfr(
- float **ptr_sig,
- float *r,
- const int16_t n_channels,
- const int16_t len
-);
-
-void eig_qr(
- const float *A,
- const int16_t num_iter,
- float *EV, float *Vals,
- const int16_t n
-);
-
-void exhst_4x4(
- float *cost_mtx,
- int16_t *path,
- const int16_t maximize
-);
-
-float mat_det4(
- const float *m
-);
-
-/* quaternion utilities */
-void mat2dquat(
- const float *a,
- float *ql,
- float *qr
-);
-
-void dquat2mat(
- const float *ql,
- const float *qr,
- float *m
-);
-
-void quat_shortestpath(
- const float *q00,
- float *q01,
- const float *q10,
- float *q11
-);
-
-void pca_interp_preproc(
- const float *prev_ql,
- const float *prev_qr,
- const float *ql,
- const float *qr,
- const int16_t len,
- float *ql_interp,
- float *qr_interp
-);
-
-void pca_enc_s3(
- float *q,
- int32_t *index
-);
-#endif
-
void pca_dec_s3(
const int32_t index,
float *q
);
-void ivas_huffman_encode(
+void ivas_huffman_encode_fx(
ivas_huffman_cfg_t *huff_cfg,
- int16_t in,
- int16_t *hcode,
- int16_t *hlen
+ Word16 in,
+ Word16 *hcode,
+ Word16 *hlen
);
@@ -3792,11 +3456,11 @@ void generate_gridEq(
SPHERICAL_GRID_DATA *data /* o : data structure for grid */
);
-ivas_error ivas_masa_enc_open(
+ivas_error ivas_masa_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
);
-void ivas_masa_enc_close(
+void ivas_masa_enc_close_fx(
MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */
);
@@ -3917,14 +3581,6 @@ int16_t calculate_brate_limit_flag(
const int16_t nchan_ism /* i : number of objects */
);
-#ifndef IVAS_FLOAT_FIXED
-void ivas_get_stereo_panning_gains(
- const float aziDeg,
- const float eleDeg,
- float panningGains[2]
-);
-#endif
-
void ivas_masa_set_coding_config(
MASA_CODEC_CONFIG* config, /* i/o: MASA coding config structure */
int16_t* band_mapping, /* o : Band mapping used */
@@ -3949,19 +3605,10 @@ void masa_compensate_two_dir_energy_ratio_index(
const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */
);
-#ifndef IVAS_FLOAT_FIXED
-void ivas_set_qmetadata_maxbit_req(
- IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */
- const IVAS_FORMAT ivas_format /* i : IVAS format */
-);
-#else
void ivas_set_qmetadata_maxbit_req_fx(
IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */
const IVAS_FORMAT ivas_format /* i : IVAS format */
);
-#endif
-
-
void masa_sample_rate_band_correction(
MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */
@@ -4061,12 +3708,6 @@ void panning_wrap_angles(
float *ele_wrapped /* o : wrapped elevation component */
);
-void v_sort_ind(
- float *x, /* i/o: Vector to be sorted */
- int16_t *idx, /* o : Original index positions */
- const int16_t len /* i : vector length */
-);
-
/*----------------------------------------------------------------------------------*
* LS Renderer prototypes
*----------------------------------------------------------------------------------*/
@@ -4149,28 +3790,13 @@ void ivas_mcmasa_split_brate(
void ivas_mcmasa_dmx_modify_fx(
- const Word16 n_samples, /* i : input frame length in samples */
- Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/
- const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0*/
- const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/
-);
-
-void v_multc_acc(
- const float x[], /* i : Input vector */
- const float c, /* i : Constant */
- float y[], /* o : Output vector that contains y + c*x */
- const int16_t N /* i : Vector length */
+ const Word16 n_samples, /* i : input frame length in samples */
+ Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/
+ Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/
+ const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */
+ const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/
);
-void lls_interp_n(
- float x[], /* i/o: input/output vector */
- const int16_t N, /* i : length of the input vector */
- float *a, /* o : calculated slope */
- float *b, /* o : calculated offset */
- const int16_t upd /* i : use 1 to update x[] with the interpolated output*/
-);
-
-
ivas_error ivas_mono_dmx_renderer_open(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
@@ -4196,7 +3822,7 @@ ivas_error ivas_create_lfe_lpf_enc(
const int32_t input_Fs /* i : input sampling rate */
);
-void ivas_lfe_lpf_enc_close(
+void ivas_lfe_lpf_enc_close_fx(
ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */
);
@@ -4211,12 +3837,12 @@ void ivas_lfe_lpf_enc_apply(
* LFE Coding prototypes
*----------------------------------------------------------------------------------*/
-ivas_error ivas_create_lfe_enc(
+ivas_error ivas_create_lfe_enc_fx(
LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */
const int32_t input_Fs /* i : input sampling rate */
);
-void ivas_lfe_enc_close(
+void ivas_lfe_enc_close_fx(
LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */
);
diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h
index ecebf22dc7b5f75df4dd33c9a31aa81736311484..3a22c5c721726926b0ade11621d4e478342ebbec 100644
--- a/lib_com/ivas_prot_fx.h
+++ b/lib_com/ivas_prot_fx.h
@@ -864,7 +864,8 @@ void td_stereo_param_updt_fx(
);
void updt_enc_common_ivas_fx(
- Encoder_State *st /* i/o: encoder state structure */
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 Q_new /* i : CUrrent frame scaling */
);
@@ -3227,7 +3228,12 @@ void computeDirectionVectors_fixed(
Word32 *direction_vector_x, /*Q30*/
Word32 *direction_vector_y, /*Q30*/
Word32 *direction_vector_z, /*Q30*/
- Word16 i_e /*Exponent of all the intensity buffers*/ );
+ Word16 i_e /*Exponent of all the intensity buffers*/
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ Word16 *i_e_band
+#endif
+);
UWord8 ivas_masa_surrcoh_signicant_fx(
@@ -3438,17 +3444,18 @@ ivas_error ivas_param_mc_enc_reconfig_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
);
-Word16 ivas_arith_encode_cmplx_cell_array(
+Word16 ivas_arith_encode_cmplx_cell_array_fx(
ivas_arith_t *pArith_re,
ivas_arith_t *pArith_re_diff,
- const Word16 *pDo_diff,
- const Word16 nB,
- Word16 *pSymbol_re,
- Word16 *pSymbol_old_re,
+ const Word16 *pDo_diff, /* Q0 */
+ const Word16 nB, /* Q0 */
+ Word16 *pSymbol_re, /* Q0 */
+ Word16 *pSymbol_old_re, /* Q0 */
ivas_cell_dim_t *pCell_dims,
BSTR_ENC_HANDLE hMetaData,
- const Word16 any_diff,
- const Word16 wc_strat_arith );
+ const Word16 any_diff, /* Q0 */
+ const Word16 wc_strat_arith /* Q0 */
+);
ivas_error stereo_dmx_evs_init_encoder_fx(
STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS_out, /* o : Stereo downmix for EVS encoder handle */
@@ -4121,7 +4128,7 @@ ivas_error ivas_set_ism_metadata_fx(
const Word16 non_diegetic_flag /* i : non-diegetic object flag */
);
-ivas_error ivas_ism_metadata_enc(
+ivas_error ivas_ism_metadata_enc_fx(
Word32 *ism_total_brate, /* i/o: ISM total bitrate */
const Word16 nchan_ism, /* i : number of ISM channels */
const Word16 nchan_transport, /* i : number of transport channels */
@@ -4558,13 +4565,17 @@ ivas_error front_vad_fx(
const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const Word16 input_frame, /* i : frame length */
Word16 vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */
- Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands Q_buffer[n] + QSCALE + 2 */
+ Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands q_fr_bands_fx */
+ Word16 q_fr_bands[], /* o : Q of fr_bands_fx Q0 */
Word16 Etot_LR_fx[], /* o : total energy Left & Right channel Q8 */
- Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels Q_buffer[n] + QSCALE */
+ Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels q_lf_E */
+ Word16 q_lf_E[], /* o : Q of lf_E_fx */
Word16 localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels */
Word16 vad_hover_flag[], /* o : VAD hangover flag */
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN Q_buffer[1] + QSCALE + 2 - band_ener_guardbits*/
- Word32 *PS_out_fx, /* o : energy spectrum Q_buffer + QSCALE */
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN q_band_energies_LR */
+ Word16 *q_band_energies_LR, /* o : Q of band_energies_LR_fx */
+ Word32 *PS_out_fx, /* o : energy spectrum q_PS_out */
+ Word16 *q_PS_out, /* o : Q of PS_out_fx Q0 */
Word16 *Bin_E_out_fx, /* o : log-energy spectrum of the current frame Q7 */
Word16 Q_inp,
Word16 *Q_buffer,
@@ -4927,17 +4938,6 @@ void ivas_dirac_dec_set_md_map(
const Word16 nCldfbTs /* i : number of CLDFB time slots */
);
-void computeDirectionVectors_fixed(
- Word32 *intensity_real_x,
- Word32 *intensity_real_y,
- Word32 *intensity_real_z,
- const Word16 enc_param_start_band,
- const Word16 num_frequency_bands,
- Word32 *direction_vector_x, /*Q30*/
- Word32 *direction_vector_y, /*Q30*/
- Word32 *direction_vector_z, /*Q30*/
- Word16 i_e /*Exponent of all the intensity buffers*/ );
-
void computeDirectionVectors_fx(
Word32 *intensity_real_x,
Word32 *intensity_real_y,
@@ -5806,14 +5806,14 @@ ivas_error ivas_sce_enc_fx(
);
ivas_error ivas_cpe_enc_fx(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 cpe_id, /* i : CPE # identifier */
- Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx) */
- Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx) */
- Word16 q_data_fx, /* i : Q-factor of input signal for both channels */
- const Word16 input_frame, /* i : input frame length per channel */
- const Word16 nb_bits_metadata /* i : number of metadata bits */
-);
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const Word16 cpe_id, /* i : CPE # identifier */
+ Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx) */
+ Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx) */
+ Word16 q_data_fx, /* i : Q-factor of input signal for both channels */
+ const Word16 input_frame, /* i : input frame length per channel */
+ const Word16 nb_bits_metadata, /* i : number of metadata bits */
+ Word16 Q_new_out[] );
ivas_error ivas_mct_enc_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
@@ -5839,7 +5839,8 @@ ivas_error ivas_compute_core_buffers_fx(
Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */
Word16 Q_old_inp_16k,
Word16 Q_r[2],
- Word16 *Q_new );
+ Word16 *Q_new,
+ Word16 downscale_buf_speech_enc_pe );
ivas_error ivas_enc_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com.c
index c3dbc8fe6b7a8d836b19561fed1178195fa318ce..499585221bbb9c682fea3d63886c15bc0e54d5f9 100644
--- a/lib_com/ivas_qspherical_com.c
+++ b/lib_com/ivas_qspherical_com.c
@@ -668,7 +668,15 @@ Word16 quantize_phi_chan_compand_fx(
delta_phi = L_shr( delta_phi, sub( 9, tmp_e ) ); // Q22
// id_phi = (int16_t) round_f( ( phi / (float) delta_phi ) );
id_phi = BASOP_Util_Divide3232_Scale( phi, delta_phi, &tmp_e ); // Q15
- id_phi = shr( id_phi, sub( 15, tmp_e ) ); // Q0
+ IF( GE_16( abs_s( id_phi ), shl_sat( 1, sub( 15, tmp_e ) ) ) )
+ {
+ id_phi = shr( id_phi, sub( 15, tmp_e ) ); // Q0
+ }
+ ELSE
+ {
+ id_phi = 0;
+ move16();
+ }
IF( add( id_phi, shr( n, 1 ) ) < 0 )
{
diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c
index a86f2913c2aecf07b420bf450b9106eab8b7d9a4..5a864835cf67f9c253d74e680c78ae94eb14a267 100644
--- a/lib_com/ivas_rom_com.c
+++ b/lib_com/ivas_rom_com.c
@@ -464,25 +464,6 @@ const UWord16 ECSQ_tab_inverse[1 + ECSQ_SEGMENT_SIZE] =
};
-/*-------------------------------------------------------------------------
- * Stereo ICA analysis ROM tables
- *------------------------------------------------------------------------*/
-const float ica_sincInterp2[2*SINC_ORDER1+1] =
-{
- 0.0f,-0.002323f,0.0f, 0.003486f, 0.0f,-0.005865f,0.0f, 0.009735f, 0.0f,-0.015447f,0.0f, 0.023503f,
- 0.0f,-0.034727f,0.0f, 0.050649f, 0.0f,-0.074578f,0.0f, 0.115220f, 0.0f,-0.204776f,0.0f, 0.634114f,
- 1.0f, 0.634114f,0.0f,-0.204776f, 0.0f, 0.115220f,0.0f,-0.074578f, 0.0f, 0.050649f,0.0f,-0.034727f,
- 0.0f, 0.023503f,0.0f,-0.015447f, 0.0f, 0.009735f,0.0f,-0.005865f, 0.0f, 0.003486f,0.0f,-0.002323f, 0.0f
-};
-const float ica_sincInterp4[2*SINC_ORDER1+1] =
-{
- 0.0f,-0.003285f,-0.005537f,-0.004930f, 0.0f, 0.008295f, 0.015189f, 0.013767f, 0.0f,-0.021845f,-0.038282f,-0.033239f,
- 0.0f, 0.049111f, 0.083913f, 0.071628f, 0.0f,-0.105469f,-0.183615f,-0.162946f, 0.0f, 0.289597f, 0.626641f, 0.896773f,
- 1.0f, 0.896773f, 0.626641f, 0.289597f, 0.0f,-0.162946f,-0.183615f,-0.105469f, 0.0f, 0.071628f, 0.083913f, 0.049111f,
- 0.0f,-0.033239f,-0.038282f,-0.021845f, 0.0f, 0.013767f, 0.015189f, 0.008295f, 0.0f,-0.004930f,-0.005537f,-0.003285f, 0.0f
-};
-
-
const Word16 tdm_bit_allc_tbl[5][6] =
{
/* IC -- UC -- GC -- TM --AC */
@@ -494,41 +475,6 @@ const Word16 tdm_bit_allc_tbl[5][6] =
};
-const float tdm_LSF_MEAN_PRED_QNT[M] =
-{
- 391.31345F, 608.50453F, 968.00585F, 1354.23965F, 1709.71084F, 2080.49872F, 2450.64009F, 2796.96588F,
- 3196.19608F, 3554.17092F, 3915.02370F, 4283.81121F, 4707.59835F, 5109.79026F, 5526.44936F, 5903.42625F
-};
-
-const float tdm_LSF_MEAN_PRED_QNT_IN[M] =
-{
- 288.540f, 535.469f, 899.738f, 1342.313f, 1730.736f, 2107.070f, 2491.455f, 2859.828f, 3239.279f, 3625.673f, 3992.540f, 4356.748f, 4752.356f, 5153.685f, 5567.107f, 5972.623f,
-};
-const float tdm_LSF_MEAN_PRED_QNT_OUT[M] =
-{
- 286.414f, 522.366f, 887.297f, 1347.961f, 1725.604f, 2102.356f, 2511.703f, 2853.093f, 3211.319f, 3612.072f, 3970.889f, 4327.774f, 4732.423f, 5154.984f, 5572.849f, 5964.332f,
-};
-
-const float tdm_PRED_QNT_fixed_beta_prd_diag_3[15 + 16 + 15] =
-{
- 0.7040f, 0.1203f,
- -0.1119f, 0.7340f, 0.1803f,
- 0.0253f, 0.6702f, 0.1901f,
- -0.1847f, 0.7892f, 0.3010f,
- -0.0418f, 0.8716f, 0.1837f,
- 0.0033f, 0.6915f, 0.2394f,
- 0.0213f, 0.6728f, 0.2441f,
- 0.0705f, 0.7549f, 0.1983f,
- 0.0752f, 0.7152f, 0.2173f,
- 0.0886f, 0.6163f, 0.3067f,
- 0.0217f, 0.8121f, 0.2021f,
- 0.1584f, 0.7311f, 0.1746f,
- 0.1204f, 0.7296f, 0.1978f,
- 0.1231f, 0.7502f, 0.1234f,
- 0.1709f, 0.6372f, 0.1060f,
- 0.1193f, 0.6574f,
-};
-
const Word16 fast_FCB_bits_2sfr[] = {8, 14, 18, 20, 24, 128/*stop value*/};
const Word16 fast_FCB_rates_2sfr[] = {/*16*50,*/ (8+14)*50, 28*50, 32*50, 34*50, 36*50, 38*50, 40*50, 42*50, 44*50, 48*50};
@@ -2534,22 +2480,22 @@ const Word16 mcmasa_bits[IVAS_NUM_ACTIVE_BRATES] =
50, 70, 80, 120, 140, 160, 220, 256, 288, 432, 528, 832, 1024, MASA_MAX_BITS
};
-const uint8_t masa_nbands[IVAS_NUM_ACTIVE_BRATES] =
+const UWord8 masa_nbands[IVAS_NUM_ACTIVE_BRATES] =
{
5, 5, 5, 5, 5, 5, 5, 5, 8, 12, 18, 24, 24, 24
};
-const uint8_t masa_joined_nbands[IVAS_NUM_ACTIVE_BRATES] =
+const UWord8 masa_joined_nbands[IVAS_NUM_ACTIVE_BRATES] =
{
5, 5, 5, 8, 12, 12, 12, 18, 18, 18, 18, 24, 24, 24
};
-const uint8_t masa_twodir_bands[IVAS_NUM_ACTIVE_BRATES] =
+const UWord8 masa_twodir_bands[IVAS_NUM_ACTIVE_BRATES] =
{
0, 0, 0, 0, 0, 1, 1, 1, 3, 4, 6, 6, 9, 24
};
-const uint8_t masa_twodir_bands_joined[IVAS_NUM_ACTIVE_BRATES] =
+const UWord8 masa_twodir_bands_joined[IVAS_NUM_ACTIVE_BRATES] =
{
0, 0, 0, 0, 0, 2, 2, 3, 4, 6, 8, 9, 12, MASA_MAXIMUM_TWO_DIR_BANDS
};
@@ -2646,291 +2592,6 @@ const Word16 dirac_gains_P_idx[16] =
-1, 1, 0, 1, 4, 3, 2, 3, 4, 8, 7, 6, 5, 6, 7, 8
};
-const float dirac_gains_norm_term[9] =
-{
- 1.000000e+00f, 7.071068e-01f, 1.000000e+00f, 4.082483e-01f, 2.041242e-01f, 1.000000e+00f, 2.886751e-01f, 9.128709e-02f, 3.726780e-02f
-};
-
-const float dirac_gains_Pnm[91][9] =
-{
- {-1.000000e+00f,-0.000000e+00f,1.000000e+00f,-0.000000e+00f,0.000000e+00f,-1.000000e+00f,-0.000000e+00f,0.000000e+00f,-0.000000e+00f},
- {-9.998477e-01f,1.745221e-02f,9.995431e-01f,-5.234867e-02f,9.137391e-04f,-9.990864e-01f,1.046734e-01f,-4.568000e-03f,7.973384e-05f},
- {-9.993909e-01f,3.489930e-02f,9.981732e-01f,-1.046341e-01f,3.653884e-03f,-9.963478e-01f,2.090770e-01f,-1.825829e-02f,6.375900e-04f},
- {-9.986295e-01f,5.233614e-02f,9.958913e-01f,-1.567932e-01f,8.217215e-03f,-9.917910e-01f,3.129416e-01f,-4.102976e-02f,2.150287e-03f},
- {-9.975641e-01f,6.975590e-02f,9.927012e-01f,-2.087579e-01f,1.459766e-02f,-9.854290e-01f,4.159897e-01f,-7.281048e-02f,5.091363e-03f},
- {-9.961947e-01f,8.715547e-02f,9.886059e-01f,-2.604715e-01f,2.278823e-02f,-9.772766e-01f,5.179674e-01f,-1.135075e-01f,9.930593e-03f},
- {-9.945220e-01f,1.045284e-01f,9.836106e-01f,-3.118673e-01f,3.277856e-02f,-9.673560e-01f,6.186047e-01f,-1.629950e-01f,1.713145e-02f},
- {-9.925461e-01f,1.218695e-01f,9.777218e-01f,-3.628832e-01f,4.455650e-02f,-9.556924e-01f,7.176415e-01f,-2.211219e-01f,2.715038e-02f},
- {-9.902681e-01f,1.391732e-01f,9.709461e-01f,-4.134564e-01f,5.810756e-02f,-9.423163e-01f,8.148217e-01f,-2.877103e-01f,4.043508e-02f},
- {-9.876884e-01f,1.564343e-01f,9.632925e-01f,-4.635251e-01f,7.341509e-02f,-9.272624e-01f,9.098945e-01f,-3.625562e-01f,5.742321e-02f},
- {-9.848077e-01f,1.736484e-01f,9.547693e-01f,-5.130307e-01f,9.046126e-02f,-9.105685e-01f,1.002619e+00f,-4.454347e-01f,7.854224e-02f},
- {-9.816272e-01f,1.908091e-01f,9.453878e-01f,-5.619103e-01f,1.092244e-01f,-8.922793e-01f,1.092752e+00f,-5.360881e-01f,1.042050e-01f},
- {-9.781475e-01f,2.079115e-01f,9.351591e-01f,-6.101044e-01f,1.296816e-01f,-8.724410e-01f,1.180063e+00f,-6.342387e-01f,1.348115e-01f},
- {-9.743701e-01f,2.249510e-01f,9.240957e-01f,-6.575567e-01f,1.518089e-01f,-8.511051e-01f,1.264332e+00f,-7.395903e-01f,1.707479e-01f},
- {-9.702957e-01f,2.419219e-01f,9.122107e-01f,-7.042075e-01f,1.755787e-01f,-8.283265e-01f,1.345341e+00f,-8.518162e-01f,2.123816e-01f},
- {-9.659258e-01f,2.588191e-01f,8.995191e-01f,-7.500002e-01f,2.009620e-01f,-8.041639e-01f,1.422883e+00f,-9.705719e-01f,2.600640e-01f},
- {-9.612616e-01f,2.756374e-01f,8.860360e-01f,-7.948789e-01f,2.279279e-01f,-7.786796e-01f,1.496760e+00f,-1.095492e+00f,3.141272e-01f},
- {-9.563048e-01f,2.923716e-01f,8.717782e-01f,-8.387891e-01f,2.564435e-01f,-7.519395e-01f,1.566788e+00f,-1.226191e+00f,3.748840e-01f},
- {-9.510565e-01f,3.090171e-01f,8.567626e-01f,-8.816782e-01f,2.864747e-01f,-7.240118e-01f,1.632789e+00f,-1.362268e+00f,4.426280e-01f},
- {-9.455186e-01f,3.255681e-01f,8.410082e-01f,-9.234920e-01f,3.179837e-01f,-6.949692e-01f,1.694595e+00f,-1.503298e+00f,5.176268e-01f},
- {-9.396926e-01f,3.420202e-01f,8.245332e-01f,-9.641815e-01f,3.509334e-01f,-6.648846e-01f,1.752055e+00f,-1.648848e+00f,6.001316e-01f},
- {-9.335804e-01f,3.583678e-01f,8.073587e-01f,-1.003696e+00f,3.852825e-01f,-6.338369e-01f,1.805025e+00f,-1.798461e+00f,6.903643e-01f},
- {-9.271840e-01f,3.746064e-01f,7.895051e-01f,-1.041987e+00f,4.209899e-01f,-6.019047e-01f,1.853375e+00f,-1.951675e+00f,7.885275e-01f},
- {-9.205049e-01f,3.907311e-01f,7.709939e-01f,-1.079010e+00f,4.580124e-01f,-5.691693e-01f,1.896987e+00f,-2.108013e+00f,8.947984e-01f},
- {-9.135456e-01f,4.067366e-01f,7.518480e-01f,-1.114717e+00f,4.963039e-01f,-5.357154e-01f,1.935757e+00f,-2.266981e+00f,1.009325e+00f},
- {-9.063079e-01f,4.226184e-01f,7.320906e-01f,-1.149067e+00f,5.358188e-01f,-5.016273e-01f,1.969593e+00f,-2.428084e+00f,1.132234e+00f},
- {-8.987941e-01f,4.383712e-01f,7.117461e-01f,-1.182016e+00f,5.765077e-01f,-4.669925e-01f,1.998415e+00f,-2.590808e+00f,1.263622e+00f},
- {-8.910065e-01f,4.539906e-01f,6.908387e-01f,-1.213526e+00f,6.183225e-01f,-4.318987e-01f,2.022162e+00f,-2.754647e+00f,1.403563e+00f},
- {-8.829476e-01f,4.694716e-01f,6.693946e-01f,-1.243556e+00f,6.612108e-01f,-3.964354e-01f,2.040781e+00f,-2.919073e+00f,1.552099e+00f},
- {-8.746198e-01f,4.848095e-01f,6.474397e-01f,-1.272072e+00f,7.051207e-01f,-3.606927e-01f,2.054234e+00f,-3.083563e+00f,1.709246e+00f},
- {-8.660253e-01f,5.000000e-01f,6.250001e-01f,-1.299038e+00f,7.500000e-01f,-3.247595e-01f,2.062500e+00f,-3.247595e+00f,1.875000e+00f},
- {-8.571672e-01f,5.150381e-01f,6.021037e-01f,-1.324421e+00f,7.957926e-01f,-2.887278e-01f,2.065570e+00f,-3.410637e+00f,2.049318e+00f},
- {-8.480480e-01f,5.299194e-01f,5.787782e-01f,-1.348191e+00f,8.424437e-01f,-2.526874e-01f,2.063448e+00f,-3.572164e+00f,2.232136e+00f},
- {-8.386706e-01f,5.446391e-01f,5.550525e-01f,-1.370318e+00f,8.898951e-01f,-2.167299e-01f,2.056155e+00f,-3.731644e+00f,2.423358e+00f},
- {-8.290377e-01f,5.591928e-01f,5.309552e-01f,-1.390776e+00f,9.380897e-01f,-1.809446e-01f,2.043725e+00f,-3.888559e+00f,2.622865e+00f},
- {-8.191521e-01f,5.735765e-01f,5.065152e-01f,-1.409539e+00f,9.869699e-01f,-1.454202e-01f,2.026202e+00f,-4.042392e+00f,2.830513e+00f},
- {-8.090171e-01f,5.877852e-01f,4.817629e-01f,-1.426585e+00f,1.036474e+00f,-1.102460e-01f,2.003651e+00f,-4.192627e+00f,3.046121e+00f},
- {-7.986355e-01f,6.018150e-01f,4.567280e-01f,-1.441893e+00f,1.086544e+00f,-7.550830e-02f,1.976144e+00f,-4.338763e+00f,3.269493e+00f},
- {-7.880108e-01f,6.156614e-01f,4.314414e-01f,-1.455444e+00f,1.137117e+00f,-4.129366e-02f,1.943771e+00f,-4.480302e+00f,3.500396e+00f},
- {-7.771459e-01f,6.293205e-01f,4.059335e-01f,-1.467221e+00f,1.188133e+00f,-7.685401e-03f,1.906632e+00f,-4.616763e+00f,3.738582e+00f},
- {-7.660444e-01f,6.427876e-01f,3.802360e-01f,-1.477211e+00f,1.239528e+00f,2.523343e-02f,1.864843e+00f,-4.747667e+00f,3.983766e+00f},
- {-7.547096e-01f,6.560589e-01f,3.543800e-01f,-1.485402e+00f,1.291240e+00f,5.738307e-02f,1.818529e+00f,-4.872555e+00f,4.235647e+00f},
- {-7.431449e-01f,6.691306e-01f,3.283964e-01f,-1.491783e+00f,1.343207e+00f,8.868646e-02f,1.767831e+00f,-4.990988e+00f,4.493906e+00f},
- {-7.313538e-01f,6.819984e-01f,3.023174e-01f,-1.496346e+00f,1.395365e+00f,1.190676e-01f,1.712898e+00f,-5.102528e+00f,4.758184e+00f},
- {-7.193397e-01f,6.946585e-01f,2.761744e-01f,-1.499086e+00f,1.447651e+00f,1.484544e-01f,1.653893e+00f,-5.206765e+00f,5.028115e+00f},
- {-7.071068e-01f,7.071068e-01f,2.500000e-01f,-1.500000e+00f,1.500000e+00f,1.767767e-01f,1.590990e+00f,-5.303301e+00f,5.303301e+00f},
- {-6.946585e-01f,7.193397e-01f,2.238256e-01f,-1.499086e+00f,1.552349e+00f,2.039685e-01f,1.524373e+00f,-5.391762e+00f,5.583331e+00f},
- {-6.819984e-01f,7.313538e-01f,1.976825e-01f,-1.496346e+00f,1.604635e+00f,2.299670e-01f,1.454233e+00f,-5.471792e+00f,5.867779e+00f},
- {-6.691307e-01f,7.431448e-01f,1.716038e-01f,-1.491783e+00f,1.656792e+00f,2.547115e-01f,1.380777e+00f,-5.543053e+00f,6.156183e+00f},
- {-6.560589e-01f,7.547096e-01f,1.456200e-01f,-1.485402e+00f,1.708760e+00f,2.781472e-01f,1.304214e+00f,-5.605237e+00f,6.448089e+00f},
- {-6.427876e-01f,7.660444e-01f,1.197639e-01f,-1.477212e+00f,1.760472e+00f,3.002205e-01f,1.224767e+00f,-5.658049e+00f,6.743000e+00f},
- {-6.293203e-01f,7.771461e-01f,9.406608e-02f,-1.467221e+00f,1.811868e+00f,3.208840e-01f,1.142662e+00f,-5.701226e+00f,7.040430e+00f},
- {-6.156614e-01f,7.880108e-01f,6.855855e-02f,-1.455444e+00f,1.862883e+00f,3.400929e-01f,1.058135e+00f,-5.734527e+00f,7.339859e+00f},
- {-6.018151e-01f,7.986354e-01f,4.327216e-02f,-1.441893e+00f,1.913455e+00f,3.578070e-01f,9.714287e-01f,-5.757732e+00f,7.640767e+00f},
- {-5.877852e-01f,8.090171e-01f,1.823708e-02f,-1.426585e+00f,1.963526e+00f,3.739910e-01f,8.827875e-01f,-5.770657e+00f,7.942629e+00f},
- {-5.735764e-01f,8.191520e-01f,-6.515074e-03f,-1.409539e+00f,2.013030e+00f,3.886124e-01f,7.924678e-01f,-5.773133e+00f,8.244888e+00f},
- {-5.591928e-01f,8.290376e-01f,-3.095508e-02f,-1.390776e+00f,2.061910e+00f,4.016449e-01f,7.007229e-01f,-5.765026e+00f,8.547005e+00f},
- {-5.446391e-01f,8.386706e-01f,-5.505246e-02f,-1.370318e+00f,2.110105e+00f,4.130656e-01f,6.078163e-01f,-5.746228e+00f,8.848414e+00f},
- {-5.299193e-01f,8.480480e-01f,-7.877823e-02f,-1.348191e+00f,2.157557e+00f,4.228564e-01f,5.140093e-01f,-5.716654e+00f,9.148557e+00f},
- {-5.150380e-01f,8.571674e-01f,-1.021038e-01f,-1.324421e+00f,2.204208e+00f,4.310043e-01f,4.195672e-01f,-5.676254e+00f,9.446875e+00f},
- {-5.000001e-01f,8.660253e-01f,-1.249999e-01f,-1.299038e+00f,2.250000e+00f,4.375000e-01f,3.247599e-01f,-5.625000e+00f,9.742785e+00f},
- {-4.848095e-01f,8.746197e-01f,-1.474395e-01f,-1.272072e+00f,2.294879e+00f,4.423398e-01f,2.298521e-01f,-5.562896e+00f,1.003573e+01f},
- {-4.694715e-01f,8.829476e-01f,-1.693947e-01f,-1.243556e+00f,2.338789e+00f,4.455244e-01f,1.351145e-01f,-5.489975e+00f,1.032514e+01f},
- {-4.539906e-01f,8.910065e-01f,-1.908388e-01f,-1.213526e+00f,2.381678e+00f,4.470587e-01f,4.081347e-02f,-5.406296e+00f,1.061045e+01f},
- {-4.383711e-01f,8.987940e-01f,-2.117461e-01f,-1.182016e+00f,2.423492e+00f,4.469530e-01f,-5.278682e-02f,-5.311945e+00f,1.089110e+01f},
- {-4.226183e-01f,9.063078e-01f,-2.320906e-01f,-1.149067e+00f,2.464181e+00f,4.452218e-01f,-1.454199e-01f,-5.207041e+00f,1.116653e+01f},
- {-4.067367e-01f,9.135454e-01f,-2.518479e-01f,-1.114717e+00f,2.503696e+00f,4.418841e-01f,-2.368270e-01f,-5.091725e+00f,1.143620e+01f},
- {-3.907311e-01f,9.205048e-01f,-2.709937e-01f,-1.079010e+00f,2.541987e+00f,4.369636e-01f,-3.267503e-01f,-4.966168e+00f,1.169956e+01f},
- {-3.746066e-01f,9.271839e-01f,-2.895049e-01f,-1.041988e+00f,2.579010e+00f,4.304885e-01f,-4.149371e-01f,-4.830570e+00f,1.195608e+01f},
- {-3.583679e-01f,9.335804e-01f,-3.073587e-01f,-1.003696e+00f,2.614717e+00f,4.224911e-01f,-5.011396e-01f,-4.685155e+00f,1.220525e+01f},
- {-3.420201e-01f,9.396927e-01f,-3.245333e-01f,-9.641814e-01f,2.649067e+00f,4.130083e-01f,-5.851153e-01f,-4.530170e+00f,1.244654e+01f},
- {-3.255681e-01f,9.455186e-01f,-3.410081e-01f,-9.234920e-01f,2.682016e+00f,4.020810e-01f,-6.666291e-01f,-4.365895e+00f,1.267948e+01f},
- {-3.090170e-01f,9.510564e-01f,-3.567626e-01f,-8.816779e-01f,2.713525e+00f,3.897543e-01f,-7.454509e-01f,-4.192628e+00f,1.290358e+01f},
- {-2.923717e-01f,9.563047e-01f,-3.717781e-01f,-8.387894e-01f,2.743556e+00f,3.760769e-01f,-8.213612e-01f,-4.010692e+00f,1.311838e+01f},
- {-2.756374e-01f,9.612617e-01f,-3.860361e-01f,-7.948790e-01f,2.772072e+00f,3.611015e-01f,-8.941467e-01f,-3.820433e+00f,1.332343e+01f},
- {-2.588190e-01f,9.659258e-01f,-3.995190e-01f,-7.499999e-01f,2.799038e+00f,3.448846e-01f,-9.636030e-01f,-3.622222e+00f,1.351832e+01f},
- {-2.419219e-01f,9.702957e-01f,-4.122107e-01f,-7.042072e-01f,2.824421e+00f,3.274858e-01f,-1.029536e+00f,-3.416446e+00f,1.370262e+01f},
- {-2.249510e-01f,9.743701e-01f,-4.240956e-01f,-6.575566e-01f,2.848191e+00f,3.089685e-01f,-1.091760e+00f,-3.203517e+00f,1.387596e+01f},
- {-2.079118e-01f,9.781476e-01f,-4.351591e-01f,-6.101051e-01f,2.870318e+00f,2.893990e-01f,-1.150101e+00f,-2.983865e+00f,1.403797e+01f},
- {-1.908090e-01f,9.816272e-01f,-4.453879e-01f,-5.619099e-01f,2.890776e+00f,2.688461e-01f,-1.204397e+00f,-2.757931e+00f,1.418832e+01f},
- {-1.736482e-01f,9.848077e-01f,-4.547695e-01f,-5.130303e-01f,2.909539e+00f,2.473820e-01f,-1.254495e+00f,-2.526181e+00f,1.432668e+01f},
- {-1.564344e-01f,9.876883e-01f,-4.632923e-01f,-4.635254e-01f,2.926584e+00f,2.250811e-01f,-1.300254e+00f,-2.289093e+00f,1.445277e+01f},
- {-1.391731e-01f,9.902681e-01f,-4.709463e-01f,-4.134560e-01f,2.941893e+00f,2.020205e-01f,-1.341547e+00f,-2.047161e+00f,1.456631e+01f},
- {-1.218693e-01f,9.925461e-01f,-4.777218e-01f,-3.628827e-01f,2.955444e+00f,1.782789e-01f,-1.378258e+00f,-1.800889e+00f,1.466707e+01f},
- {-1.045285e-01f,9.945219e-01f,-4.836107e-01f,-3.118677e-01f,2.967221e+00f,1.539375e-01f,-1.410285e+00f,-1.550796e+00f,1.475483e+01f},
- {-8.715577e-02f,9.961947e-01f,-4.886058e-01f,-2.604724e-01f,2.977212e+00f,1.290786e-01f,-1.437538e+00f,-1.297406e+00f,1.482941e+01f},
- {-6.975648e-02f,9.975641e-01f,-4.927011e-01f,-2.087597e-01f,2.985402e+00f,1.037861e-01f,-1.459940e+00f,-1.041256e+00f,1.489065e+01f},
- {-5.233594e-02f,9.986295e-01f,-4.958915e-01f,-1.567926e-01f,2.991783e+00f,7.814553e-02f,-1.477429e+00f,-7.828888e-01f,1.493841e+01f},
- {-3.489946e-02f,9.993909e-01f,-4.981730e-01f,-1.046346e-01f,2.996346e+00f,5.224292e-02f,-1.489957e+00f,-5.228543e-01f,1.497260e+01f},
- {-1.745235e-02f,9.998478e-01f,-4.995431e-01f,-5.234908e-02f,2.999086e+00f,2.616524e-02f,-1.497488e+00f,-2.617055e-01f,1.499315e+01f},
- {-4.371139e-08f,1.000000e+00f,-5.000000e-01f,-1.311342e-07f,3.000000e+00f,6.556709e-08f,-1.500000e+00f,-6.556709e-07f,1.500000e+01f}
-};
-
-const float dirac_gains_trg_term[181][2] =
-{
- {-1.000000e+00f,8.742278e-08f},
- {-9.998477e-01f,-1.745246e-02f},
- {-9.993908e-01f,-3.489945e-02f},
- {-9.986295e-01f,-5.233605e-02f},
- {-9.975641e-01f,-6.975647e-02f},
- {-9.961947e-01f,-8.715564e-02f},
- {-9.945219e-01f,-1.045285e-01f},
- {-9.925461e-01f,-1.218693e-01f},
- {-9.902681e-01f,-1.391732e-01f},
- {-9.876884e-01f,-1.564344e-01f},
- {-9.848077e-01f,-1.736483e-01f},
- {-9.816272e-01f,-1.908090e-01f},
- {-9.781476e-01f,-2.079116e-01f},
- {-9.743701e-01f,-2.249511e-01f},
- {-9.702957e-01f,-2.419219e-01f},
- {-9.659258e-01f,-2.588191e-01f},
- {-9.612617e-01f,-2.756374e-01f},
- {-9.563048e-01f,-2.923716e-01f},
- {-9.510565e-01f,-3.090170e-01f},
- {-9.455186e-01f,-3.255681e-01f},
- {-9.396926e-01f,-3.420202e-01f},
- {-9.335805e-01f,-3.583679e-01f},
- {-9.271839e-01f,-3.746065e-01f},
- {-9.205049e-01f,-3.907312e-01f},
- {-9.135455e-01f,-4.067366e-01f},
- {-9.063078e-01f,-4.226183e-01f},
- {-8.987941e-01f,-4.383711e-01f},
- {-8.910065e-01f,-4.539906e-01f},
- {-8.829476e-01f,-4.694716e-01f},
- {-8.746198e-01f,-4.848095e-01f},
- {-8.660254e-01f,-5.000001e-01f},
- {-8.571673e-01f,-5.150380e-01f},
- {-8.480480e-01f,-5.299193e-01f},
- {-8.386706e-01f,-5.446390e-01f},
- {-8.290377e-01f,-5.591928e-01f},
- {-8.191521e-01f,-5.735765e-01f},
- {-8.090171e-01f,-5.877852e-01f},
- {-7.986355e-01f,-6.018151e-01f},
- {-7.880108e-01f,-6.156614e-01f},
- {-7.771459e-01f,-6.293205e-01f},
- {-7.660444e-01f,-6.427876e-01f},
- {-7.547097e-01f,-6.560590e-01f},
- {-7.431448e-01f,-6.691306e-01f},
- {-7.313537e-01f,-6.819983e-01f},
- {-7.193397e-01f,-6.946585e-01f},
- {-7.071068e-01f,-7.071068e-01f},
- {-6.946585e-01f,-7.193397e-01f},
- {-6.819983e-01f,-7.313537e-01f},
- {-6.691307e-01f,-7.431448e-01f},
- {-6.560590e-01f,-7.547097e-01f},
- {-6.427876e-01f,-7.660444e-01f},
- {-6.293203e-01f,-7.771460e-01f},
- {-6.156614e-01f,-7.880108e-01f},
- {-6.018151e-01f,-7.986355e-01f},
- {-5.877852e-01f,-8.090170e-01f},
- {-5.735765e-01f,-8.191520e-01f},
- {-5.591928e-01f,-8.290376e-01f},
- {-5.446391e-01f,-8.386706e-01f},
- {-5.299193e-01f,-8.480480e-01f},
- {-5.150380e-01f,-8.571673e-01f},
- {-5.000001e-01f,-8.660254e-01f},
- {-4.848095e-01f,-8.746197e-01f},
- {-4.694716e-01f,-8.829476e-01f},
- {-4.539906e-01f,-8.910065e-01f},
- {-4.383711e-01f,-8.987941e-01f},
- {-4.226183e-01f,-9.063078e-01f},
- {-4.067367e-01f,-9.135454e-01f},
- {-3.907312e-01f,-9.205049e-01f},
- {-3.746066e-01f,-9.271839e-01f},
- {-3.583679e-01f,-9.335805e-01f},
- {-3.420201e-01f,-9.396926e-01f},
- {-3.255681e-01f,-9.455186e-01f},
- {-3.090170e-01f,-9.510565e-01f},
- {-2.923717e-01f,-9.563047e-01f},
- {-2.756374e-01f,-9.612617e-01f},
- {-2.588190e-01f,-9.659258e-01f},
- {-2.419219e-01f,-9.702957e-01f},
- {-2.249510e-01f,-9.743701e-01f},
- {-2.079117e-01f,-9.781476e-01f},
- {-1.908090e-01f,-9.816272e-01f},
- {-1.736482e-01f,-9.848077e-01f},
- {-1.564344e-01f,-9.876884e-01f},
- {-1.391731e-01f,-9.902681e-01f},
- {-1.218693e-01f,-9.925461e-01f},
- {-1.045285e-01f,-9.945219e-01f},
- {-8.715577e-02f,-9.961947e-01f},
- {-6.975648e-02f,-9.975641e-01f},
- {-5.233594e-02f,-9.986295e-01f},
- {-3.489946e-02f,-9.993908e-01f},
- {-1.745235e-02f,-9.998477e-01f},
- {-4.371139e-08f,-1.000000e+00f},
- {1.745238e-02f,-9.998477e-01f},
- {3.489950e-02f,-9.993908e-01f},
- {5.233597e-02f,-9.986295e-01f},
- {6.975651e-02f,-9.975641e-01f},
- {8.715580e-02f,-9.961947e-01f},
- {1.045284e-01f,-9.945219e-01f},
- {1.218693e-01f,-9.925461e-01f},
- {1.391731e-01f,-9.902681e-01f},
- {1.564345e-01f,-9.876884e-01f},
- {1.736482e-01f,-9.848077e-01f},
- {1.908089e-01f,-9.816272e-01f},
- {2.079117e-01f,-9.781476e-01f},
- {2.249510e-01f,-9.743701e-01f},
- {2.419219e-01f,-9.702957e-01f},
- {2.588191e-01f,-9.659258e-01f},
- {2.756374e-01f,-9.612617e-01f},
- {2.923717e-01f,-9.563048e-01f},
- {3.090170e-01f,-9.510565e-01f},
- {3.255681e-01f,-9.455186e-01f},
- {3.420202e-01f,-9.396926e-01f},
- {3.583680e-01f,-9.335804e-01f},
- {3.746066e-01f,-9.271839e-01f},
- {3.907311e-01f,-9.205049e-01f},
- {4.067366e-01f,-9.135455e-01f},
- {4.226182e-01f,-9.063078e-01f},
- {4.383712e-01f,-8.987941e-01f},
- {4.539905e-01f,-8.910065e-01f},
- {4.694716e-01f,-8.829476e-01f},
- {4.848096e-01f,-8.746197e-01f},
- {5.000000e-01f,-8.660254e-01f},
- {5.150381e-01f,-8.571673e-01f},
- {5.299193e-01f,-8.480481e-01f},
- {5.446390e-01f,-8.386706e-01f},
- {5.591929e-01f,-8.290375e-01f},
- {5.735765e-01f,-8.191521e-01f},
- {5.877852e-01f,-8.090170e-01f},
- {6.018150e-01f,-7.986355e-01f},
- {6.156615e-01f,-7.880107e-01f},
- {6.293204e-01f,-7.771460e-01f},
- {6.427876e-01f,-7.660444e-01f},
- {6.560590e-01f,-7.547095e-01f},
- {6.691306e-01f,-7.431449e-01f},
- {6.819984e-01f,-7.313537e-01f},
- {6.946584e-01f,-7.193398e-01f},
- {7.071068e-01f,-7.071068e-01f},
- {7.193398e-01f,-6.946584e-01f},
- {7.313537e-01f,-6.819983e-01f},
- {7.431448e-01f,-6.691306e-01f},
- {7.547096e-01f,-6.560590e-01f},
- {7.660444e-01f,-6.427876e-01f},
- {7.771460e-01f,-6.293204e-01f},
- {7.880108e-01f,-6.156615e-01f},
- {7.986355e-01f,-6.018150e-01f},
- {8.090170e-01f,-5.877852e-01f},
- {8.191521e-01f,-5.735765e-01f},
- {8.290376e-01f,-5.591929e-01f},
- {8.386706e-01f,-5.446391e-01f},
- {8.480481e-01f,-5.299193e-01f},
- {8.571673e-01f,-5.150381e-01f},
- {8.660254e-01f,-5.000000e-01f},
- {8.746197e-01f,-4.848096e-01f},
- {8.829476e-01f,-4.694716e-01f},
- {8.910065e-01f,-4.539905e-01f},
- {8.987941e-01f,-4.383712e-01f},
- {9.063078e-01f,-4.226183e-01f},
- {9.135454e-01f,-4.067366e-01f},
- {9.205049e-01f,-3.907311e-01f},
- {9.271839e-01f,-3.746066e-01f},
- {9.335804e-01f,-3.583679e-01f},
- {9.396926e-01f,-3.420201e-01f},
- {9.455186e-01f,-3.255681e-01f},
- {9.510565e-01f,-3.090170e-01f},
- {9.563048e-01f,-2.923717e-01f},
- {9.612617e-01f,-2.756374e-01f},
- {9.659258e-01f,-2.588190e-01f},
- {9.702957e-01f,-2.419219e-01f},
- {9.743701e-01f,-2.249510e-01f},
- {9.781476e-01f,-2.079117e-01f},
- {9.816272e-01f,-1.908090e-01f},
- {9.848077e-01f,-1.736482e-01f},
- {9.876884e-01f,-1.564345e-01f},
- {9.902681e-01f,-1.391731e-01f},
- {9.925461e-01f,-1.218693e-01f},
- {9.945219e-01f,-1.045285e-01f},
- {9.961947e-01f,-8.715574e-02f},
- {9.975641e-01f,-6.975647e-02f},
- {9.986295e-01f,-5.233596e-02f},
- {9.993908e-01f,-3.489950e-02f},
- {9.998477e-01f,-1.745241e-02f},
- {1.000000e+00f,0.000000e+00f}
-};
-
/*----------------------------------------------------------------------------------*
* FB ROM tables
*----------------------------------------------------------------------------------*/
diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h
index 662dc81a9ba23ba6696e520d350c227b0139c1eb..b58e183ebda207962993ac3a75678cbc2ef4ce1d 100644
--- a/lib_com/ivas_rom_com.h
+++ b/lib_com/ivas_rom_com.h
@@ -78,8 +78,6 @@ extern const UWord16 ECSQ_tab_inverse[1 + ECSQ_SEGMENT_SIZE];
/*----------------------------------------------------------------------------------*
* Stereo ICA ROM tables
*----------------------------------------------------------------------------------*/
-extern const float ica_sincInterp4[];
-extern const float ica_sincInterp2[];
extern const Word16 tdm_bit_allc_tbl[5][6];
/* LSFs Intra-frame prediction tables */
@@ -100,11 +98,6 @@ extern const Word16 tdm_LSF_MEAN_PRED_QNT_fx[M];
extern const Word16 tdm_PRED_QNT_fixed_beta_prd_diag_3_fx[15 + 16 + 15];
-extern const float tdm_LSF_MEAN_PRED_QNT_OUT[M];
-extern const float tdm_LSF_MEAN_PRED_QNT_IN[M];
-extern const float tdm_LSF_MEAN_PRED_QNT[M];
-extern const float tdm_PRED_QNT_fixed_beta_prd_diag_3[15 + 16 + 15];
-
extern const Word16 fast_FCB_bits_2sfr[];
extern const Word16 fast_FCB_rates_2sfr[];
@@ -288,9 +281,6 @@ extern const ivas_lfe_freq_models ivas_str_lfe_freq_models;
extern const Word16 ivas_lfe_lpf_delay_Q15[2];
extern const Word16 dirac_gains_P_idx[16];
-extern const float dirac_gains_norm_term[9];
-extern const float dirac_gains_Pnm[91][9];
-extern const float dirac_gains_trg_term[181][2];
/*------------------------------------------------------------------------------------------*
* FB ROM tables
diff --git a/lib_com/ivas_sns_com.c b/lib_com/ivas_sns_com.c
deleted file mode 100644
index cf7ec8348361a485a60ddd8a89fc2d73ea07ee41..0000000000000000000000000000000000000000
--- a/lib_com/ivas_sns_com.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "ivas_prot.h"
-#include "rom_com.h"
-#include "ivas_rom_com.h"
-#include
-#include
-#include "wmc_auto.h"
-
-#ifndef IVAS_FLOAT_FIXED
-/*-------------------------------------------------------------------
- * sns_compute_scf()
- *
- *
- *-------------------------------------------------------------------*/
-
-void sns_compute_scf(
- float spectrum[],
- const PsychoacousticParameters *pPsychParams,
- const int16_t L_frame,
- float *scf )
-{
- int16_t i, n, k;
- float x[FDNS_NPTS], xs[FDNS_NPTS], sum, mean, xl4[SNS_NPTS], nf, xl[FDNS_NPTS];
- float tilt;
- const uint8_t nBands = pPsychParams->nBands;
- const uint8_t *bandLengths = pPsychParams->bandLengths;
- int8_t bw = 0;
-
-
- const float w_0 = 1.0f / 12.0f;
- const float w_1 = 2.0f / 12.0f;
- const float w_2 = 0.25f; /* 3.0f / 12.0f */
- const float w_3 = w_2;
- const float w_4 = w_1;
- const float w_5 = w_0;
-
- const float scale_log = INV_LOG_2 * 0.5f;
-
- assert( nBands == FDNS_NPTS );
-
- set_f( x, 0.0f, FDNS_NPTS );
-
- if ( bandLengths == NULL )
- {
- bw = (int8_t) ( L_frame / nBands );
- /* Energy per band */
- k = 0;
- for ( i = 0; i < nBands; ++i )
- {
- x[i] = 0.0f;
- for ( n = 0; n < bw; ++n, ++k )
- {
- x[i] += spectrum[k];
- }
- x[i] /= bw;
- }
- }
- else
- {
- /* Energy per band */
- k = 0;
- for ( i = 0; i < nBands; ++i )
- {
- x[i] = 0.0f;
- for ( n = 0; n < bandLengths[i]; ++n, ++k )
- {
- x[i] += spectrum[k];
- }
- x[i] /= bandLengths[i];
- }
- }
-
- /* Smoothing */
- xs[0] = 0.75f * x[0] + 0.25f * x[1];
-
- for ( i = 1; i < FDNS_NPTS - 1; i++ )
- {
- xs[i] = 0.5f * x[i] + 0.25f * x[i - 1] + 0.25f * x[i + 1];
- }
-
- xs[FDNS_NPTS - 1] = 0.75f * x[FDNS_NPTS - 1] + 0.25f * x[FDNS_NPTS - 2];
-
- /* Pre-emphasis */
- switch ( L_frame )
- {
- case L_FRAME16k:
- tilt = 19.f;
- break;
- case L_FRAME25_6k:
- tilt = 22.f;
- break;
- case L_FRAME32k:
- tilt = 23.5f;
- break;
- default:
- tilt = 0.f;
- assert( !"illegal frame length in sns_compute_scf" );
- }
-
- for ( i = 0; i < FDNS_NPTS; i++ )
- {
- xs[i] = xs[i] * powf( 10.0f, (float) i * (float) tilt / ( (float) FDNS_NPTS - 1.0f ) / 10.0f );
- }
-
- /* Noise floor at -40dB */
- sum = sum_f( xs, FDNS_NPTS );
- mean = sum / FDNS_NPTS;
-
- nf = mean * powf( 10.0f, -4.0f );
- nf = max( nf, powf( 2.0f, -32.0f ) );
-
-
- for ( i = 0; i < FDNS_NPTS; i++ )
- {
- if ( xs[i] < nf )
- {
- xs[i] = nf;
- }
- }
-
- /* Log-domain */
- for ( i = 0; i < FDNS_NPTS; i++ )
- {
- xl[i] = logf( xs[i] ) * scale_log;
- }
-
- /* Downsampling */
- xl4[0] = w_0 * xl[0] +
- w_1 * xl[0] +
- w_2 * xl[1] +
- w_3 * xl[2] +
- w_4 * xl[3] +
- w_5 * xl[4];
-
-
- for ( n = 1; n < SNS_NPTS - 1; n++ )
- {
- int16_t n4 = 4 * n;
- xl4[n] = w_0 * xl[n4 - 1] +
- w_1 * xl[n4] +
- w_2 * xl[n4 + 1] +
- w_3 * xl[n4 + 2] +
- w_4 * xl[n4 + 3] +
- w_5 * xl[n4 + 4];
- }
-
- xl4[SNS_NPTS - 1] = w_0 * xl[FDNS_NPTS - 5] +
- w_1 * xl[FDNS_NPTS - 4] +
- w_2 * xl[FDNS_NPTS - 3] +
- w_3 * xl[FDNS_NPTS - 2] +
- w_4 * xl[FDNS_NPTS - 1] +
- w_5 * xl[FDNS_NPTS - 1];
-
- /* Remove mean and scaling */
- sum = sum_f( xl4, SNS_NPTS );
- mean = sum / SNS_NPTS;
-
- for ( i = 0; i < SNS_NPTS; i++ )
- {
- scf[i] = 0.85f * ( xl4[i] - mean );
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------
- * sns_interpolate_scalefactors()
- *
- *
- *-------------------------------------------------------------------*/
-
-void sns_interpolate_scalefactors(
- float *scf_int, /* o : interpolated scalefactors for spectrum shaping*/
- const float *scf, /* i : sns scalefactors as derived from the signal or read from the bitstream */
- int16_t encoder_side /* i : flag, if scalefactors have to be inverted */
-)
-{
- int16_t n;
-
- /* Interpolation */
- scf_int[0] = scf[0];
- scf_int[1] = scf[0];
-
- for ( n = 0; n <= M - 2; n++ )
- {
- scf_int[n * 4 + 2] = scf[n] + ( scf[n + 1] - scf[n] ) / 8.f;
- scf_int[n * 4 + 3] = scf[n] + 3.f * ( scf[n + 1] - scf[n] ) / 8.f;
- scf_int[n * 4 + 4] = scf[n] + 5.f * ( scf[n + 1] - scf[n] ) / 8.f;
- scf_int[n * 4 + 5] = scf[n] + 7.f * ( scf[n + 1] - scf[n] ) / 8.f;
- }
-
- scf_int[FDNS_NPTS - 2] = scf[M - 1] + ( scf[M - 1] - scf[M - 2] ) / 8.f;
- scf_int[FDNS_NPTS - 1] = scf[M - 1] + 3.f * ( scf[M - 1] - scf[M - 2] ) / 8.f;
-
- /* Inversion at encoder-side */
- if ( encoder_side == ENC )
- {
- for ( n = 0; n < FDNS_NPTS; n++ )
- {
- scf_int[n] = -scf_int[n];
- }
- }
-
- /* Linear domain */
- for ( n = 0; n < FDNS_NPTS; n++ )
- {
- scf_int[n] = powf( 2.f, scf_int[n] );
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------
- * sns_shape_spectrum()
- *
- *
- *-------------------------------------------------------------------*/
-
-void sns_shape_spectrum(
- float spectrum[], /* i/o: spectrum to be shaped */
- const PsychoacousticParameters *pPsychParams, /* i : psychoacoustic parameters used to get the frequency bands */
- const float *scf_int, /* i : already interpolated SNS scalefactors */
- const int16_t L_frame /* i : frame length */
-)
-{
- int16_t i, n, k, bw;
- const uint8_t nBands = pPsychParams->nBands;
- const uint8_t *bandLengths = pPsychParams->bandLengths;
-
- if ( bandLengths == NULL )
- {
- bw = L_frame / nBands;
-
- /* Shape spectrum */
- k = 0;
- for ( i = 0; i < nBands; ++i )
- {
- for ( n = 0; n < bw; ++n, ++k )
- {
- spectrum[k] *= scf_int[i];
- }
- }
- }
- else
- {
- /* Shape spectrum */
- k = 0;
- for ( i = 0; i < nBands; ++i )
- {
- for ( n = 0; n < bandLengths[i]; ++n, ++k )
- {
- spectrum[k] *= scf_int[i];
- }
- }
- }
-
- return;
-}
-#endif
diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c
index 7ab41d5edd70313a46658b38f859772a1d34005a..362c1c9ed71a7328f4184d0f5c73d0fbd563290d 100644
--- a/lib_com/ivas_spar_com.c
+++ b/lib_com/ivas_spar_com.c
@@ -2633,7 +2633,11 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
test();
IF( W_norm( re ) == 0 || W_norm( recon_uu_re[i][j] ) == 0 )
{
+#ifdef FIX_ISSUE_1122
+ recon_uu_re[i][j] = L_shr( recon_uu_re[i][j], 1 ); // q_recon_uu_re[i][j] - 1
+#else
re1[m] = L_shr( re1[m], 1 ); // q_recon_uu_re[i][j]-1
+#endif
move32();
q_recon_uu_re[i][j] = sub( q_recon_uu_re[i][j], 1 );
move16();
diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c
index 943d0062051932db768e7e1f5c60d8806a0e9cd0..5738b6feb7715c9474c06907d2ae9b6e3e46186a 100644
--- a/lib_com/ivas_tools.c
+++ b/lib_com/ivas_tools.c
@@ -51,24 +51,6 @@
* sum of absolute values
* ---------------------------------------------------------------*/
-/*! r: sum abs of all vector elements */
-float sumAbs(
- const float *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-)
-{
- int16_t i;
- float tmp;
-
- tmp = 0.0f;
- for ( i = 0; i < lvec; i++ )
- {
- tmp += fabsf( vec[i] );
- }
-
- return tmp;
-}
-
Word32 sumAbs_fx(
const Word32 *vec, /* i : input vector Qx*/
const Word16 lvec /* i : length of input vector Q0*/
@@ -94,31 +76,33 @@ Word32 sumAbs_fx(
*---------------------------------------------------------------------*/
void mvc2c(
- const uint8_t x[], /* i : input vector */
- uint8_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
+ const UWord8 x[], /* i : input vector */
+ UWord8 y[], /* o : output vector */
+ const Word16 n /* i : vector size */
)
{
- int16_t i;
+ Word16 i;
- if ( n <= 0 )
+ IF( n <= 0 )
{
/* no need to transfer vectors with size 0 */
return;
}
- if ( y < x )
+ IF( y < x )
{
- for ( i = 0; i < n; i++ )
+ FOR( i = 0; i < n; i++ )
{
y[i] = x[i];
+ move16();
}
}
- else
+ ELSE
{
- for ( i = n - 1; i >= 0; i-- )
+ FOR( i = n - 1; i >= 0; i-- )
{
y[i] = x[i];
+ move16();
}
}
@@ -134,34 +118,6 @@ void mvc2c(
*-------------------------------------------------------------------*/
/*! r: number of clipped samples */
-uint32_t ivas_syn_output(
- float *synth[], /* i/o: float synthesis signal */
- const int16_t output_frame, /* i : output frame length (one channel) */
- const int16_t n_channels, /* i : number of output channels */
- int16_t *synth_out /* o : integer 16 bits synthesis signal */
-)
-{
- int16_t i, n;
- int16_t synth_loc[MAX_JBM_L_FRAME48k];
- uint32_t noClipping = 0;
-
- /*-----------------------------------------------------------------*
- * float to integer conversion with saturation control
- *-----------------------------------------------------------------*/
-
- for ( n = 0; n < n_channels; n++ )
- {
- noClipping += mvr2s( synth[n], synth_loc, output_frame );
-
- for ( i = 0; i < output_frame; i++ )
- {
- synth_out[i * n_channels + n] = synth_loc[i];
- }
- }
-
- return noClipping;
-}
-
UWord32 ivas_syn_output_fx(
Word32 *synth[], /* i/o: float synthesis signal q_synth*/
const Word16 q_synth,
@@ -204,30 +160,6 @@ UWord32 ivas_syn_output_fx(
*-------------------------------------------------------------------*/
/*! r: number of clipped samples */
-void ivas_syn_output_f(
- float *synth[], /* i/o: float synthesis signal */
- const int16_t output_frame, /* i : output frame length (one channel) */
- const int16_t n_channels, /* i : number of output channels */
- float *synth_out /* o : integer 16 bits synthesis signal */
-)
-{
- int16_t i, n;
-
- /*-----------------------------------------------------------------*
- * float to integer conversion with saturation control
- *-----------------------------------------------------------------*/
-
- for ( n = 0; n < n_channels; n++ )
- {
- for ( i = 0; i < output_frame; i++ )
- {
- synth_out[i * n_channels + n] = synth[n][i];
- }
- }
-
- return;
-}
-
void ivas_syn_output_f_fx(
Word32 *synth[], /* i/o: float synthesis signal Q11*/
const Word16 output_frame, /* i : output frame length (one channel) Q0*/
@@ -288,8 +220,8 @@ void mvr2r_inc_fixed_one(
y_fx[iy] = x_fx[ix]; /*Q29*/
move32();
- ix = add( ix, x_inc );
- iy = add( iy, y_inc );
+ ix = ix + x_inc;
+ iy = iy + y_inc;
}
}
ELSE
@@ -301,8 +233,8 @@ void mvr2r_inc_fixed_one(
y_fx[iy] = x_fx[ix]; /*Q29*/
move32();
- ix = sub( ix, x_inc );
- iy = sub( iy, y_inc );
+ ix = ix - x_inc;
+ iy = iy - y_inc;
}
}
@@ -338,8 +270,8 @@ void mvr2r_inc_fixed(
y_fx[iy] = x_fx[ix]; /*Q29*/
move32();
- ix = add( ix, x_inc );
- iy = add( iy, y_inc );
+ ix = ix + x_inc;
+ iy = iy + y_inc;
}
}
ELSE
@@ -351,52 +283,8 @@ void mvr2r_inc_fixed(
y_fx[iy] = x_fx[ix]; /*Q29*/
move32();
- ix = sub( ix, x_inc );
- iy = sub( iy, y_inc );
- }
- }
-
- return;
-}
-
-void mvr2r_inc(
- const float x[], /* i : input vector */
- const int16_t x_inc, /* i : increment for vector x[] */
- float y[], /* o : output vector */
- const int16_t y_inc, /* i : increment for vector y[] */
- const int16_t n /* i : vector size */
-)
-{
- int16_t i;
- int16_t ix;
- int16_t iy;
-
- if ( n <= 0 )
- {
- /* cannot transfer vectors with size 0 */
- return;
- }
-
- if ( y < x )
- {
- ix = 0;
- iy = 0;
- for ( i = 0; i < n; i++ )
- {
- y[iy] = x[ix];
- ix += x_inc;
- iy += y_inc;
- }
- }
- else
- {
- ix = ( n - 1 ) * x_inc;
- iy = ( n - 1 ) * y_inc;
- for ( i = n - 1; i >= 0; i-- )
- {
- y[iy] = x[ix];
- ix -= x_inc;
- iy -= y_inc;
+ ix = ix - x_inc;
+ iy = iy - y_inc;
}
}
@@ -409,32 +297,6 @@ void mvr2r_inc(
* Addition of two vectors sample by sample with explicit increments
*-------------------------------------------------------------------*/
-void v_add_inc(
- const float x1[], /* i : Input vector 1 */
- const int16_t x_inc, /* i : Increment for input vector 1 */
- const float x2[], /* i : Input vector 2 */
- const int16_t x2_inc, /* i : Increment for input vector 2 */
- float y[], /* o : Output vector that contains vector 1 + vector 2 */
- const int16_t y_inc, /* i : increment for vector y[] */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
- int16_t ix1 = 0;
- int16_t ix2 = 0;
- int16_t iy = 0;
-
- for ( i = 0; i < N; i++ )
- {
- y[iy] = x1[ix1] + x2[ix2];
- ix1 += x_inc;
- ix2 += x2_inc;
- iy += y_inc;
- }
-
- return;
-}
-
// for same q//
void v_add_inc_fx(
const Word32 x1[], /* i : Input vector 1 Qx*/
@@ -446,10 +308,35 @@ void v_add_inc_fx(
const Word16 N /* i : Vector length Q0*/
)
{
+#ifndef FIX_1107_VADDINC
Word16 i;
Word16 ix1 = 0;
Word16 ix2 = 0;
Word16 iy = 0;
+#else
+ Word16 i, ix1, ix2, iy;
+
+ /* The use of this function is currently always for the interleaved input format, */
+ /* that means, the following conditions are always true and thus obsolete. */
+ test();
+ test();
+ test();
+ test();
+ IF( ( sub( x_inc, 2 ) == 0 ) && ( sub( x2_inc, 2 ) == 0 ) && ( sub( y_inc, 1 ) == 0 ) && ( &x1[1] == &x2[0] ) )
+ {
+ /* Interleaved input case, linear output */
+ FOR( i = 0; i < N; i++ )
+ {
+ y[i] = L_add( x1[2 * i + 0], x1[2 * i + 1] ); /*Qx*/
+ move32();
+ }
+ return;
+ }
+
+ ix1 = 0;
+ ix2 = 0;
+ iy = 0;
+#endif
move16();
move16();
move16();
@@ -540,38 +427,6 @@ void v_mult_inc_fixed(
return;
}
-/*-------------------------------------------------------------------*
- * v_mult_inc()
- *
- * Multiplication of two vectors with explicit increments
- *-------------------------------------------------------------------*/
-
-void v_mult_inc(
- const float x1[], /* i : Input vector 1 */
- const int16_t x1_inc, /* i : Increment for input vector 1 */
- const float x2[], /* i : Input vector 2 */
- const int16_t x2_inc, /* i : Increment for input vector 1 */
- float y[], /* o : Output vector that contains vector 1 .* vector 2 */
- const int16_t y_inc, /* i : increment for vector y[i] */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
- int16_t ix1 = 0;
- int16_t ix2 = 0;
- int16_t iy = 0;
-
- for ( i = 0; i < N; i++ )
- {
- y[iy] = x1[ix1] * x2[ix2];
- ix1 += x1_inc;
- ix2 += x2_inc;
- iy += y_inc;
- }
-
- return;
-}
-
/*-------------------------------------------------------------------*
* v_addc_fx()
*
@@ -618,23 +473,6 @@ void v_addc_fixed(
return;
}
-void v_addc(
- const float x[], /* i : Input vector */
- const float c, /* i : Constant */
- float y[], /* o : Output vector that contains c*x */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = c + x[i];
- }
-
- return;
-}
-
/*-------------------------------------------------------------------*
* v_min_fx()
*
@@ -693,29 +531,6 @@ void v_min_fx(
return;
}
-/*-------------------------------------------------------------------*
- * v_min()
- *
- * minimum of two vectors
- *-------------------------------------------------------------------*/
-
-void v_min(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 .* vector 2 */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = ( x1[i] < x2[i] ) ? x1[i] : x2[i];
- }
-
- return;
-}
-
/*-------------------------------------------------------------------*
* v_sqrt()
@@ -740,23 +555,6 @@ void v_sqrt_fx(
return;
}
-void v_sqrt(
- const float x[], /* i : Input vector */
- float y[], /* o : Output vector that contains sqrt(x) */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = sqrtf( x[i] );
- }
-
- return;
-}
-
-
/*-------------------------------------------------------------------*
* v_sub_s()
*
@@ -800,24 +598,6 @@ void v_sub32_fx(
return;
}
-void v_sub_s(
- const int16_t x1[], /* i : Input vector 1 */
- const int16_t x2[], /* i : Input vector 2 */
- int16_t y[], /* o : Output vector that contains vector 1 - vector 2 */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = x1[i] - x2[i];
- }
-
- return;
-}
-
-
/*---------------------------------------------------------------------*
* dot_product_cholesky()
*
@@ -827,34 +607,6 @@ void v_sub_s(
*---------------------------------------------------------------------*/
/*! r: the dot product x'*A*A'*x */
-float dot_product_cholesky(
- const float *x, /* i : vector x */
- const float *A, /* i : Cholesky matrix A */
- const int16_t N /* i : vector & matrix size */
-)
-{
- int16_t i, j;
- float suma, tmp_sum;
- const float *pt_x, *pt_A;
-
- pt_A = A;
- suma = 0;
-
- for ( i = 0; i < N; i++ )
- {
- tmp_sum = 0;
- pt_x = x;
- for ( j = 0; j <= i; j++ )
- {
- float mul = *pt_x++ * *pt_A++;
- tmp_sum += mul;
- }
-
- suma += tmp_sum * tmp_sum;
- }
-
- return suma;
-}
Word32 dot_product_cholesky_fixed(
const Word32 *x, /* i : vector x Q31 - exp_x*/
const Word32 *A, /* i : Cholesky matrix A Q31 - exp_A*/
@@ -1024,47 +776,6 @@ void v_mult_mat_fx(
return;
}
-/*---------------------------------------------------------------------*
- * v_mult_mat()
- *
- * Multiplication of row vector x by matrix A, where x has size Nr and
- * A has size Nr x Nc ans it is stored column-wise in memory.
- * The resulting row vector y has size Nc
- *---------------------------------------------------------------------*/
-
-void v_mult_mat(
- float *y, /* o : the product x*A */
- const float *x, /* i : vector x */
- const float *A, /* i : matrix A */
- const int16_t Nr, /* i : number of rows */
- const int16_t Nc /* i : number of columns */
-)
-{
- int16_t i, j;
-
- const float *pt_x, *pt_A;
- float tmp_y[MAX_V_MULT_MAT];
- float *pt_y;
-
- pt_y = tmp_y;
- pt_A = A;
-
- for ( i = 0; i < Nc; i++ )
- {
- pt_x = x;
- *pt_y = 0;
- for ( j = 0; j < Nr; j++ )
- {
- *pt_y += ( *pt_x++ ) * ( *pt_A++ );
- }
- pt_y++;
- }
-
- mvr2r( tmp_y, y, Nc );
-
- return;
-}
-
/*---------------------------------------------------------------------*
* logsumexp()
@@ -1073,32 +784,6 @@ void v_mult_mat(
*---------------------------------------------------------------------*/
/*! r: log(sum(exp(x)) of the input array x */
-float logsumexp(
- const float x[], /* i : input array x */
- const int16_t N /* i : number of elements in array x */
-)
-{
- float max_exp;
- float sum;
- int16_t i;
-
- max_exp = x[0];
- sum = 0;
- for ( i = 1; i < N; i++ )
- {
- if ( x[i] > max_exp )
- {
- max_exp = x[i];
- }
- }
-
- for ( i = 0; i < N; i++ )
- {
- sum += expf( x[i] - max_exp );
- }
-
- return logf( sum ) + max_exp;
-}
Word32 logsumexp_fx(
const Word32 x[], /* i : input array x Q31 - x_e*/
const Word16 x_e,
@@ -1188,76 +873,13 @@ Word32 lin_interp32_fx(
return temp32; /*Q_io*/
}
-/*! r: mapped output value */
-float lin_interp(
- const float x, /* i : the value to be mapped */
- const float x1, /* i : source range interval: low end */
- const float y1, /* i : source range interval: high end */
- const float x2, /* i : target range interval: low */
- const float y2, /* i : target range interval: high */
- const int16_t flag_sat /* i : flag to indicate whether to apply saturation */
-)
-{
- if ( x2 - x1 == 0 )
- {
- return y1;
- }
- else if ( flag_sat )
- {
- if ( x >= max( x1, x2 ) )
- {
- return x1 > x2 ? y1 : y2;
- }
- else if ( x <= min( x1, x2 ) )
- {
- return x1 < x2 ? y1 : y2;
- }
- }
-
- return y1 + ( x - x1 ) * ( y2 - y1 ) / ( x2 - x1 );
-}
-
-
/*-------------------------------------------------------------------*
- * check_bounds()
+ * check_bounds_s_fx()
*
* Ensure the input value is within the given limits
*-------------------------------------------------------------------*/
/*! r: Adjusted value */
-float check_bounds(
- const float value, /* i : Input value */
- const float low, /* i : Low limit */
- const float high /* i : High limit */
-)
-{
- float value_adj;
-
- value_adj = min( max( value, low ), high );
-
- return value_adj;
-}
-
-
-/*-------------------------------------------------------------------*
- * check_bounds_s()
- *
- * Ensure the input value is within the given limits
- *-------------------------------------------------------------------*/
-
-/*! r: Adjusted value */
-int16_t check_bounds_s(
- const int16_t value, /* i : Input value */
- const int16_t low, /* i : Low limit */
- const int16_t high /* i : High limit */
-)
-{
- int16_t value_adj;
-
- value_adj = min( max( value, low ), high );
-
- return value_adj;
-}
Word16 check_bounds_s_fx(
const Word16 value, /* i : Input value Q0*/
const Word16 low, /* i : Low limit Q0*/
@@ -1302,105 +924,6 @@ Word32 check_bounds_l(
* comput the matrix product of two matrices (Z=X*Y)
*---------------------------------------------------------------------*/
-/*! r: success or failure */
-int16_t matrix_product(
- const float *X, /* i : left hand matrix */
- const int16_t rowsX, /* i : number of rows of the left hand matrix */
- const int16_t colsX, /* i : number of columns of the left hand matrix */
- const int16_t transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */
- const float *Y, /* i : right hand matrix */
- const int16_t rowsY, /* i : number of rows of the right hand matrix */
- const int16_t colsY, /* i : number of columns of the right hand matrix */
- const int16_t transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */
- float *Z /* o : resulting matrix after the matrix multiplication */
-)
-{
- int16_t i, j, k;
- float *Zp = Z;
-
- /* Processing */
- if ( transpX == 1 && transpY == 0 ) /* We use X transpose */
- {
- if ( rowsX != rowsY )
- {
- return EXIT_FAILURE;
- }
- for ( j = 0; j < colsY; ++j )
- {
- for ( i = 0; i < colsX; ++i )
- {
- ( *Zp ) = 0.0f;
- for ( k = 0; k < rowsX; ++k )
- {
- ( *Zp ) += X[k + i * rowsX] * Y[k + j * rowsY];
- }
- Zp++;
- }
- }
- }
- else if ( transpX == 0 && transpY == 1 ) /* We use Y transpose */
- {
- if ( colsX != colsY )
- {
- return EXIT_FAILURE;
- }
- for ( j = 0; j < rowsY; ++j )
- {
- for ( i = 0; i < rowsX; ++i )
- {
- ( *Zp ) = 0.0f;
- for ( k = 0; k < colsX; ++k )
- {
- ( *Zp ) += X[i + k * rowsX] * Y[j + k * rowsY];
- }
- Zp++;
- }
- }
- }
- else if ( transpX == 1 && transpY == 1 ) /* We use both transpose */
- {
- if ( rowsX != colsY )
- {
- return EXIT_FAILURE;
- }
- for ( j = 0; j < rowsY; ++j )
- {
- for ( i = 0; i < colsX; ++i )
- {
- ( *Zp ) = 0.0f;
- for ( k = 0; k < colsX; ++k )
- {
- ( *Zp ) += X[k + i * rowsX] * Y[j + k * rowsY];
- }
-
- Zp++;
- }
- }
- }
- else /* Regular case */
- {
- if ( colsX != rowsY )
- {
- return EXIT_FAILURE;
- }
-
- for ( j = 0; j < colsY; ++j )
- {
- for ( i = 0; i < rowsX; ++i )
- {
- ( *Zp ) = 0.0f;
- for ( k = 0; k < colsX; ++k )
- {
- ( *Zp ) += X[i + k * rowsX] * Y[k + j * rowsY];
- }
- Zp++;
- }
- }
- }
-
- return EXIT_SUCCESS;
-}
-
Word16 matrix_product_mant_exp_fx(
const Word32 *X_fx, /* i : left hand matrix Q31 - X_fx_e*/
const Word16 X_fx_e, /* i : left hand matrix */
@@ -1992,60 +1515,6 @@ Word16 matrix_product_mant_exp(
}
-/*---------------------------------------------------------------------*
- * matrix_diag_product
- *
- * compute the product of a matrix with a diagonal of a matrix (Z=X*diag(Y))
- *---------------------------------------------------------------------*/
-
-/*! r: success or failure */
-int16_t matrix_diag_product(
- const float *X, /* i : left hand matrix */
- const int16_t rowsX, /* i : number of rows of the left hand matrix */
- const int16_t colsX, /* i : number of columns of the left hand matrix */
- const int16_t transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */
- const float *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements */
- const int16_t entriesY, /* i : number of entries in the diagonal */
- float *Z /* o : resulting matrix after the matrix multiplication */
-)
-{
- int16_t i, j;
- float *Zp = Z;
-
- /* Processing */
- if ( transpX == 1 ) /* We use X transpose */
- {
- if ( rowsX != entriesY )
- {
- return EXIT_FAILURE;
- }
- for ( j = 0; j < entriesY; ++j )
- {
- for ( i = 0; i < colsX; ++i )
- {
- *( Zp++ ) = X[j + i * rowsX] * Y[j];
- }
- }
- }
- else /* Regular case */
- {
- if ( colsX != entriesY )
- {
- return EXIT_FAILURE;
- }
-
- for ( j = 0; j < entriesY; ++j )
- {
- for ( i = 0; i < rowsX; ++i )
- {
- *( Zp++ ) = *( X++ ) * Y[j];
- }
- }
- }
-
- return EXIT_SUCCESS;
-}
-
Word16 matrix_diag_product_fx(
const Word32 *X, /* i : left hand matrix Q31 - X_e*/
Word16 X_e,
@@ -2227,60 +1696,6 @@ Word16 diag_matrix_product_fx(
return EXIT_SUCCESS;
}
-
-/*---------------------------------------------------------------------*
- * diag_matrix_product()
- *
- * compute the matrix product of a diagonal matrix X with a full matrix Y (Z=diag(Y)*X)
- *---------------------------------------------------------------------*/
-
-/*! r: success or failure */
-int16_t diag_matrix_product(
- const float *Y, /* i : left hand diagonal matrix as vector containing the diagonal elements */
- const int16_t entriesY, /* i : length of the diagonal of the left hand matrix */
- const float *X, /* i : right hand matrix */
- const int16_t rowsX, /* i : number of rows of the right hand matrix */
- const int16_t colsX, /* i : number of columns of the right hand matrix */
- const int16_t transpX, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */
- float *Z /* o : resulting matrix after the matrix multiplication */
-)
-{
- int16_t i, j;
- float *Zp = Z;
-
- /* Processing */
- if ( transpX == 1 ) /* We use X transpose */
- {
- if ( colsX != entriesY )
- {
- return EXIT_FAILURE;
- }
- for ( i = 0; i < rowsX; ++i )
- {
- for ( j = 0; j < entriesY; ++j )
- {
- *( Zp++ ) = X[i + j * rowsX] * Y[j];
- }
- }
- }
- else /* Regular case */
- {
- if ( rowsX != entriesY )
- {
- return EXIT_FAILURE;
- }
- for ( i = 0; i < colsX; ++i )
- {
- for ( j = 0; j < entriesY; ++j )
- {
- *( Zp++ ) = *( X++ ) * Y[j];
- }
- }
- }
-
- return EXIT_SUCCESS;
-}
-
Word16 matrix_product_diag_fx(
const Word32 *X, /* i : left hand matrix Q31 - X_e*/
Word16 X_e,
@@ -2401,96 +1816,6 @@ Word16 matrix_product_diag_fx(
* compute only the main diagonal of X*Y (Z=diag(X*Y))
*---------------------------------------------------------------------*/
-/*! r: success or failure */
-int16_t matrix_product_diag(
- const float *X, /* i : left hand matrix */
- const int16_t rowsX, /* i : number of rows of the left hand matrix */
- const int16_t colsX, /* i : number of columns of the left hand matrix */
- const int16_t transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */
- const float *Y, /* i : right hand matrix */
- const int16_t rowsY, /* i : number of rows of the right hand matrix */
- const int16_t colsY, /* i : number of columns of the right hand matrix */
- const int16_t transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */
- float *Z /* o : resulting matrix after the matrix multiplication */
-)
-{
- int16_t j, k;
- float *Zp = Z;
-
- /* Processing */
- if ( transpX == 1 && transpY == 0 ) /* We use X transpose */
- {
- if ( rowsX != rowsY )
- {
- return EXIT_FAILURE;
- }
-
- for ( j = 0; j < colsY; ++j )
- {
- ( *Zp ) = 0.0f;
- for ( k = 0; k < rowsX; ++k )
- {
- ( *Zp ) += X[k + j * rowsX] * Y[k + j * rowsY];
- }
- Zp++;
- }
- }
- else if ( transpX == 0 && transpY == 1 ) /* We use Y transpose */
- {
- if ( colsX != colsY )
- {
- return EXIT_FAILURE;
- }
- for ( j = 0; j < rowsY; ++j )
- {
- ( *Zp ) = 0.0f;
- for ( k = 0; k < colsX; ++k )
- {
- ( *Zp ) += X[j + k * rowsX] * Y[j + k * rowsY];
- }
- Zp++;
- }
- }
- else if ( transpX == 1 && transpY == 1 ) /* We use both transpose */
- {
- if ( rowsX != colsY )
- {
- return EXIT_FAILURE;
- }
-
- for ( j = 0; j < rowsY; ++j )
- {
-
- ( *Zp ) = 0.0f;
- for ( k = 0; k < colsX; ++k )
- {
- ( *Zp ) += X[k + j * rowsX] * Y[j + k * rowsY];
- }
-
- Zp++;
- }
- }
- else /* Regular case */
- {
- if ( colsX != rowsY )
- {
- return EXIT_FAILURE;
- }
-
- for ( j = 0; j < colsY; ++j )
- {
- ( *Zp ) = 0.0f;
- for ( k = 0; k < colsX; ++k )
- {
- ( *Zp ) += X[j + k * rowsX] * Y[k + j * rowsY];
- }
- Zp++;
- }
- }
-
- return EXIT_SUCCESS;
-}
-
void cmplx_matrix_square_fx(
const Word32 *realX, /* i : real part of the matrix Q31 - input_exp*/
const Word32 *imagX, /* i : imaginary part of the matrix Q31 - input_exp*/
@@ -2560,87 +1885,6 @@ void cmplx_matrix_square_fx(
}
-/*---------------------------------------------------------------------*
- * cmplx_matrix_square()
- *
- * compute the square of a complex matrix (Z=X*X)
- *---------------------------------------------------------------------*/
-
-/*! r: success or failure */
-void cmplx_matrix_square(
- const float *realX, /* i : real part of the matrix */
- const float *imagX, /* i : imaginary part of the matrix */
- const int16_t mRows, /* i : number of rows of the matrix */
- const int16_t nCols, /* i : number of columns of the matrix */
- float *realZ, /* o : real part of the resulting matrix */
- float *imagZ /* o : imaginary part of the resulting matrix */
-)
-{
- int16_t i, j, k;
- float *realZp, *imagZp;
- const float *p_real1, *p_real2, *p_imag1, *p_imag2;
-
- /* resulting matrix is hermitean, we only need to calc the upper triangle */
- /* we assume transposition needed */
-
- /* column*column = column/column */
- for ( i = 0; i < nCols; i++ )
- {
- for ( j = i; j < nCols; j++ )
- {
- p_real1 = realX + i * mRows;
- p_imag1 = imagX + i * mRows;
- p_real2 = realX + j * mRows;
- p_imag2 = imagX + j * mRows;
- realZp = realZ + ( i + nCols * j );
- imagZp = imagZ + ( i + nCols * j );
- *( realZp ) = 0.0f;
- *( imagZp ) = 0.0f;
-
- for ( k = 0; k < mRows; k++ )
- {
- *( imagZp ) += *( p_real1 ) * ( *( p_imag2 ) ) - ( *( p_real2 ) ) * ( *( p_imag1 ) );
- *( realZp ) += *( p_real1++ ) * ( *( p_real2++ ) ) + *( p_imag1++ ) * ( *( p_imag2++ ) );
- }
- }
- }
-
- /* fill lower triangle */
- for ( i = 1; i < nCols; i++ )
- {
- for ( j = 0; j < i; j++ )
- {
- realZ[i + nCols * j] = realZ[j + nCols * i];
- imagZ[i + nCols * j] = imagZ[j + nCols * i];
- }
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * v_multc_acc()
- *
- * Multiplication of vector by constant, accumulate to the output
- *-------------------------------------------------------------------*/
-
-void v_multc_acc(
- const float x[], /* i : Input vector */
- const float c, /* i : Constant */
- float y[], /* o : Output vector that contains y + c*x */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] += c * x[i];
- }
-
- return;
-}
-
void v_multc_acc_32_16(
const Word32 x[], /* i : Input vector Qx*/
const Word16 c, /* i : Constant Q31*/
@@ -2685,51 +1929,6 @@ void v_multc_acc_32_32(
* the interpolated vector is return as x[], if requested
*---------------------------------------------------------------------*/
-
-void lls_interp_n(
- float x[], /* i/o: input/output vector */
- const int16_t N, /* i : length of the input vector */
- float *a, /* o : calculated slope */
- float *b, /* o : calculated offset */
- const int16_t upd /* i : use 1 to update x[] with the interpolated output */
-)
-{
- int16_t i;
- const float n_i[11] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- const float one_by_n[11] = { 0, 1, 0.5f, 0.333f, 0.25f, 0.2f, 0.1666f, 0.14286f, 0.125f, 0.111111f, 0.1f };
- const float sum_i[12] = { 0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55 };
- const float sum_ii[12] = { 0, 0, 1, 5, 14, 30, 55, 91, 140, 204, 285, 385 };
- float sum_x, sum_ix, slope, offset;
-
- assert( N > 0 && N <= 10 );
-
- sum_x = sum_f( x, N );
- sum_ix = dotp( x, n_i, N );
-
- slope = ( N * sum_ix - sum_i[N] * sum_x ) / ( N * sum_ii[N] - sum_i[N] * sum_i[N] );
- offset = ( sum_x - slope * sum_i[N] ) * one_by_n[N];
-
- if ( upd )
- {
- for ( i = 0; i < N; i++ )
- {
- x[i] = slope * i + offset;
- }
- }
-
- if ( a != NULL )
- {
- *a = slope;
- }
-
- if ( b != NULL )
- {
- *b = offset;
- }
-
- return;
-}
-
void lls_interp_n_fx(
Word16 x_fx[], /* i/o: input/output vector Q15*/
const Word16 N, /* i : length of the input vector Q0*/
@@ -3032,44 +2231,6 @@ void panning_wrap_angles_fx(
}
}
-/*-------------------------------------------------------------------------*
- * v_sort_ind()
- *
- * Sort a float array
- * (modified version of v_sort() to return an index array)
- *-------------------------------------------------------------------------*/
-
-void v_sort_ind(
- float *x, /* i/o: Vector to be sorted */
- int16_t *idx, /* o : Original index positions */
- const int16_t len /* i : vector length */
-)
-{
- int16_t i, j;
- float tempr;
- int16_t tempi;
-
- for ( i = 0; i < len; i++ )
- {
- idx[i] = i;
- }
-
- for ( i = len - 2; i >= 0; i-- )
- {
- tempr = x[i];
- tempi = idx[i];
- for ( j = i + 1; ( j < len ) && ( tempr > x[j] ); j++ )
- {
- x[j - 1] = x[j];
- idx[j - 1] = idx[j];
- }
- x[j - 1] = tempr;
- idx[j - 1] = tempi;
- }
-
- return;
-}
-
/*-------------------------------------------------------------------------*
* v_sort_ind_fixed()
*
@@ -3204,23 +2365,6 @@ Word16 is_SIDrate(
* generate a random value with a triangular pdf in [-0.5, 0.5]
*-------------------------------------------------------------------*/
-float rand_triangular_signed(
- int16_t *seed )
-{
- float rand_val;
- rand_val = own_random( seed ) * OUTMAX_INV;
- if ( rand_val <= 0.0f )
- {
- /* rand_val in [-1, 0] */
- return 0.5f * sqrtf( rand_val + 1.0f ) - 0.5f;
- }
- else
- {
- /* rand_val in (0, 1) */
- return 0.5f - 0.5f * sqrtf( 1.0f - rand_val );
- }
-}
-
Word16 rand_triangular_signed_fx(
Word16 *seed, /*Q0*/
Word16 *exp_fac )
diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c
index d70da04dd0371357f667cb1d6f95bbd544819f7f..be06b8b0184b1d3cb7730c21276e3827b4915465 100644
--- a/lib_com/low_rate_band_att_fx.c
+++ b/lib_com/low_rate_band_att_fx.c
@@ -74,8 +74,17 @@ void ivas_fine_gain_pred_fx(
exp = norm_l( xx );
L_tmp = L_shl( xx, exp ); /*2*(15-shift)+exp */
exp = sub( 31, add( exp, sub( 30, shl( shift, 1 ) ) ) );
- L_tmp = Isqrt_lc( L_tmp, &exp ); /*31 - exp */
+ L_tmp = Isqrt_lc( L_tmp, &exp ); /*31 - exp */
+#ifndef FIX_ISSUE_987
Mpy_32_16_ss( L_tmp, ivas_fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */
+#else
+ Word16 norm = norm_s( bw );
+ Word16 tmp1, tmp_exp = sub( 15, norm );
+ tmp1 = Sqrt16( shl( bw, norm ), &tmp_exp );
+ tmp1 = shr( tmp1, sub( sub( 15, tmp_exp ), Q11 ) );
+ Mpy_32_16_ss( L_tmp, tmp1, &L_tmp, &lsb ); /*31-exp+11-15=27-exp */
+#endif
+
#ifdef BASOP_NOGLOB
gp = round_fx_o( L_shl_o( L_tmp, add( 1, exp ), &Overflow ), &Overflow ); /*27-exp+1+exp-16=12 */
#else
diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c
index 21857fd103a62a8ed20039fee4e56fa0c1e5238a..1b8438e84ad7f7266ddef765b5bed495cc7e340d 100644
--- a/lib_com/lsf_tools_fx.c
+++ b/lib_com/lsf_tools_fx.c
@@ -3324,10 +3324,6 @@ void msvq_dec(
maxn = n;
move16();
}
- if ( maxn % 4 )
- {
- n = n;
- }
assert( ( maxn % 4 ) == 0 );
N34 = mult( maxn, 24576 /*0.75 Q15*/ );
diff --git a/lib_com/move.h b/lib_com/move.h
index a6f5b353e8aba360d4ff04ad456f62cc960a9873..5c325fb1d5dc2d1b88edbfa6fb222e171e8928d7 100644
--- a/lib_com/move.h
+++ b/lib_com/move.h
@@ -36,13 +36,6 @@
#ifndef _MOVE_H
#define _MOVE_H
-#include "stl.h"
-/* BASOP -> FLC brigde: data move counting */
-
-#ifdef WMOPS
-extern BASIC_OP multiCounter[MAXCOUNTERS];
-extern int currCounter;
-#endif /* ifdef WMOPS */
static __inline void move16( void )
{
diff --git a/lib_com/options.h b/lib_com/options.h
index cacefdab4fdb59427afcd30a35fccb3cd3bb7165..5aa205a23ca71789ff4646d830a2a3342b3d74df 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -58,12 +58,17 @@
/*#define WMOPS*/ /* Activate complexity and memory counters */
#ifdef WMOPS
/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
+/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */
+/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */
/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */
#endif
/* #################### End DEBUGGING switches ############################ */
#define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */
+#ifndef BASOP_NOGLOB_DEV_USE_GLOBALS
+#define BASOP_NOGLOB_DECLARE_LOCAL
+#endif
#define IVAS_FLOAT_FIXED
#define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */
@@ -83,7 +88,23 @@
#define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/
#define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */
#define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX
+#define FIX_ISSUE_987
#define FIX_1054_IF_ELSE_CMPLX /* VA: Fix 1054 incorrect counting of complexity when ELSE-IF sequence is encoutered in two functions */
#define FIX_1052_COPY_CMPLX_DISCREPANCY /* VA: modify IF-ELSE statements used in Copy*() functions to avoid dependency on x[] and y[] in RAM */
#define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */
+#define NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+#define FIX_1103_OPT_L_NORM_ARR /* FhG: Optimize L_norm_arr(), avoid IF */
+#define FIX_1105_OPT_MINIMUM_SL /* FhG: Optimize minimum_s(), minimum_l(), avoid IF */
+#define FIX_1104_OPT_GETMINSCALEFAC /* FhG: Optimize get_min_scalefactor(), avoid IF */
+#define FIX_1106_SIMPLIFY_SET32FX /* FhG: simplify set32_fx() */
+#define FIX_1107_VADDINC /* FhG: Optimize v_add_inc_fx() for most frequent case */
+#define FIX_1009_OPT_PARAMMC_RENDER /* FhG: Optimize ivas_param_mc_dec_render_fx() */
+#define FIX_1109_OPTIM_MCT_STEREO_IGF_DEC /* FhG: optimize mctStereoIGF_dec_fx() */
+#define FIX_1110_OPTIM_DIRAC_DECORR_PROC /* FhG: optimize ivas_dirac_dec_decorr_process() */
+#define FIX_1127_IMPROVE_SBA_MLD /* Ittiam: Avoid saturation for DiRAC reference power */
+#define FIX_1100_REMOVE_LPC_RESCALING /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/
+#define FIX_1133_IMPROVE_MC_MLD /* Ittiam: Correcting wrong updation of exponents in ivas_mc_paramupmix_param_est_enc_fx() */
+#define FIX_ISSUE_1122 /* Ittiam: Fix issue 1122: corrected incorrect scaling of a buffer leading to incorrect metadata bits */
+#define FIX_1132_STACK_CORRUPTION /* Stack corruption issue due of extending index access*/
+#define FIX_ISSUE_1092 /* Ittiam: Fix for Issue 1092: BASOP asserts in stereo fx encoder for selection test inputs*/
#endif
diff --git a/lib_com/prot.h b/lib_com/prot.h
index 2246bc0403bad1b77896ed83d1b26a880deb61e1..9985ca978d25841413a23beec53528ddca5ac455 100644
--- a/lib_com/prot.h
+++ b/lib_com/prot.h
@@ -337,13 +337,6 @@ void v_multc(
const int16_t N /* i : Vector length */
);
-void v_sub_s(
- const int16_t x1[], /* i : Input vector 1 */
- const int16_t x2[], /* i : Input vector 2 */
- int16_t y[], /* o : Output vector that contains vector 1 - vector 2 */
- const int16_t N /* i : Vector length */
-);
-
/*! r: index of the winning codeword */
int16_t squant(
const float x, /* i : scalar value to quantize */
@@ -863,17 +856,6 @@ void deemph(
float *mem /* i/o: memory (y[-1]) */
);
-/*! r: tilt of the code */
-float est_tilt(
- const float *adpt_exc, /* i : adaptive excitation vector */
- const float gain_pit, /* i : adaptive gain */
- const float *fixe_exc, /* i : algebraic exctitation vector */
- const float gain_code, /* i : algebraic code gain */
- float *voice_fac, /* o : voicing factor */
- const int16_t L_subfr, /* i : subframe size */
- const int16_t flag_tilt /* i : flag for special tilt */
-);
-
void weight_a(
const float *a, /* i : LP filter coefficients */
float *ap, /* o : weighted LP filter coefficients */
@@ -1242,16 +1224,6 @@ void stat_noise_uv_mod(
const int16_t bwidth /* i : audio bandwidth */
);
-#ifndef IVAS_FLOAT_FIXED
-void pre_echo_att(
- float *Last_frame_ener, /* i/o: Energy of the last frame */
- float *exc, /* i/o: Excitation of the current frame */
- const int16_t attack_flag, /* i : attack flag (GSC or TC) */
- const int16_t last_coder_type, /* i : Last coder type */
- const int16_t L_frame /* i : frame length */
-);
-#endif
-
void limit_band_noise_level_calc(
const int16_t *wnorm, /* i : reordered norm of sub-vectors */
int16_t *limit, /* o : highest band of bit allocation */
@@ -1569,18 +1541,6 @@ void enforce_zero_for_min_envelope(
const int16_t *sfm_end /* i : Sub band end indices */
);
-#ifndef IVAS_FLOAT_FIXED
-/*! r: Number of assigned gain bits */
-int16_t assign_gain_bits(
- const int16_t core, /* i : HQ core */
- const int16_t BANDS, /* i : Number of bands */
- const int16_t *band_width, /* i : Sub band bandwidth */
- int16_t *Rk, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
- int16_t *gain_bits_array, /* o : Assigned gain bits */
- int16_t *Rcalc /* o : Bit budget for shape quantizer (Q3) */
-);
-#endif
-
void apply_envelope(
const float *coeff, /* i/o: Coded/noisefilled normalized spectrum */
const int16_t *norm, /* i : Envelope */
@@ -2044,24 +2004,24 @@ void MDCT_selector(
const float enerBuffer[] /* i : energy buffer */
);
-ivas_error acelp_core_enc(
+ivas_error acelp_core_enc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 inp[], /* i : input signal of the current frame */
- Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */
- Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes */
- const Word32 epsP[M + 1], /* i : LP prediction errors */
- Word16 lsp_new[M], /* i : LSPs at the end of the frame */
- Word16 lsp_mid[M], /* i : LSPs in the middle of the frame */
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- const Word16 attack_flag, /* i : attack flag (GSC or TC) */
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_new */
- Word16 *voice_factors_fx, /* o : voicing factors Q15 */
- Word16 old_syn_12k8_16k[], /* o : ACELP core synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
+ const Word16 inp[], /* i : input signal of the current frame Q_new*/
+ Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/
+ Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/
Word16 *q_old_syn_12k8_16,
- Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits, /* o : number of unused bits */
- STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
- Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
+ Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word16 *unbits, /* o : number of unused bits Q0*/
+ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
+ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/
Word16 Q_new );
ivas_error acelp_core_switch_dec_bfi(
@@ -2905,16 +2865,6 @@ float gsc_gainQ(
const int32_t core_brate_inp /* i : true core brate */
);
-#ifndef IVAS_FLOAT_FIXED
-void Ener_per_band_comp(
- const float exc_diff[], /* i : gain per band */
- float y_gain4[], /* o : gain per band to quantize */
- const int16_t Mband, /* i : Max band */
- const int16_t Eflag, /* i : flag of highest band */
- const int16_t L_frame /* i : frame length */
-);
-#endif
-
void Comp_and_apply_gain(
float exc_diffQ[], /* i/o: gain per band */
float Ener_per_bd_iQ[], /* o : Quant Ener per band */
@@ -2923,30 +2873,6 @@ void Comp_and_apply_gain(
const int16_t ReUseGain /* i : Reuse the gain in Ener_per_bd_yQ */
);
-#ifndef IVAS_FLOAT_FIXED
-void bands_and_bit_alloc(
- const int16_t cor_strong_limit, /* i : HF correlation */
- const int16_t noise_lev, /* i : dwn scaling factor */
- const int32_t core_brate, /* i : core bitrate */
- const int16_t Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
- const int16_t bits_used, /* i : Number of bit used before frequency Q */
- int16_t *bit, /* i/o: Number of bit allowed for frequency quantization */
- float *ener_vec, /* i/o: Quantized energy vector */
- int16_t *max_ener_band, /* o : Sorted order */
- int16_t *bits_per_bands_s, /* i/o: Number of bit allowed per allowed subband (Q3) */
- int16_t *nb_subbands, /* o : Number of subband allowed */
- const float *exc_diff, /* i : Difference signal to quantize (encoder side only) */
- float *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */
- int16_t *pvq_len, /* o : Number of bin covered with the PVQ */
- const int16_t coder_type, /* i : coding type */
- const int16_t bwidth, /* i : input signal bandwidth */
- const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
- const int16_t L_frame, /* i : frame length */
- const int16_t element_mode, /* i : element mode */
- const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
-);
-#endif
-
void bands_and_bit_alloc_ivas_fx(
const Word16 cor_strong_limit, /* i : HF correlation */
const Word16 noise_lev, /* i : dwn scaling factor */
@@ -2969,29 +2895,6 @@ void bands_and_bit_alloc_ivas_fx(
const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
);
-#ifndef IVAS_FLOAT_FIXED
-/*! r: average frequency gain */
-float gsc_gaindec(
- Decoder_State *st, /* i/o: decoder state structure */
- float y_gainQ[], /* o : quantized gain per band */
- const int32_t core_brate, /* i : core used */
- float old_y_gain[], /* i/o: AR gain quantizer for low rate */
- const int16_t coder_type, /* i : coding type */
- const int16_t bwidth /* i : input signal bandwidth */
-);
-#endif
-
-#ifndef IVAS_FLOAT_FIXED
-void freq_dnw_scaling(
- const int16_t cor_strong_limit, /* i : HF correlation */
- const int16_t coder_type, /* i : coder type */
- const int16_t noise_lev, /* i : Noise level */
- const int32_t core_brate, /* i : Core bitrate */
- float fy_norm[], /* i/o: Frequency quantized parameter */
- const int16_t L_frame /* i : frame length */
-);
-#endif
-
void GSC_dec_init_ivas(
GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */
);
@@ -3042,38 +2945,6 @@ void dec_pit_exc(
const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
);
-#ifndef IVAS_FLOAT_FIXED
-void highband_exc_dct_in(
- const int32_t core_brate, /* i : core bitrate */
- const int16_t *mfreq_bindiv_loc, /* i : bin per bands tables */
- int16_t last_bin, /* i : last bin of bit allocation */
- int16_t Diff_len, /* i : number of bin before cut-off frequency */
- int16_t noise_lev, /* i : pulses dynamic */
- int16_t pit_band_idx, /* i : bin position of the cut-off frequency */
- float *exc_diffQ, /* i : frequency coefficients of per band */
- int16_t *seed_tcx, /* i : Seed for noise */
- float *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */
- int16_t nb_subfr, /* i : Number of subframe considered */
- float *exc_dct_in, /* o : dct of residual signal */
- int16_t last_coder_type, /* i : coding type of last frame */
- int16_t *bitallocation_band, /* i : bit allocation flag of each band */
- const float *lsf_new, /* i : ISFs at the end of the frame */
- float *last_exc_dct_in, /* i : dct of residual signal of last frame */
- float *last_ener, /* i : frequency energy of last frame */
- int16_t *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */
- int16_t *bitallocation_exc, /* i : flag of decoded coefficients */
- const int16_t bfi, /* i : bad frame indicator */
- const int16_t coder_type, /* i : coder type */
- const int16_t bwidth, /* i : audio bandwidth */
- float *exc_wo_nf, /* o : excitation (in f domain) without noisefill */
- const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
- float *lt_ener_per_band_fx, /* i/o: Average per band energy */
- const int16_t L_frame, /* i : frame length */
- const int16_t element_mode, /* i : IVAS element moden */
- const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
-);
-#endif
-
void music_postfilt_init_flt(
MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */
);
@@ -3123,31 +2994,25 @@ void speech_music_classif(
int16_t *high_lpn_flag, /* o : sp/mus LPN flag */
const int16_t flag_spitch /* i : flag to indicate very short stable pitch */
);
-void ivas_find_wsp(
- const Word16 L_frame, /* i : length of the frame */
- const Word16 L_subfr, /* i : length of subframe */
- const Word16 nb_subfr, /* i : number of subframes */
- const Word16 *A_fx, /* i : A(z) filter coefficients */
- Word16 *Aw_fx, /* o : weighted A(z) filter coefficients */
- const Word16 *speech_fx, /* i : pointer to the denoised speech frame */
- const Word16 tilt_fact, /* i : tilt factor */
- Word16 *wsp_fx, /* o : poitnter to the weighted speech frame */
- Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory */
- const Word16 gamma, /* i : weighting factor */
- const Word16 L_look /* i : look-ahead */
-);
-void find_wsp(
- const int16_t L_frame, /* i : length of the frame */
- const int16_t L_subfr, /* i : length of subframe */
- const int16_t nb_subfr, /* i : number of subframes */
- const float *A, /* i : A(z) filter coefficients */
- float *Aw, /* o : weighted A(z) filter coefficients */
- const float *speech, /* i : pointer to the denoised speech frame */
- const float tilt_fact, /* i : tilt factor */
- float *wsp, /* o : poitnter to the weighted speech frame */
- float *mem_wsp, /* i/o: W(Z) denominator memory */
- const float gamma, /* i : weighting factor */
- const int16_t L_look /* i : look-ahead */
+void ivas_find_wsp_fx(
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 L_subfr, /* i : length of subframe Q0*/
+ const Word16 nb_subfr, /* i : number of subframes Q0*/
+ const Word16 *A_fx,
+ /* i : A(z) filter coefficients */ // Q12
+ Word16 *Aw_fx,
+ /* o : weighted A(z) filter coefficients */ // Q12
+ const Word16 *speech_fx,
+ /* i : pointer to the denoised speech frame */ // Q_new
+ const Word16 tilt_fact,
+ /* i : tilt factor */ // Q15
+ Word16 *wsp_fx,
+ /* o : poitnter to the weighted speech frame */ // Q_new
+ Word16 *mem_wsp_fx,
+ /* i/o: W(Z) denominator memory */ // Q_new
+ const Word16 gamma,
+ /* i : weighting factor */ // Q15
+ const Word16 L_look /* i : look-ahead Q0*/
);
void gain_enc_amr_wb(
@@ -5795,20 +5660,6 @@ void adapt_lag_wind_fx(
const int32_t sr_core /* i : core sampling rate */
);
-#ifndef IVAS_FLOAT_FIXED
-void hp20_flt(
- Float32 signal[],
- const Word16 lg,
- Float32 mem[],
- const Word32 Fs );
-#endif
-
-void init_coder_ace_plus(
- Encoder_State *st, /* i : Encoder state handle */
- const int32_t last_total_brate, /* i : last total bitrate */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
-);
-
void core_coder_reconfig(
Encoder_State *st, /* i/o: encoder state structure */
const int32_t last_total_brate /* i : last total bitrate */
@@ -5945,16 +5796,6 @@ void core_signal_analysis_high_bitrate(
const int16_t vad_hover_flag /* i : VAD hangover flag */
);
-#ifndef IVAS_FLOAT_FIXED
-/*! r: codebook gain (adaptive or fixed) */
-float get_gain_flt(
- const float x[], /* i : target signal */
- const float y[], /* i : filtered codebook excitation */
- const int16_t n, /* i : segment length */
- float *en_y /* o : energy of y (sum of y[]^2, optional) */
-);
-#endif
-
void encode_acelp_gains(
const float *code,
const int16_t gains_mode,
@@ -6288,17 +6129,18 @@ int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
);
-int16_t RCcontextMapping_encode2_estimate_bandWise_start(
- int16_t *x,
- const int16_t nt,
- const int16_t target,
+Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx(
+ Word16 *x, /* Q0 */
+ const Word16 nt, /* Q0 */
+ const Word16 target, /* Q0 */
HANDLE_RC_CONTEXT_MEM hContextMem );
-int16_t RCcontextMapping_encode2_estimate_bandWise(
- int16_t *x,
- const int16_t start_line,
- const int16_t end_line,
- HANDLE_RC_CONTEXT_MEM hContextMem );
+Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
+ Word16 *x, /* Q0 */
+ const Word16 start_line, /* Q0 */
+ const Word16 end_line, /* Q0 */
+ HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */
+);
void tcx_get_windows_flt(
TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */
@@ -6752,16 +6594,16 @@ void decoder_acelp(
float *bwe_exc /* o : excitation for SWB TBE */
);
-void writeTCXMode(
- Encoder_State *st, /* i/o: encoder state structure */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
- int16_t *nbits_start /* o : nbits start */
+void writeTCXMode_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ Word16 *nbits_start /* o : nbits start Q0*/
);
-void writeTCXWindowing(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const int16_t overlap_mode /* i : overlap mode */
+void writeTCXWindowing_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const Word16 overlap_mode /* i : overlap mode Q0*/
);
void writeLPCparam(
@@ -8022,17 +7864,6 @@ float Damping_fact_flt(
const int16_t core /* i : current core: ACELP = 0, TCX20 = 1, TCX10 = 2 */
);
-#ifndef IVAS_FLOAT_FIXED
-void fer_energy(
- const int16_t L_frame, /* i : frame length */
- const int16_t clas, /* i : frame classification */
- const float synth[], /* i : synthesized speech at Fs = 12k8 Hz */
- const float pitch, /* i : pitch period */
- float *enr, /* o : pitch-synchronous or half_frame energy */
- const int16_t useOffset /* i : speech pointer offset (0 or L_FRAME) */
-);
-#endif
-
float getLevelSynDeemph(
const float h1Init[], /* i : input value or vector to be processed */
const float A[], /* i : LPC coefficients */
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
index 40086183d77af30f3b65cee59d3787d003c40497..0e528f9f3af42a04ec8a3ad612476421a8a7528d 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -206,6 +206,12 @@ void Scale_sig(
const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
);
+void scale_sig(
+ Word16 x[], /* i/o: signal to scale Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
// tools.c
Word32 sum2_fx( /* o : sum of all squared vector elements Q(2x+1)*/
const Word16 *vec, /* i : i vector Qx*/
@@ -2727,6 +2733,12 @@ void time_envelop_shaping_fx(
const Word16 L, /* i : frame length */
Word16 *Q_synth );
+void time_envelop_shaping_ivas_fx(
+ Word16 werr[], /* i/o: SHB synthesis Q_synth*/
+ Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/
+ const Word16 L, /* i : frame length */
+ Word16 *Q_synth );
+
void time_reduce_pre_echo_fx(
const Word16 *synth, /* i : ACELP core synthesis Q_syn*/
Word16 *error, /* i/o: SHB BWE synthesis Q0*/
@@ -3668,58 +3680,64 @@ gp_clips_fx.c
/========================================================================================================*/
void init_gp_clip_fx(
- Word16 mem[] /* o : memory of gain of pitch clipping algorithm */
+ Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
);
Word16 gp_clip_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 *voicing, /* i : normalized correlations (from OL pitch) */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : type of coder */
- const Word16 xn[], /* i : target vector */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ const Word16 xn[], /* i : target vector Q_new*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
const Word16 Q_new /* i : scaling factor */
);
void gp_clip_test_isf_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 isf[], /* i : isf values (in frequency domain) */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/
);
void gp_clip_test_gain_pit_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 gain_pit, /* i : gain of quantized pitch Q14 */
- Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14 */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 gain_pit, /* i : gain of quantized pitch Q14*/
+ Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/
);
-Word16 Mode2_gp_clip(
- const Word16 *voicing, /* i : normalized correlations (from OL pitch) */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : type of coder */
- const Word16 xn[], /* i : target vector */
+Word16 Mode2_gp_clip_fx(
+ const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */
+ const Word16 i_subfr, /* i : subframe index Q0 */
+ const Word16 coder_type, /* i : type of coder Q0 */
+ const Word16 xn[], /* i : target vector Q_xn */
Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 L_subfr,
- const Word16 Q_xn /* i : xn data format */
+ /* mem[0]: Q0 */
+ /* mem[1]: 1Q14 */
+ /* mem[2]: 8Q7 */
+ /* mem[3]: Q0 (integer) */
+ /* mem[4]: Q14 */
+ /* mem[5]: Q14 */
+ const Word16 L_subfr, /* Q0 */
+ const Word16 Q_xn /* i : scaling factor of vector xn[] */
);
void gp_clip_test_lsf_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28 */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 m /* i : dimension of lsf */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ const Word16 m /* i : dimension of lsf Q0*/
);
void gp_clip_test_lsf_ivas_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 lsf[], /* i : LSF vector */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/
);
/*========================================================================================================/
@@ -3818,7 +3836,7 @@ detect_transient_fx.c
Word16 detect_transient_fx(
const Word16 *in_fx, /*Q_new */
- const Word16 L,
+ const Word16 L, /*Q0*/
Word16 Q_new,
Encoder_State *st_fx );
@@ -4437,6 +4455,13 @@ void edct_fx(
Word16 *q /* i : Q value of i signal */
);
+void edct_ivas_fx(
+ const Word32 *x, /* i : input signal Qq */
+ Word32 *y, /* o : output transform Qq */
+ Word16 length, /* i : length Q0*/
+ Word16 *q /* i : Q value of input signal */
+);
+
void edst_fx(
const Word32 *x, /* i : i signal Qq */
Word32 *y, /* o : output transform Qq */
@@ -4552,11 +4577,13 @@ void DoRTFTn_fx_ivas(
Word16 find_guarded_bits_fx( Word32 n );
-Word16 L_norm_arr( Word32 *arr, Word16 size );
+Word16 L_norm_arr( const Word32 *arr, Word16 size );
+Word16 norm_arr( Word16 *arr, Word16 size );
Word16 get_min_scalefactor( Word32 x, Word32 y );
Flag is_zero_arr( Word32 *arr, Word16 size );
+Flag is_zero_arr16( Word16 *arr, Word16 size );
void edct2_fx_ivas(
const Word16 n,
@@ -4937,12 +4964,12 @@ void fine_gain_quant_fx(
const Word16 *gopt /* i : Optimal gains Q12 */
);
void fine_gain_quant_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *ord, /* i : Indices for energy order Q0 */
- const Word16 num_sfm, /* i : Number of bands Q0 */
- const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */
- Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */
- const Word16 *gopt /* i : Optimal gains Q12 */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 *ord, /* i : Indices for energy order Q0 */
+ const Word16 num_sfm, /* i : Number of bands Q0 */
+ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */
+ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains i:Q12 / o:Q11 */
+ const Word16 *gopt /* i : Optimal gains Q12 */
);
void get_max_pulses_fx(
const Word16 *band_start, /* i : Sub band start indices */
@@ -9587,6 +9614,17 @@ void cldfbAnalysis_ts_fx(
Word16 *q_cldfb );
Word16 floor_log_2( Word32 num );
+void cldfbAnalysis_ts_fx_var_q(
+ const Word32 *timeIn_fx,
+ /* i : time buffer */ // q
+ Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ /* o : real value buffer */ // q_cldfb - 5
+ Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ /* o : imag value buffer */ // q_cldfb - 5
+ const Word16 samplesToProcess, /* i : samples to process */
+ HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
+ Word16 *q_cldfb );
+
void cldfbAnalysis_ts_fx_fixed_q(
const Word32 *timeIn_fx,
/* i : time buffer */ // q
@@ -9905,14 +9943,14 @@ void tcx_scalar_quantization_ivas_fx(
Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */
const Word16 alfe_flag );
-Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
- Word16 *x, /* Spectral coefficients */
- const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) */
- Word16 *lastnz_out,
- Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */
- const Word16 target, /* Target bits */
- Word16 *stop,
- Word16 mode,
+Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
+ Word16 *x, /* Spectral coefficients Q0*/
+ const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/
+ Word16 *lastnz_out, /* Q0 */
+ Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/
+ const Word16 target, /* Target bits Q0*/
+ Word16 *stop, /* Q0 */
+ Word16 mode, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
);
@@ -10031,6 +10069,12 @@ Word16 maximum_fx( /* o : index of the maximum value in t
Word16 *max_fx /* o : maximum value in the input vector */
);
+Word16 maximum_exp_fx( /* o : index of the maximum value in the input vector */
+ const Word16 *vec_fx, /* i : input vector */
+ const Word16 *exp_vec, /* i : exponents of input vector */
+ const Word16 lvec_fx /* i : length of input vector */
+);
+
Word16 maximum_abs_16_fx( /* o : index of the maximum abs value in the input vector */
const Word16 *vec, /* i : input vector */
const Word16 lvec, /* i : length of input vector */
@@ -10739,7 +10783,8 @@ void core_encode_update_ivas_fx(
);
void updt_enc_common_ivas_fx(
- Encoder_State *st /* i/o: encoder state structure */
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 Q_new /* i : CUrrent frame scaling */
);
// tools.c
@@ -10769,9 +10814,11 @@ Word32 sum2_32_fx(
Word16 *e );
void ProcessStereoIGF_fx(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct,
- Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
- Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
- Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */
+ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
+ Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
+ Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */
+ Word16 q_pITFMDCTSpectrum_1,
+ Word16 q_pITFMDCTSpectrum_2,
Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */
Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
@@ -10797,8 +10844,8 @@ void IGFEncApplyStereo_fx(
void IGFSaveSpectrumForITF_ivas_fx(
IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */
const Word16 igfGridIdx, /* i : IGF grid index */
- const Word32 *pITFSpectrum /* i : MDCT spectrum */
-);
+ const Word32 *pITFSpectrum, /* i : MDCT spectrum */
+ Word16 exp_pITFSpectrum );
Word16 IGFEncWriteBitstream_ivas_fx(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
@@ -10816,19 +10863,24 @@ Word16 IGFSCFEncoderEncode(
const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */
);
/*ari_enc.c*/
-Word16 ari_encode_14bits_ext(
- Word16 *ptr,
- Word16 bp,
+Word16 ari_encode_14bits_ext_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
Tastat *s,
- Word32 symbol,
- const UWord16 *cum_freq );
-Word16 ari_encode_14bits_sign(
- Word16 *ptr,
- Word16 bp,
- Word32 bits,
+ Word32 symbol, /* Q0 */
+ UWord16 const *cum_freq /* Q0 */
+);
+Word16 ari_encode_14bits_sign_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word32 bits, /* Q0 */
Tastat *s,
- Word16 sign );
-Word16 ari_done_encoding_14bits( Word16 *ptr, Word16 bp, Tastat *s );
+ Word16 sign /* Q0 */
+);
+Word16 ari_done_encoding_14bits_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Tastat *s );
void pack_bit(
const Word16 bit, /* i: bit to be packed */
UWord8 **pt, /* i/o: pointer to octet array into which bit will be placed */
@@ -10932,12 +10984,12 @@ Word16 get_next_coeff_mapped_ivas_fx(
);
void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word16 *x,
- const Word16 nt,
- Word16 lastnz,
- const Word16 nbbits,
- const Word16 resQMaxBits,
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ Word16 *x, /* Q0 */
+ const Word16 nt, /* Q0 */
+ Word16 lastnz, /* Q0 */
+ const Word16 nbbits, /* Q0 */
+ const Word16 resQMaxBits, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg );
void writeTCXparam_fx(
@@ -10976,8 +11028,9 @@ void core_coder_mode_switch_ivas_fx(
void configureFdCngEnc_ivas_fx(
HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
- const Word16 bwidth,
- const Word32 total_brate );
+ const Word16 bwidth, /* Q0 */
+ const Word32 total_brate /* Q0 */
+);
Word16 getTcxonly_ivas_fx(
const Word16 element_mode, /* i : IVAS element mode */
@@ -10989,9 +11042,9 @@ Word16 getTcxonly_ivas_fx(
void SetModeIndex_ivas_fx(
Encoder_State *st, /* i : Encoder state */
- const Word32 last_total_brate, /* i : last total bitrate */
- const Word16 last_element_mode, /* i : last IVAS element mode */
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
+ const Word32 last_total_brate, /* i : last total bitrate Q0*/
+ const Word16 last_element_mode, /* i : last IVAS element mode Q0*/
+ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/
);
void IGFEncSetMode_ivas_fx(
@@ -11057,16 +11110,16 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx(
);
void FEC_encode_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation */
- const Word16 coder_type, /* i : type of coder */
- Word16 clas, /* i : signal clas for current frame */
- const Word16 *fpit, /* i : close loop fractional pitch buffer Q6 */
- const Word16 *res, /* i : LP residual signal frame */
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse */
- const Word16 L_frame, /* i : Frame length */
- const Word32 total_brate, /* i : total codec bitrate */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
+ const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ Word16 clas, /* i : signal clas for current frame Q0*/
+ const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
+ const Word16 *res, /* i : LP residual signal frame Qx*/
+ Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
+ const Word16 L_frame, /* i : Frame length Q0*/
+ const Word32 total_brate, /* i : total codec bitrate Q0*/
const Word16 Q_synth /* i : input scaling */
);
diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c
index 48ee402ef182f83254b64a6aa52a8a7a8bc26b09..36fa528b863fe573823b24915d60a7e4ca6e5fb3 100644
--- a/lib_com/pvq_com_fx.c
+++ b/lib_com/pvq_com_fx.c
@@ -515,12 +515,12 @@ void apply_gain_fx(
* Fine gain quantization
*--------------------------------------------------------------------------*/
void fine_gain_quant_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *ord, /* i : Indices for energy order Q0 */
- const Word16 num_sfm, /* i : Number of bands Q0 */
- const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */
- Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q11 */
- const Word16 *gopt /* i : Optimal gains Q12 */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 *ord, /* i : Indices for energy order Q0 */
+ const Word16 num_sfm, /* i : Number of bands Q0 */
+ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */
+ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains i:Q12 / o:Q11 */
+ const Word16 *gopt /* i : Optimal gains Q12 */
)
{
Word16 band;
@@ -577,6 +577,10 @@ void fine_gain_quant_ivas_fx(
fg_pred[band] = round_fx( L_shl( L_tmp, sub( 15, exp1 ) ) ); /*12+exp1+16-exp1-16=12 - 1-> Q11*/
move16();
}
+ ELSE
+ {
+ fg_pred[band] = shr( fg_pred[band], 1 ); // Q12 -> Q11 To align all the fg_pred indices in same Q.
+ }
}
return;
diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c
index 254c3df9d9e36baa5af8afd2bd3a7a6cde2d59e2..612e30bdf6d5a833984683cc135d7797466c2f83 100644
--- a/lib_com/rom_com.c
+++ b/lib_com/rom_com.c
@@ -475,12 +475,6 @@ const Word16 ACELP_CDK_BITS[ACELP_FIXED_CDK_NB] =
* Perceptual critical bands
*----------------------------------------------------------------------------------*/
-const float crit_bands[] =
-{
- 100.0f, 200.0f, 300.0f, 400.0f, 510.0f, 630.0f, 770.0f, 920.0f, 1080.0f, 1270.0f, 1480.0f,
- 1720.0f, 2000.0f, 2320.0f, 2700.0f, 3150.0f, 3700.0f, 4400.0f, 5300.0f, 6350.0f, 7700.0f,
- 9500.0f, 12000.0f, 15500.0f, 40000.0f
-};
const Word32 crit_bands_fx[] =//Q0
{
100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480,
@@ -793,138 +787,6 @@ const Word16 assym_window_16k_fx[L_LP_16k] = /*Q15*/
2756, 2720, 2690, 2665, 2646, 2632, 2624, 2621
};
-/* LAGW_STRONG */
-const float lag_window_8k_flt[17] =
-{
- 1.0001f,
- 0.998890285694f, 0.995568526105f, 0.990056789412f, 0.982391584471f,
- 0.972623458067f, 0.960816439805f, 0.947047343167f, 0.931404933402f,
- 0.913988974871f, 0.894909172129f, 0.874284020465f, 0.852239582728f,
- 0.828908210054f, 0.804427224606f, 0.778937582562f, 0.752582535421f
-};
-
-const float lag_window_12k8_flt[NUM_LAGW_STRENGTHS][17] =
-{
- /* LAGW_WEAK */
- {
- 1.0001f,
- 0.999951809733f, 0.999807252867f, 0.999566371195f, 0.999229234349f,
- 0.998795939769f, 0.998266612656f, 0.997641405905f, 0.996920500042f,
- 0.996104103128f, 0.995192450664f, 0.994185805476f, 0.993084457589f,
- 0.991888724088f, 0.990598948965f, 0.989215502956f, 0.987738783362f
- },
- /* LAGW_MEDIUM */
- {
- 1.0001f,
- 0.999807252867f, 0.999229234349f, 0.998266612656f, 0.996920500042f,
- 0.995192450664f, 0.993084457589f, 0.990598948965f, 0.987738783362f,
- 0.984507244288f, 0.980908033914f, 0.976945266001f, 0.972623458067f,
- 0.967947522806f, 0.962922758784f, 0.957554840431f, 0.951849807369f
- },
- /* LAGW_STRONG */
- {
- 1.0001f,
- 0.999566371183f, 0.998266612613f, 0.996104103033f, 0.993084457421f,
- 0.989215493202f, 0.984507262707f, 0.978971838951f, 0.972623467445f,
- 0.965478420258f, 0.957554817200f, 0.948872864246f, 0.939454317093f,
- 0.929322779179f, 0.918503403664f, 0.907022833824f, 0.894909143448f
- }
-};
-
-const float lag_window_16k_flt[NUM_LAGW_STRENGTHS][17] =
-{
- /* LAGW_WEAK */
- {
- 1.0001f,
- 0.999969157962f, 0.999876637555f, 0.999722455899f, 0.999506641521f,
- 0.999229234349f, 0.998890285694f, 0.998489858239f, 0.998028026020f,
- 0.997504874399f, 0.996920500042f, 0.996275010885f, 0.995568526105f,
- 0.994801176082f, 0.993973102356f, 0.993084457589f, 0.992135405511f
- },
- /* LAGW_MEDIUM */
- {
- 1.0001f,
- 0.999876637555f, 0.999506641521f, 0.998890285694f, 0.998028026020f,
- 0.996920500042f, 0.995568526105f, 0.993973102356f, 0.992135405511f,
- 0.990056789412f, 0.987738783362f, 0.985183090250f, 0.982391584471f,
- 0.979366309628f, 0.976109476043f, 0.972623458067f, 0.968910791191f
- },
- /* LAGW_STRONG */
- {
- 1.0001f,
- 0.999722455899f, 0.998890285694f, 0.997504874399f, 0.995568526105f,
- 0.993084457589f, 0.990056789412f, 0.986490534533f, 0.982391584471f,
- 0.977766693093f, 0.972623458067f, 0.966970300068f, 0.960816439805f,
- 0.954171872966f, 0.947047343167f, 0.939454313017f, 0.931404933402f
- }
-};
-
-const float lag_window_25k6_flt[NUM_LAGW_STRENGTHS][17] =
-{
- /* LAGW_WEAK */
- {
- 1.0001f,
- 0.999987952216f, 0.999951809733f, 0.999891575166f, 0.999807252867f,
- 0.999698848932f, 0.999566371195f, 0.999409829230f, 0.999229234349f,
- 0.999024599601f, 0.998795939769f, 0.998543271372f, 0.998266612656f,
- 0.997965983599f, 0.997641405905f, 0.997292903003f, 0.996920500042f
- },
- /* LAGW_MEDIUM */
- {
- 1.0001f,
- 0.999951809733f, 0.999807252867f, 0.999566371195f, 0.999229234349f,
- 0.998795939769f, 0.998266612656f, 0.997641405905f, 0.996920500042f,
- 0.996104103128f, 0.995192450664f, 0.994185805476f, 0.993084457589f,
- 0.991888724088f, 0.990598948965f, 0.989215502956f, 0.987738783362f
- },
- /* LAGW_STRONG */
- {
- 1.0001f,
- 0.999891579151f, 0.999566376209f, 0.999024569988f, 0.998266637325f,
- 0.997292876244f, 0.996104121208f, 0.994700968266f, 0.993084430695f,
- 0.991255581379f, 0.989215493202f, 0.986965596676f, 0.984507262707f,
- 0.981842100620f, 0.978971838951f, 0.975898265839f, 0.972623467445f
- }
-};
-
-const float lag_window_32k_flt[NUM_LAGW_STRENGTHS][17] =
-{
- /* LAGW_WEAK */
- {
- 1.0001f,
- 0.999992289401f, 0.999969157962f, 0.999930606752f, 0.999876637555f,
- 0.999807252867f, 0.999722455899f, 0.999622250572f, 0.999506641521f,
- 0.999375634094f, 0.999229234349f, 0.999067449055f, 0.998890285694f,
- 0.998697752455f, 0.998489858239f, 0.998266612656f, 0.998028026020f
- },
- /* LAGW_MEDIUM */
- {
- 1.0001f,
- 0.999969157962f, 0.999876637555f, 0.999722455899f, 0.999506641521f,
- 0.999229234349f, 0.998890285694f, 0.998489858239f, 0.998028026020f,
- 0.997504874399f, 0.996920500042f, 0.996275010885f, 0.995568526105f,
- 0.994801176082f, 0.993973102356f, 0.993084457589f, 0.992135405511f
- },
- /* LAGW_STRONG */
- {
- 1.0001f,
- 0.999930606752f, 0.999722455899f, 0.999375634094f, 0.998890285694f,
- 0.998266612656f, 0.997504874399f, 0.996605387628f, 0.995568526105f,
- 0.994394720400f, 0.993084457589f, 0.991638280913f, 0.990056789412f,
- 0.988340637503f, 0.986490534533f, 0.984507244288f, 0.982391584471f
- }
-};
-
-/* LAGW_STRONG */
-const float lag_window_48k_flt[17] =
-{
- 1.0001f,
- 0.999969157962f, 0.999876637555f, 0.999722455899f, 0.999506641521f,
- 0.999229234349f, 0.998890285694f, 0.998489858239f, 0.998028026020f,
- 0.997504874399f, 0.996920500042f, 0.996275010885f, 0.995568526105f,
- 0.994801176082f, 0.993973102356f, 0.993084457589f, 0.992135405511f
-};
-
const Word16 lag_window_8k[2][16] = /* LAGW_STRONG Q15*/
{
/* h */ { 32728, 32619, 32438, 32187, 31867, 31480, 31029, 30517, 29946, 29321, 28645, 27923, 27158, 26356, 25521, 24658 },
@@ -1103,44 +965,6 @@ const Word16 grid40_fx[(GRID40_POINTS - 1) / 2 - 1] =
* Sinus & Cosinus - table for the FFT and IFFT of 256 points,
* dimension of the table = 161
*----------------------------------------------------------------------------------*/
-
-const float sincos_t[161] =
-{
- 0.0f,
- 0.0245412290096282960f, 0.0490676760673522950f, 0.0735645666718482970f, 0.0980171412229537960f, 0.1224106773734092700f,
- 0.1467304676771163900f, 0.1709618866443634000f, 0.1950903236865997300f, 0.2191012352705001800f, 0.2429801821708679200f,
- 0.2667127549648284900f, 0.2902846634387970000f, 0.3136817514896392800f, 0.3368898630142211900f, 0.3598950505256652800f,
- 0.3826834261417388900f, 0.4052413105964660600f, 0.4275550842285156300f, 0.4496113359928131100f, 0.4713967442512512200f,
- 0.4928981959819793700f, 0.5141027569770813000f, 0.5349976420402526900f, 0.5555702447891235400f, 0.5758081674575805700f,
- 0.5956993103027343800f, 0.6152315735816955600f, 0.6343932747840881300f, 0.6531728506088256800f, 0.6715589761734008800f,
- 0.6895405650138855000f, 0.7071067690849304200f, 0.7242470979690551800f, 0.7409511208534240700f, 0.7572088241577148400f,
- 0.7730104327201843300f, 0.7883464097976684600f, 0.8032075166702270500f, 0.8175848126411438000f, 0.8314695954322814900f,
- 0.8448535799980163600f, 0.8577286005020141600f, 0.8700869679450988800f, 0.8819212913513183600f, 0.8932242989540100100f,
- 0.9039893150329589800f, 0.9142097830772399900f, 0.9238795042037963900f, 0.9329928159713745100f, 0.9415440559387207000f,
- 0.9495281577110290500f, 0.9569403529167175300f, 0.9637760519981384300f, 0.9700312614440918000f, 0.9757021069526672400f,
- 0.9807852506637573200f, 0.9852776527404785200f, 0.9891765117645263700f, 0.9924795627593994100f, 0.9951847195625305200f,
- 0.9972904324531555200f, 0.9987954497337341300f, 0.9996988177299499500f, 1.0000000000000000000f, 0.9996988177299499500f,
- 0.9987954497337341300f, 0.9972904324531555200f, 0.9951847195625305200f, 0.9924795627593994100f, 0.9891765117645263700f,
- 0.9852776527404785200f, 0.9807852506637573200f, 0.9757021069526672400f, 0.9700312614440918000f, 0.9637760519981384300f,
- 0.9569403529167175300f, 0.9495281577110290500f, 0.9415440559387207000f, 0.9329928159713745100f, 0.9238795042037963900f,
- 0.9142097830772399900f, 0.9039893150329589800f, 0.8932242989540100100f, 0.8819212913513183600f, 0.8700869679450988800f,
- 0.8577286005020141600f, 0.8448535799980163600f, 0.8314695954322814900f, 0.8175848126411438000f, 0.8032075166702270500f,
- 0.7883464097976684600f, 0.7730104327201843300f, 0.7572088241577148400f, 0.7409511208534240700f, 0.7242470979690551800f,
- 0.7071067690849304200f, 0.6895405650138855000f, 0.6715589761734008800f, 0.6531728506088256800f, 0.6343932747840881300f,
- 0.6152315735816955600f, 0.5956993103027343800f, 0.5758081674575805700f, 0.5555702447891235400f, 0.5349976420402526900f,
- 0.5141027569770813000f, 0.4928981959819793700f, 0.4713967442512512200f, 0.4496113359928131100f, 0.4275550842285156300f,
- 0.4052413105964660600f, 0.3826834261417388900f, 0.3598950505256652800f, 0.3368898630142211900f, 0.3136817514896392800f,
- 0.2902846634387970000f, 0.2667127549648284900f, 0.2429801821708679200f, 0.2191012352705001800f, 0.1950903236865997300f,
- 0.1709618866443634000f, 0.1467304676771163900f, 0.1224106773734092700f, 0.0980171412229537960f, 0.0735645666718482970f,
- 0.0490676723420619960f, 0.0245412290096282960f, -0.00000000041020686847303978f, -0.0245412290096282960f, -0.0490676760673522950f,
- -0.0735645666718482970f, -0.0980171412229537960f, -0.1224106773734092700f, -0.1467304676771163900f, -0.1709618866443634000f,
- -0.1950903236865997300f, -0.2191012352705001800f, -0.2429801821708679200f, -0.2667127549648284900f, -0.2902846634387970000f,
- -0.3136817514896392800f, -0.3368898630142211900f, -0.3598950505256652800f, -0.3826834261417388900f, -0.4052413105964660600f,
- -0.4275550842285156300f, -0.4496113359928131100f, -0.4713967442512512200f, -0.4928981959819793700f, -0.5141027569770813000f,
- -0.5349976420402526900f, -0.5555702447891235400f, -0.5758081674575805700f, -0.5956993103027343800f, -0.6152315735816955600f,
- -0.6343932747840881300f, -0.6531728506088256800f, -0.6715589761734008800f, -0.6895405650138855000f, -0.7071067690849304200f
-};
-
const Word16 sincos_t_fx[161] =
{
/*Q15 */
@@ -2116,7 +1940,7 @@ const PulseConfig PulseConfTable[] =
/* Number of pulses & positions to the number of unique states that can be achieved with those pulses */
-const uint32_t pulsestostates[17][9] =
+const UWord32 pulsestostates[17][9] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 2, 2, 2, 2, 2, 2, 2, 2, 2},
@@ -11603,7 +11427,7 @@ const Word16 BitsVQ_p[]=
}; // Q0
-const int16_t predmode_tab_float[][6] =
+const Word16 predmode_tab_float[][6] =
{
{1,1,2,2,0,2},
{1,1,2,2,0,2},
@@ -12189,58 +12013,6 @@ const Word16 *const Quantizers_fx[] = { SVNB_SN1_fx, SVNB_SN2_fx, GETRNB_SN1_fx,
const Word16 *const Quantizers_p_fx[] = { IAA_MA1_fx, UVD_MA1_fx, UVD_MA2_fx, UVWB_MA3_fx, GESVNB_AR1_fx, GESVNB_AR2_fx, GESVWB_AR1_fx, GESVWB_AR2_fx,
GEWB2_MA1_fx,GEWB_MA1_fx, AUWB2_MA1_fx, SVWB2_AR1_fx, SVWB2_AR2_fx
};//Qlog2(2.56)
-const float vals[NO_LEADERS][MAX_NO_VALS]=
-{
- {1.0f, 0.0f, 0.0f, 0.0f},
- {0.5f, 0.0f, 0.0f, 0.0f},
- {1.0f, 0.0f, 0.0f, 0.0f},
- {2.0f, 0.0f, 0.0f, 0.0f},
- {1.5f, 0.5f, 0.0f, 0.0f},
- {1.0f, 0.0f, 0.0f, 0.0f},
- {2.0f, 1.0f, 0.0f, 0.0f},
- {1.5f, 0.5f, 0.0f, 0.0f},
- {1.0f, 0.0f, 0.0f, 0.0f},
- {2.0f, 1.0f, 0.0f, 0.0f},
- {2.0f, 0.0f, 0.0f, 0.0f},
- {1.5f, 0.5f, 0.0f, 0.0f},
- {2.5f, 0.5f, 0.0f, 0.0f},
- {2.0f, 1.0f, 0.0f, 0.0f},
- {2.0f, 1.0f, 0.0f, 0.0f},
- {3.0f, 1.0f, 0.0f, 0.0f},
- {1.5f, 0.5f, 0.0f, 0.0f},
- {2.5f, 1.5f, 0.5f, 0.0f},
- {2.0f, 1.0f, 0.0f, 0.0f},
- {2.0f, 0.0f, 0.0f, 0.0f},
- {3.0f, 1.0f, 0.0f, 0.0f},
- {1.5f, 0.5f, 0.0f, 0.0f},
- {2.5f, 1.5f, 0.5f, 0.0f},
- {2.0f, 1.0f, 0.0f, 0.0f},
- {2.0f, 1.0f, 0.0f, 0.0f},
- {3.0f, 1.0f, 0.0f, 0.0f},
- {3.0f, 2.0f, 1.0f, 0.0f},
- {1.5f, 0.5f, 0.0f, 0.0f},
- {2.5f, 1.5f, 0.5f, 0.0f},
- {2.5f, 0.5f, 0.0f, 0.0f},
- {3.5f, 0.5f, 0.0f, 0.0f},
- {2.0f, 1.0f, 0.0f, 0.0f},
- {2.0f, 0.0f, 0.0f, 0.0f},
- {3.0f, 1.0f, 0.0f, 0.0f},
- {3.0f, 2.0f, 1.0f, 0.0f},
- {4.0f, 0.0f, 0.0f, 0.0f},
- {1.5f, 0.5f, 0.0f, 0.0f},
- {2.5f, 1.5f, 0.5f, 0.0f},
- {2.5f, 1.5f, 0.5f, 0.0f},
- {3.5f, 1.5f, 0.5f, 0.0f},
- {2.0f, 1.0f, 0.0f, 0.0f},
- {3.0f, 2.0f, 1.0f, 0.0f},
- {3.0f, 2.0f, 1.0f, 0.0f},
- {3.0f, 0.0f, 0.0f, 0.0f},
- {4.0f, 1.0f, 0.0f, 0.0f},
- {1.5f, 0.0f, 0.0f, 0.0f},
- {2.5f, 1.5f, 0.5f, 0.0f},
- {2.5f, 1.5f, 0.5f, 0.0f},
- {3.5f, 1.5f, 0.5f, 0.0f}
-};
const Word16 vals_fx[NO_LEADERS][MAX_NO_VALS] = /*Q1 */
{
@@ -12486,449 +12258,6 @@ const Word16 pl_par[] = /* 1 if even number of signs */
0, 0, 0, 0, -1, 1, -1, 1, 0, 0, 0, 0, 0, 1, -1, 1, -1
}; // Q0
-const float scales[][MAX_NO_SCALES*2]= /* 2 subvectors */
-{
- {1.528f, 0.000f, 0.000f, 1.532f, 0.000f, 0.000f, }, /* 14 */
- {1.605f, 0.000f, 0.000f, 1.532f, 0.000f, 0.000f, }, /* 15 */
- {1.275f, 2.458f, 0.000f, 1.532f, 0.000f, 0.000f, }, /* 18 */
- {1.275f, 2.458f, 0.000f, 1.631f, 0.000f, 0.000f, }, /* 19 */
- {1.057f, 1.794f, 2.896f, 1.154f, 1.860f, 3.067f, }, /* 25 */
- {0.927f, 1.458f, 2.317f, 1.033f, 1.791f, 3.440f, }, /* 28*/ /* mode 0 UV WB*/
-
- {1.284f, 2.676f, 0.000f, 1.451f, 0.000f, 0.000f, }, /* 18 */
- {1.368f, 0.000f, 0.000f, 1.401f, 2.477f, 0.000f, }, /* 19 */
- {0.861f, 1.243f, 1.818f, 1.228f, 2.226f, 10.307f, }, /* 24 */
- {1.072f, 1.934f, 3.633f, 1.221f, 2.938f, 10.723f, }, /* 25 */
- {0.899f, 1.417f, 0.677f, 1.033f, 1.837f, 10.893f, }, /* 29 */
- {0.830f, 1.323f, 0.629f, 0.911f, 1.585f, 10.088f, }, /* 32 */ /* mode 1 UV NB*/
- {1.573f, 0.000f, 0.000f, 1.656f, 0.000f, 0.000f, }, /* 17 */
- {1.239f, 2.404f, 0.000f, 1.556f, 0.000f, 0.000f, }, /* 18 */
- {1.375f, 2.065f, 3.124f, 1.795f, 0.000f, 0.000f, }, /* (18.745) 19 */
- {1.375f, 2.065f, 3.124f, 1.901f, 0.000f, 0.000f, }, /* (19.838) 20 */
- {1.055f, 1.700f, 4.439f, 1.656f, 0.000f, 0.000f, }, /* 21 */
- {1.250f, 2.404f, 4.132f, 1.355f, 2.361f, 0.000f, }, /* 22 */
- {1.246f, 1.857f, 2.744f, 1.500f, 2.704f, 0.000f, }, /* (22.959) 23 */
- {1.243f, 2.054f, 3.638f, 1.577f, 0.000f, 0.000f, }, /* (23.949) 24 */
- {1.056f, 1.785f, 4.523f, 1.318f, 2.586f, 0.000f, }, /* 25 */
- {0.996f, 1.505f, 3.355f, 1.185f, 1.776f, 2.728f, },
- {0.929f, 1.387f, 3.357f, 1.080f, 1.701f, 2.885f, },
- {0.922f, 1.493f, 3.369f, 1.080f, 1.701f, 2.885f, },
- {0.922f, 1.493f, 3.369f, 1.066f, 1.694f, 3.135f, },
- {0.922f, 1.493f, 3.369f, 0.962f, 1.550f, 3.946f, }, /* 30 */
- {1.286f, 0.906f, 2.422f, 1.124f, 1.698f, 2.482f, }, /* (30.994) 31 */
- {0.746f, 1.108f, 2.869f, 0.959f, 1.481f, 3.907f, }, /* 32 */
- {0.770f, 1.194f, 2.823f, 0.907f, 1.402f, 2.116f, }, /* 33*/
- {0.748f, 1.103f, 2.866f, 1.182f, 0.811f, 3.332f, }, /* 34*/
- {0.765f, 1.132f, 1.844f, 1.242f, 1.893f, 0.922f, }, /* (34.981) 35 */
- {0.766f, 1.133f, 1.846f, 1.066f, 1.641f, 0.813f, }, /* (35.998) 36 */
- {0.677f, 0.963f, 2.127f, 0.726f, 1.082f, 2.204f, }, /* 37*/ /* mode 2 V WB*/
-
- {1.639f, 0.000f, 0.000f, 1.218f, 2.161f, 0.000f, }, /* 17 */
- {1.286f, 2.446f, 0.000f, 1.410f, 0.000f, 0.000f, }, /* 18 */
- {1.086f, 1.728f, 3.758f, 1.218f, 2.161f, 0.000f, }, /* 22 */
- {1.035f, 1.575f, 4.815f, 1.218f, 2.161f, 0.000f, }, /* 23 */
- {0.964f, 1.533f, 4.942f, 1.218f, 2.161f, 0.000f, }, /* 24 */
- {0.841f, 1.198f, 1.982f, 1.218f, 2.161f, 0.000f, }, /* 25 */
- {0.898f, 1.298f, 2.184f, 1.216f, 2.664f, 0.000f, }, /* 27 */
- {0.841f, 1.237f, 2.237f, 0.995f, 1.657f, 2.836f, }, /* 29 */
- {0.697f, 0.981f, 2.043f, 0.935f, 1.505f, 0.659f, }, /* 34 */
- {0.669f, 0.909f, 1.328f, 0.985f, 0.654f, 1.911f, }, /* 37 */ /* mode 3 V NB*/
-
- {1.212f, 1.897f, 0.000f, 0.000f, 0.000f, 0.000f, }, /* 12 (11.883) */
- {1.160f, 1.869f, 3.406f, 0.000f, 0.000f, 0.000f, }, /* (12.997) 13 */
- {1.658f, 0.000f, 0.000f, 1.896f, 0.000f, 0.000f, }, /* (13.640) 14 */
- {1.740f, 0.000f, 0.000f, 1.896f, 0.000f, 0.000f, }, /* (14.733) 15 */
- {1.634f, 0.000f, 0.000f, 1.669f, 0.000f, 0.000f, }, /* 16 (15.826) */
- {1.740f, 0.000f, 0.000f, 2.016f, 0.000f, 0.000f, }, /* (15.826) 16 */
- {1.377f, 2.548f, 0.000f, 1.896f, 0.000f, 0.000f, }, /* (17.479) 18 */
- {1.288f, 2.423f, 0.000f, 1.669f, 0.000f, 0.000f, }, /* 19 (18.572) */
- {1.212f, 1.897f, 0.000f, 1.669f, 0.000f, 0.000f, }, /* 20 (19.796) */
- {1.083f, 1.766f, 3.175f, 1.669f, 0.000f, 0.000f, }, /* 21 (20.910) */
- {1.037f, 1.609f, 4.228f, 1.669f, 0.000f, 0.000f, }, /* 22 (21.776) */
- {1.095f, 1.659f, 2.716f, 1.315f, 2.506f, 0.000f, }, /* 23 (22.959) */
- {1.166f, 1.965f, 3.654f, 1.686f, 0.000f, 0.000f, }, /* (23.949) 24 */
- {0.941f, 1.386f, 2.221f, 1.315f, 2.506f, 0.000f, }, /* 25 (24.992) */
- {0.908f, 1.306f, 1.901f, 1.320f, 2.623f, 0.000f, }, /* 26 (25.904) */
- {1.075f, 1.767f, 0.790f, 1.320f, 2.623f, 0.000f, }, /* 27 (26.829) */
- {1.022f, 1.531f, 0.759f, 1.110f, 1.755f, 2.594f, }, /* 28 (27.989) */
- {1.075f, 1.767f, 0.790f, 1.093f, 1.902f, 3.014f, }, /* 29 (28.984) */
- {0.893f, 1.472f, 0.675f, 1.103f, 1.770f, 2.842f, }, /* 30 (29.980) */
- {0.910f, 1.548f, 0.685f, 1.032f, 1.651f, 2.513f, }, /* 31 (30.966) */
- {0.826f, 1.256f, 0.632f, 0.981f, 1.542f, 2.217f, }, /* 32 (31.995) */ /* G WB*/
-
- {1.184f, 1.810f, 2.761f, 0.000f, 0.000f, 0.000f, }, /* 12 (11.925) */
- {1.611f, 0.000f, 0.000f, 1.618f, 0.000f, 0.000f, }, /* 16 (15.826) */
- {1.184f, 1.810f, 2.761f, 1.550f, 0.000f, 0.000f, }, /* 19 (18.745) */
- {1.184f, 1.810f, 2.761f, 1.618f, 0.000f, 0.000f, }, /* 20 (19.838) */
- {1.063f, 1.737f, 2.985f, 1.618f, 0.000f, 0.000f, }, /* 21 (20.910) */
- {1.078f, 1.825f, 3.162f, 1.469f, 2.249f, 0.000f, }, /* 22 (21.985) */
- {1.375f, 0.915f, 2.082f, 1.469f, 2.249f, 0.000f, }, /* 23 (22.815) */
- {0.960f, 1.423f, 0.700f, 1.310f, 2.132f, 0.000f, }, /* 25 (24.996) */
- {1.124f, 0.794f, 1.902f, 1.283f, 2.302f, 0.000f, }, /* 26 (25.993) */
- {1.077f, 1.727f, 0.767f, 1.250f, 1.951f, 2.981f, }, /* 27 (26.954) */
- {0.933f, 1.471f, 0.685f, 1.250f, 1.951f, 2.981f, }, /* 28 (27.992) */
- {0.927f, 1.600f, 0.674f, 1.154f, 1.776f, 2.854f, }, /* 29 (28.996) */
- {1.047f, 0.722f, 1.785f, 1.056f, 1.642f, 2.701f, }, /* 30 (29.988) */
- {0.971f, 0.688f, 1.509f, 1.043f, 1.730f, 2.931f, }, /* 31 (30.962) */
- {0.919f, 0.662f, 1.367f, 1.057f, 1.808f, 3.069f, }, /* 32 (31.987) */ /* G NB*/
-
- {1.617f, 0.000f, 0.000f, 1.657f, 0.000f, 0.000f, }, /* 17 */
- {1.275f, 2.298f, 0.000f, 1.563f, 0.000f, 0.000f, }, /* 18 */
- {1.377f, 2.548f, 0.000f, 2.016f, 0.000f, 0.000f, }, /* (18.572) 19 */ /* from GEWB */
- {1.299f, 2.019f, 0.000f, 2.016f, 0.000f, 0.000f, }, /* (19.796) 20 */
- {1.308f, 2.354f, 0.000f, 1.387f, 0.000f, 0.000f, }, /* 21 */
- {1.291f, 2.418f, 0.000f, 1.355f, 2.443f, 0.000f, }, /* 22 */
- {1.173f, 1.767f, 2.796f, 1.588f, 3.028f, 0.000f, }, /* (22.959) 23 */ /* from GEWB */
- {1.079f, 1.769f, 3.012f, 1.387f, 0.000f, 0.000f, }, /* 24 */
- {1.079f, 1.769f, 3.012f, 1.325f, 2.555f, 0.000f, }, /* 25 */
- {0.973f, 1.392f, 2.014f, 1.593f, 3.183f, 0.000f, }, /* (25.904) 26 */ /* from GEWB */
- {1.149f, 1.873f, 0.848f, 1.593f, 3.183f, 0.000f, }, /* (26.829) 27 */
- {0.897f, 1.340f, 2.604f, 1.070f, 1.689f, 2.527f, }, /* 28 */
- {1.149f, 1.873f, 0.848f, 1.319f, 2.288f, 3.687f, }, /* (28.984) 29 */ /* from GEWB */
- {0.897f, 1.340f, 2.604f, 0.939f, 1.454f, 2.083f, }, /* 30 */
- {0.905f, 1.327f, 2.599f, 1.109f, 0.777f, 1.705f, },
- {0.762f, 1.101f, 2.359f, 0.939f, 1.454f, 2.083f, },
- {0.794f, 1.226f, 3.180f, 1.109f, 0.777f, 1.705f, }, /* 33 */ /* mode 6 T WB */
-
- {1.629f, 0.000f, 0.000f, 1.191f, 2.211f, 0.000f, }, /* 17 */
- {1.277f, 2.557f, 0.000f, 1.367f, 0.000f, 0.000f, }, /* 18 */
- {1.082f, 1.761f, 3.929f, 1.191f, 2.211f, 0.000f, }, /* 22 */
- {1.018f, 1.535f, 2.808f, 1.191f, 2.211f, 0.000f, }, /* 23 */
- {0.944f, 1.477f, 2.763f, 1.191f, 2.211f, 0.000f, }, /* 24 */
- {0.910f, 1.744f, 3.317f, 1.191f, 2.211f, 0.000f, }, /* 25 */
- {0.920f, 1.648f, 3.068f, 0.969f, 1.683f, 3.953f, }, /* 28 */
- {0.739f, 1.111f, 2.694f, 0.879f, 1.411f, 2.305f, }, /* 31 */
- {0.709f, 1.032f, 2.717f, 0.810f, 1.245f, 1.824f, }, /* 32*/ /* mode 7 T NB*/
-
- {0.758f, 1.116f, 1.964f, 2.021f, 0.798f, 1.219f, }, /* 31 */
- {0.699f, 1.034f, 1.978f, 2.021f, 0.798f, 1.219f, }, /* 32 */ /* mode 8 G 16k */
-
- {0.726f, 1.050f, 1.845f, 1.355f, 0.860f, 2.205f, }, /* 32 (31.998) */
- {0.677f, 0.997f, 1.669f, 1.355f, 0.860f, 2.205f, }, /* 33 (32.983) mode 9 T16k */
-
- {1.646f, 0.000f, 0.000f, 1.254f, 2.459f, 0.000f, }, /* 17 */
- {1.480f, 2.941f, 0.000f, 1.823f, 0.000f, 0.000f, }, /* (17.479) 18 */
- {1.368f, 2.297f, 0.000f, 1.823f, 0.000f, 0.000f, }, /* (18.703) 19 */
- {1.368f, 2.297f, 0.000f, 1.985f, 0.000f, 0.000f, }, /* (19.796) 20 */
- {1.073f, 1.863f, 3.231f, 1.678f, 0.000f, 0.000f, }, /* 21 */
- {1.073f, 1.863f, 3.231f, 1.254f, 2.459f, 0.000f, }, /* 22 */
- {1.056f, 1.577f, 2.467f, 1.806f, 2.990f, 0.000f, }, /* (22.917) 23 */
- {1.130f, 1.818f, 0.836f, 1.985f, 0.000f, 0.000f, }, /* (23.978) 24 */
- {0.951f, 1.492f, 2.496f, 1.255f, 2.971f, 0.000f, }, /* 25 */
- {1.148f, 1.841f, 0.813f, 1.255f, 2.971f, 0.000f, }, /* 26 */
- {1.148f, 0.809f, 1.920f, 1.530f, 2.736f, 0.000f, }, /* (26.953) 27 */
- {1.206f, 0.851f, 2.180f, 1.513f, 3.176f, 0.000f, }, /* (27.992) 28 */
- {0.804f, 1.200f, 1.976f, 1.504f, 3.210f, 0.000f, }, /* (28.992) 29 */
- {1.141f, 0.806f, 1.915f, 1.973f, 1.166f, 3.713f, }, /* (29.976) 30 */
- {1.118f, 0.778f, 2.026f, 1.239f, 2.139f, 3.775f, }, /* (30.963) 31 */
- {0.770f, 1.134f, 1.915f, 1.231f, 2.298f, 3.880f, }, /* (31.995) 32 */
- {1.025f, 0.709f, 1.731f, 1.231f, 2.298f, 3.880f, }, /* (32.996) 33 */
- {0.967f, 0.713f, 1.653f, 1.840f, 1.100f, 2.829f, }, /* (33.994) 34 */
- {0.989f, 0.698f, 1.601f, 1.086f, 1.964f, 2.882f, }, /* (34.954) 35 */
- {0.602f, 0.869f, 1.418f, 1.264f, 0.764f, 2.218f}, /* 36 */ /* mode 10 AUDIO_WB LVQ bitrate 15-36 + 4 + 1*/
-
- {0.853f, 1.769f, 4.425f, 1.000f, 1.000f, 1.000f}, /* 17 */
- {1.011f, 1.663f, 4.403f, 1.578f, 0.000f, 0.000f}, /* 21 */
- {1.011f, 1.663f, 4.403f, 1.202f, 2.424f, 0.000f}, /* 22 */
- {0.881f, 1.618f, 4.136f, 1.202f, 2.424f, 0.000f}, /* 25 */
- {0.847f, 1.791f, 4.466f, 1.202f, 2.424f, 0.000f}, /* 26 */
- {0.670f, 1.112f, 2.389f, 1.202f, 2.424f, 0.000f}, /* 28 */ /* mode 11 AUDIO_NB */
-
- {1.131f, 1.815f, 0.796f, 1.265f, 2.794f, 0.000f, }, /* 26 */
- {0.570f, 0.804f, 1.197f, 1.162f, 1.949f, 0.728f, }, /* 36*/ /* mode 12 AUDIO_WB 16k bitrate 15-36 + 4 + 1*/
-
- {1.045f, 1.586f, 3.754f, 1.669f, 0.000f, 0.000f, }, /* 22 (21.776) */
- {1.100f, 1.604f, 2.295f, 1.334f, 2.423f, 0.000f, }, /* (22.959) 23 */
- {1.091f, 1.752f, 3.164f, 1.407f, 0.000f, 0.000f, }, /* (23.949) 24 */
- {1.091f, 1.752f, 3.164f, 1.346f, 2.525f, 0.000f, }, /* (24.889) 25 */
- {1.091f, 1.752f, 3.164f, 1.089f, 1.684f, 2.523f, }, /* (25.821) 26 */
- {0.940f, 1.349f, 1.903f, 1.199f, 1.790f, 2.564f, }, /* (26.982) 27 */
- {0.880f, 1.280f, 2.824f, 1.099f, 1.735f, 0.000f, }, /* 28 (27.994) */
- {0.831f, 1.215f, 2.927f, 1.089f, 1.708f, 2.479f, }, /* 29 (28.996) */
- {0.870f, 1.327f, 2.906f, 1.066f, 1.719f, 2.676f, }, /* 30 (29.991) */
- {0.765f, 3.115f, 1.818f, 1.123f, 2.309f, 4.775f, }, /* (30.985) 31 */
- {0.772f, 1.122f, 2.351f, 1.446f, 0.944f, 2.072f, }, /* 32 (31.992) */
- {0.701f, 0.977f, 1.738f, 0.947f, 1.453f, 2.082f, }, /* 33 (32.993) */
- {0.719f, 1.021f, 1.701f, 1.119f, 0.794f, 1.696f, }, /* 34 (33.968) */
- {0.839f, 0.640f, 1.522f, 1.118f, 1.697f, 0.796f, }, /* (34.968) 35 */
- {0.839f, 0.640f, 1.522f, 0.961f, 1.469f, 0.707f, }, /* (35.990) 36 */
- {0.640f, 0.884f, 1.732f, 0.755f, 1.090f, 1.548f, }, /* 37 (36.995) */ /* VOICED 16k */
- /* 5sf */
- {1.218f, 0.796f, 2.283f, 1.290f, 3.325f, 0.000f, }, /* 25 (24.980) */
- {1.590f, 0.835f, 4.436f, 1.097f, 3.070f, 0.000f, }, /* 25 (24.974) */
- {0.994f, 2.617f, 0.000f, 1.091f, 2.233f, 3.457f, }, /* 25 (24.852) */
- {0.887f, 1.573f, 3.543f, 1.088f, 1.827f, 3.067f, }, /* 25 (24.994) */
- {0.837f, 1.238f, 1.903f, 1.298f, 2.797f, 0.000f, }, /* 25 (24.996) */
- {1.138f, 2.826f, 0.000f, 1.106f, 2.796f, 4.391f, }, /* 25 (24.671) */
-
- /* 4sf */
- {0.941f, 1.931f, 4.473f, 0.681f, 1.266f, 2.328f, }, /* 25 (24.936) */
- {1.352f, 4.332f, 0.000f, 0.820f, 1.545f, 4.175f, }, /* 25 (24.955) */
- {1.343f, 3.607f, 0.000f, 0.859f, 1.453f, 2.590f, }, /* 25 (24.853) */
- {1.208f, 2.740f, 0.000f, 0.759f, 1.240f, 2.182f, }, /* 25 (24.881) */
- {1.123f, 2.736f, 0.000f, 0.874f, 1.498f, 2.586f, }, /* 25 (24.939) */
- {0.919f, 2.471f, 0.000f, 0.615f, 1.072f, 2.096f, }, /* 25 (24.996) */
- {1.548f, 4.508f, 0.000f, 0.825f, 2.178f, 4.305f, }, /* 25 (24.310) */
- {1.217f, 2.898f, 0.000f, 0.737f, 1.217f, 1.930f, }, /* 25 (24.955) */
- {0.976f, 2.190f, 5.716f, 1.506f, 0.642f, 4.211f, }, /* 25 (24.984) */
- {1.107f, 2.595f, 0.000f, 1.302f, 0.604f, 0.880f, }, /* 25 (24.866) */
-};
-
-const float scales_p[][MAX_NO_SCALES*2]= /* 2 subvectors 20 modes */
-{
- {1.464f, 2.374f, 0.000f, 0.000f, 0.000f, 0.000f, }, /* 9 (8.464) */
- {1.284f, 2.159f, 0.000f, 0.000f, 0.000f, 0.000f, }, /* (8.910) 9 */
- {1.245f, 2.590f, 0.000f, 0.000f, 0.000f, 0.000f, }, /* (10.659) 11 */
- {1.142f, 1.858f, 2.927f, 0.000f, 0.000f, 0.000f, }, /* (11.925) 12 */
- {1.038f, 1.837f, 3.009f, 0.000f, 0.000f, 0.000f, }, /* (12.997) 13 */
- {1.515f, 0.000f, 0.000f, 1.540f, 0.000f, 0.000f, }, /* (13.640) 14 */
- {1.584f, 0.000f, 0.000f, 1.540f, 0.000f, 0.000f, }, /* (14.733) 15 */
- {1.584f, 0.000f, 0.000f, 1.620f, 0.000f, 0.000f, }, /* (15.826) 16 */
- {1.284f, 2.159f, 0.000f, 1.620f, 0.000f, 0.000f, }, /* (16.823) 17 */
- {1.245f, 2.590f, 0.000f, 1.540f, 0.000f, 0.000f, }, /* (17.479) 18 */
- {1.265f, 2.564f, 0.000f, 1.638f, 0.000f, 0.000f, }, /* 19 (18.572) */
- {1.142f, 1.858f, 2.927f, 1.620f, 0.000f, 0.000f, }, /* (19.838) 20 */
- {1.038f, 1.837f, 3.009f, 1.620f, 0.000f, 0.000f, }, /* (20.910) 21 */
- {0.988f, 1.661f, 2.539f, 1.620f, 0.000f, 0.000f, }, /* (21.776) 22 */
- {1.063f, 1.703f, 2.805f, 1.294f, 2.353f, 0.000f, }, /* 23 (22.959) */
- {1.063f, 1.917f, 3.063f, 1.365f, 0.000f, 0.000f, }, /* 24 (23.949) */
- {0.914f, 1.412f, 2.223f, 1.294f, 2.353f, 0.000f, }, /* 25 (24.992) */
- {0.900f, 1.410f, 2.254f, 1.298f, 2.413f, 0.000f, }, /* (25.718) 26 */
- {0.882f, 1.401f, 2.402f, 1.313f, 2.441f, 0.000f, }, /* 27 (26.902) */
- {1.356f, 0.867f, 2.377f, 1.070f, 1.686f, 2.546f, }, /* 28 (27.996) */
- {0.846f, 1.348f, 2.546f, 1.076f, 1.742f, 2.658f, }, /* 29 (28.937) */
- {0.845f, 1.379f, 2.566f, 1.019f, 1.577f, 2.443f, }, /* 30 (29.954) */
- {0.756f, 1.189f, 2.799f, 1.084f, 1.804f, 2.758f, }, /* 31 (30.978) */
- {0.755f, 1.218f, 2.821f, 0.944f, 1.433f, 1.973f, }, /* 32 (31.978) */
- {0.745f, 1.197f, 2.898f, 1.242f, 0.843f, 1.952f, }, /* (32.988) 33 */
- {0.724f, 1.235f, 2.942f, 1.255f, 0.848f, 2.000f, }, /* 34 (33.975) */
- {0.687f, 1.113f, 2.338f, 0.853f, 1.328f, 1.944f, }, /* 35 (34.975) */
- {0.648f, 1.029f, 1.836f, 0.854f, 1.356f, 1.961f, }, /* 36 (35.889) */
- {0.607f, 0.934f, 1.517f, 0.783f, 1.213f, 1.534f, }, /* (36.996) 37 */
- {0.599f, 0.905f, 1.529f, 0.731f, 1.111f, 1.500f, }, /* (37.993) 38 */
- {0.648f, 1.029f, 1.836f, 0.687f, 1.058f, 1.900f, }, /* 39 (38.488) */ /* V WB*/
-
- {1.613f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, }, /* 8 (7.913) */
- {1.267f, 2.475f, 0.000f, 1.619f, 0.000f, 0.000f, }, /* 19 (18.572) */
- {1.014f, 1.630f, 2.464f, 1.285f, 2.151f, 0.000f, }, /* 23 (22.773) */
- {0.893f, 1.390f, 2.314f, 1.465f, 2.299f, 0.000f, }, /* 24 (23.999) */
- {0.930f, 1.401f, 2.150f, 1.280f, 2.254f, 0.000f, }, /* 25 (24.992) */
- {0.893f, 1.390f, 2.314f, 1.276f, 2.206f, 2.984f, }, /* 27 (26.962) */
- {0.893f, 1.390f, 2.314f, 1.036f, 1.646f, 2.471f, }, /* 28 (27.835) */
- {0.857f, 1.337f, 2.464f, 1.043f, 1.730f, 2.625f, }, /* 29 (28.937) */
- {0.765f, 1.219f, 1.553f, 1.036f, 1.646f, 2.471f, }, /* 30 (29.969) */
- {0.789f, 1.328f, 1.652f, 1.052f, 1.784f, 2.706f, }, /* 31 (30.952) */
- {0.764f, 1.224f, 1.555f, 0.920f, 1.443f, 2.035f, }, /* 32 (31.978) */
- {0.663f, 1.061f, 1.238f, 1.379f, 0.898f, 1.951f, }, /* 34 (33.992) */
- {0.673f, 1.104f, 1.306f, 1.259f, 0.828f, 1.954f, }, /* 35 (35.000) */
- {0.666f, 1.071f, 1.249f, 0.803f, 1.241f, 1.729f, }, /* 36 (35.980) */
- {0.658f, 1.039f, 1.214f, 0.950f, 0.651f, 1.429f, }, /* 39 (38.512) */ /* V NB*/
-
- {1.600f, 0.000f, 0.000f, 1.553f, 0.000f, 0.000f, }, /* 15 (14.733) */
- {1.306f, 2.427f, 0.000f, 1.580f, 0.000f, 0.000f, }, /* (15.730) 16 */
- {1.306f, 2.427f, 0.000f, 1.676f, 0.000f, 0.000f, }, /* (16.823) 17 */
- {1.250f, 2.894f, 0.000f, 1.580f, 0.000f, 0.000f, }, /* (17.479) 18 */
- {1.134f, 1.986f, 3.295f, 1.553f, 0.000f, 0.000f, }, /* 19 (18.745) */
- {1.143f, 2.052f, 3.345f, 1.676f, 0.000f, 0.000f, }, /* (19.838) 20 */
- {1.044f, 2.031f, 3.487f, 1.676f, 0.000f, 0.000f, }, /* (20.910) 21 */
- {0.987f, 1.788f, 2.659f, 1.647f, 0.000f, 0.000f, }, /* 22 (21.776) */
- {0.899f, 1.602f, 2.579f, 1.647f, 0.000f, 0.000f, }, /* 23 (22.791) */
- {0.797f, 1.294f, 2.140f, 1.647f, 0.000f, 0.000f, }, /* 24 (23.999) */
- {0.797f, 1.294f, 2.140f, 1.335f, 2.225f, 0.000f, }, /* 25 (24.996) */
- {0.741f, 1.151f, 1.816f, 1.335f, 2.225f, 0.000f, }, /* 26 (25.934) */
- {0.980f, 1.702f, 0.706f, 1.317f, 2.628f, 0.000f, }, /* (26.887) 27 */
- {0.797f, 1.294f, 2.140f, 1.186f, 1.932f, 0.000f, }, /* 28 (27.969) */
- {0.741f, 1.151f, 1.816f, 1.164f, 1.823f, 2.769f, }, /* 29 (28.996) */
- {0.708f, 1.126f, 1.953f, 1.076f, 1.730f, 2.777f, }, /* 30 (29.988) */
- {0.660f, 1.049f, 1.571f, 1.076f, 1.730f, 2.777f, }, /* 31 (30.931) */
- {0.662f, 1.026f, 1.554f, 1.074f, 1.913f, 3.022f, }, /* 32 (31.987) */
- {0.660f, 1.049f, 1.571f, 1.439f, 0.926f, 2.131f, }, /* 33 (32.982) */
- {0.630f, 0.966f, 1.522f, 1.312f, 0.881f, 2.207f, }, /* 34 (33.967) */
- {0.617f, 0.921f, 1.447f, 1.032f, 1.549f, 0.756f, }, /* 35 (34.994) */ /* G WB*/
-
- {1.595f, 0.000f, 0.000f, 1.502f, 0.000f, 0.000f, }, /* 15 (14.733) */
- {1.123f, 1.946f, 3.732f, 1.502f, 0.000f, 0.000f, }, /* 19 (18.792) */
- {1.033f, 2.075f, 4.339f, 1.419f, 2.446f, 0.000f, }, /* 22 (21.985) */
- {0.985f, 1.793f, 5.965f, 1.281f, 2.324f, 0.000f, }, /* 23 (22.773) */
- {0.881f, 1.606f, 6.995f, 1.419f, 2.446f, 0.000f, }, /* 24 (23.932) */
- {0.844f, 1.582f, 7.020f, 1.281f, 2.324f, 0.000f, }, /* 25 (24.955) */
- {0.789f, 1.520f, 7.203f, 1.281f, 2.324f, 0.000f, }, /* 26 (25.991) */
- {0.869f, 1.547f, 6.995f, 1.030f, 1.754f, 3.102f, }, /* 28 (27.979) */
- {0.817f, 1.492f, 7.120f, 1.030f, 1.754f, 3.102f, }, /* 29 (28.878) */
- {0.755f, 1.382f, 7.133f, 1.030f, 1.754f, 3.102f, }, /* 30 (29.954) */
- {0.706f, 1.315f, 7.225f, 1.030f, 1.754f, 3.102f, }, /* 31 (30.893) */
- {0.689f, 1.296f, 7.290f, 1.016f, 1.875f, 3.239f, }, /* 32 (31.963) */
- {0.698f, 1.275f, 7.209f, 0.914f, 1.548f, 2.433f, }, /* 33 (32.997) */
- {0.679f, 1.315f, 7.290f, 1.229f, 1.845f, 0.813f, }, /* 34 (33.986) */
- {0.679f, 1.315f, 7.290f, 1.188f, 0.772f, 1.955f, }, /* 35 (34.952) */ /* G NB*/
-
- {1.011f, 1.777f, 2.760f, 1.614f, 0.000f, 0.000f, }, /* 21 */
- {0.964f, 1.580f, 3.996f, 1.729f, 0.000f, 0.000f, }, /* (21.776) 22 */
- {0.878f, 1.440f, 2.289f, 1.729f, 0.000f, 0.000f, }, /* (22.784) 23 */
- {0.852f, 1.643f, 2.429f, 1.729f, 0.000f, 0.000f, }, /* (23.980) 24 */
- {0.853f, 1.382f, 2.066f, 1.245f, 2.679f, 0.000f, }, /* 25 */
- { 1.207f, 0.778f, 2.208f, 1.245f, 2.679f, 0.000f, }, /* 26 */
- {0.804f, 1.354f, 2.647f, 1.408f, 2.615f, 0.000f, }, /* (26.931) 27 */
- {0.782f, 1.254f, 2.799f, 1.378f, 2.708f, 0.000f, }, /* (27.977) 28 */
- { 1.207f, 0.778f, 2.208f, 1.013f, 1.832f, 3.053f, }, /* 29 */
- {1.207f, 0.778f, 2.208f, 1.420f, 0.872f, 2.330f, }, /* 30 */
- {0.683f, 1.016f, 1.788f, 1.126f, 1.886f, 2.924f, }, /* (30.993) 31 */
- {0.627f, 0.917f, 1.448f, 1.126f, 1.886f, 2.924f, }, /* (31.998) 32 */
- {0.658f, 1.028f, 1.557f, 1.482f, 0.975f, 2.147f, }, /* (32.996) 33 */
- {0.794f, 0.580f, 1.331f, 1.482f, 0.975f, 2.147f, }, /* (33.994) 34 */
- {0.823f, 0.592f, 1.323f, 1.346f, 0.895f, 2.308f, }, /* (34.999) 35 */
- {1.098f, 0.738f, 0.555f, 0.869f, 1.290f, 1.862f, }, /* (35.984) 36 */
- {0.758f, 1.111f, 0.550f, 0.871f, 1.367f, 1.906f, }, /* (36.969) 37 */
- {0.551f, 0.766f, 1.116f, 0.791f, 1.201f, 1.663f, }, /* (37.971) 38 */
- {0.551f, 0.766f, 1.116f, 0.963f, 0.697f, 1.323f, }, /* (38.973) 39 */
- {0.525f, 0.770f, 1.073f, 0.815f, 1.237f, 0.567f,}, /* 40 */ /* mode 7 AUDIO_WB 19-40 + 0 + 1 */
-
- {1.070f, 1.791f, 3.903f, 1.599f, 0.000f, 0.000f}, /* 21 */
- {0.820f, 1.217f, 2.089f, 1.255f, 2.290f, 0.000f}, /* 25 */
- {0.780f, 1.169f, 2.495f, 1.255f, 2.290f, 0.000f}, /* 26 */
- {1.075f, 0.723f, 2.361f, 1.110f, 1.961f, 3.491f}, /* 30 */
- {0.691f, 1.029f, 2.337f, 1.034f, 1.791f, 4.004f}, /* 31 */
- {0.671f, 1.076f, 2.606f, 0.955f, 1.547f, 2.514f}, /* 32 */ /*mode 8 AUDIO_NB */
-
- {1.184f, 0.776f, 2.117f, 1.057f, 1.670f, 0.674f,}, /* 30 */
- {0.946f, 1.448f, 2.723f, 1.394f, 2.645f, 4.581f, }, /* (30.967) 31 */
- {0.948f, 1.454f, 2.723f, 1.970f, 1.174f, 3.484f, }, /* (31.990) 32 */
- {0.885f, 1.406f, 2.763f, 1.970f, 1.174f, 3.484f, }, /* (32.979) 33 */
- {1.245f, 0.842f, 2.378f, 1.999f, 1.168f, 3.682f, }, /* (33.989) 34 */
- {0.870f, 1.346f, 2.814f, 1.744f, 1.058f, 2.897f, }, /* (34.991) 35 */
- {0.827f, 1.219f, 2.176f, 1.588f, 2.600f, 0.995f, }, /* (35.990) 36 */
- {0.817f, 1.186f, 1.992f, 1.593f, 0.974f, 2.619f, }, /* (36.986) 37 */
- {0.822f, 1.205f, 2.099f, 1.464f, 0.904f, 2.398f, }, /* (37.982) 38 */
- {0.822f, 1.205f, 2.099f, 2.053f, 0.837f, 1.359f, }, /* (38.995) 39 */
- {0.521f, 0.747f, 1.033f, 0.796f, 1.333f, 0.542f,}, /* 40 */ /* mode 9 AUDIO_WB 16k 30-40 + 5 MA pred for WB2 (AV: not used?)*/
-
- {1.679f, 0.000f, 0.000f, 1.282f, 2.471f, 0.000f, }, /* 17 (16.823) */
- {1.088f, 1.849f, 3.195f, 1.687f, 0.000f, 0.000f, }, /* 21 (20.910) */
- {1.088f, 1.849f, 3.195f, 1.282f, 2.471f, 0.000f, }, /* 22 (21.907) */
- {1.126f, 1.689f, 0.790f, 1.282f, 2.471f, 0.000f, }, /* 25 (24.863) */
- {0.930f, 1.382f, 0.682f, 1.282f, 2.471f, 0.000f, }, /* 26 (25.921) */
- {1.115f, 0.794f, 1.852f, 1.281f, 3.033f, 0.000f, }, /* 27 (26.837) */
- {0.840f, 1.376f, 0.623f, 0.800f, 1.416f, 4.260f, }, /* 36 (35.998) */ /* INACTIVE NB */
-
- {0.801f, 1.148f, 1.802f, 0.000f, 0.000f, 0.000f, }, /* 17 (16.932) */
- {1.344f, 2.627f, 0.000f, 1.574f, 0.000f, 0.000f, }, /* (17.479) 18 */
- {1.260f, 2.045f, 0.000f, 1.574f, 0.000f, 0.000f, }, /* (18.703) 19 */
- {1.260f, 2.045f, 0.000f, 1.675f, 0.000f, 0.000f, }, /* (19.796) 20 */
- {1.089f, 1.812f, 3.172f, 1.677f, 0.000f, 0.000f, }, /* 21 (20.910) */
- {1.089f, 1.904f, 3.221f, 1.521f, 2.635f, 0.000f, }, /* 22 (21.985) */
- {0.963f, 1.440f, 2.117f, 1.675f, 0.000f, 0.000f, }, /* (22.934) 23 */
- {0.963f, 1.440f, 2.117f, 1.302f, 2.410f, 0.000f, }, /* (23.931) 24 */
- {0.845f, 1.212f, 1.934f, 1.313f, 2.419f, 0.000f, }, /* 25 (24.845) */
- {0.779f, 1.095f, 1.700f, 1.313f, 2.419f, 0.000f, }, /* 26 (25.999) */
- {0.723f, 1.015f, 1.664f, 1.313f, 2.419f, 0.000f, }, /* 27 (26.981) */
- {1.009f, 1.667f, 0.752f, 1.307f, 3.021f, 0.000f, }, /* (27.988) 28 */
- {1.005f, 1.647f, 0.749f, 1.064f, 1.871f, 3.348f, }, /* (28.936) 29 */
- {0.895f, 1.490f, 0.682f, 1.064f, 1.871f, 3.348f, }, /* (29.855) 30 */
- {0.787f, 1.272f, 0.608f, 1.064f, 1.871f, 3.348f, }, /* (30.968) 31 */
- {0.861f, 0.648f, 1.459f, 1.064f, 1.871f, 3.348f, }, /* (31.943) 32 */
- {0.829f, 0.631f, 1.337f, 1.059f, 2.032f, 3.428f, }, /* (32.999) 33 */
- {0.861f, 0.648f, 1.459f, 1.541f, 0.920f, 2.511f, }, /* (33.994) 34 */
- {0.848f, 0.633f, 1.358f, 1.408f, 0.879f, 2.711f, }, /* (34.989) 35 */
- {0.893f, 0.652f, 1.438f, 1.076f, 0.720f, 1.794f, }, /* 36 (35.929) */ /* INACTIVE WB*/
-
- {1.359f, 2.306f, 0.000f, 1.669f, 0.000f, 0.000f, }, /* 17 (16.823) */
- {1.077f, 1.927f, 3.546f, 1.669f, 0.000f, 0.000f, }, /* 21 (20.910) */
- {1.077f, 2.032f, 3.578f, 1.429f, 2.711f, 0.000f, }, /* 22 (21.985) */
- {0.833f, 1.253f, 2.105f, 1.283f, 2.556f, 0.000f, }, /* 25 (24.845) */
- {0.776f, 1.152f, 1.858f, 1.283f, 2.556f, 0.000f, }, /* 26 (25.934) */
- {0.719f, 1.066f, 1.732f, 1.283f, 2.556f, 0.000f, }, /* 27 (26.914) */
- {0.941f, 0.651f, 1.565f, 0.722f, 1.190f, 1.940f, }, /* 36 (35.915) */ /* INACTIVE 16k*/
-
- {1.292f, 2.479f, 0.000f, 1.541f, 0.000f, 0.000f, }, /* 18 (17.479) */
- {1.202f, 1.903f, 0.000f, 1.541f, 0.000f, 0.000f, }, /* 19 (18.703) */
- {1.028f, 1.641f, 2.455f, 1.648f, 0.000f, 0.000f, }, /* 22 (21.776) */
- {1.247f, 0.878f, 2.329f, 1.648f, 0.000f, 0.000f, }, /* 23 (22.791) */
- {0.863f, 1.358f, 2.522f, 1.648f, 0.000f, 0.000f, }, /* 24 (23.999) */
- {0.817f, 1.222f, 2.010f, 1.074f, 1.785f, 2.733f, }, /* 29 (28.966) */
- {0.815f, 0.612f, 1.281f, 1.055f, 1.724f, 2.952f, }, /* 32 (31.990) */ /* UNVOICED NB */
- {1.545f, 0.000f, 0.000f, 1.548f, 0.000f, 0.000f, }, /* 14 (13.640) */
- {1.640f, 0.000f, 0.000f, 1.548f, 0.000f, 0.000f, }, /* 15 (14.733) */
- {1.330f, 0.000f, 0.000f, 1.597f, 0.000f, 0.000f, }, /* (15.826) 16 */
- {1.235f, 2.316f, 0.000f, 1.597f, 0.000f, 0.000f, }, /* (16.376) 17 */
- {1.287f, 2.749f, 0.000f, 1.548f, 0.000f, 0.000f, }, /* 18 (17.479) */
- {1.287f, 2.749f, 0.000f, 1.654f, 0.000f, 0.000f, }, /* 19 (18.572) */
- {1.190f, 2.026f, 0.000f, 1.654f, 0.000f, 0.000f, }, /* 20 (19.796) */
- {0.952f, 1.674f, 2.762f, 1.597f, 0.000f, 0.000f, }, /* (20.910) 21 */
- {0.918f, 1.571f, 3.210f, 1.597f, 0.000f, 0.000f, }, /* (21.776) 22 */
- {1.256f, 0.792f, 2.078f, 1.597f, 0.000f, 0.000f, }, /* (22.784) 23 */
- {0.757f, 1.203f, 1.874f, 1.597f, 0.000f, 0.000f, }, /* (23.999) 24 */
- {0.931f, 1.458f, 2.450f, 1.294f, 2.742f, 0.000f, }, /* 25 (24.992) */
- {1.117f, 0.736f, 1.875f, 1.251f, 2.567f, 0.000f, }, /* (25.993) 26 */
- {0.772f, 1.236f, 1.921f, 1.251f, 2.567f, 0.000f, }, /* (26.883) 27 */
- {0.877f, 1.396f, 2.737f, 1.081f, 1.816f, 3.360f, }, /* 28 (27.996) */ /* UNVOICED WB*/
-
- {1.131f, 1.636f, 0.000f, 1.371f, 0.000f, 0.000f, }, /* 24 (23.818) */
- {0.892f, 1.592f, 3.424f, 1.298f, 3.206f, 0.000f, }, /* (24.961) 25 */
- {0.875f, 1.547f, 3.459f, 1.285f, 2.899f, 4.150f, }, /* (25.964) 26 */
- {0.846f, 1.650f, 3.307f, 1.275f, 2.446f, 4.005f, }, /* (26.946) 27 */
- {0.808f, 3.069f, 1.716f, 1.275f, 2.446f, 4.005f, }, /* (27.856) 28 */
- {0.765f, 3.128f, 1.823f, 1.275f, 2.446f, 4.005f, }, /* (28.977) 29 */
- {0.934f, 1.277f, 0.728f,1.157f, 1.697f, 0.000f, }, /* 30 (29.992) */
- {0.833f, 1.162f, 0.658f,1.151f, 1.687f, 0.000f, }, /* 31 (30.998) */
- {0.751f, 1.032f, 0.598f,1.151f, 1.687f, 0.000f, }, /* 32 (31.987) */
- {0.759f, 3.138f, 1.845f, 0.922f, 1.508f, 3.110f, }, /* (32.975) 33 */
- {0.709f, 1.005f, 0.570f, 1.060f, 1.772f, 2.719f, }, /* 34 (33.994) */
- {0.746f, 1.001f, 0.601f,1.004f, 1.803f, 2.892f, }, /* 35 (35.000) */
- {0.743f, 1.000f, 0.599f,0.936f, 1.861f, 2.874f, }, /* 36 (35.994) */
- {0.750f, 3.170f, 1.925f, 0.737f, 1.423f, 2.687f, } , /* (36.977) 37 */
- {0.750f, 3.170f, 1.925f, 0.659f, 1.059f, 1.975f, }, /* (37.984) 38 */
- {0.775f, 0.614f, 1.037f, 0.796f, 1.304f, 1.905f, }, /* 39 (38.301) */ /* VOICED 16k */
-
- {0.894f, 1.339f, 2.549f, 1.308f, 2.601f, 0.000f, }, /* 26 (25.917) */
- {0.832f, 1.254f, 1.937f, 1.307f, 2.614f, 0.000f, }, /* (26.887) 27 */
- {0.832f, 1.232f, 1.916f, 1.158f, 1.977f, 0.000f, }, /* (27.974) 28 */
- {0.825f, 1.260f, 1.993f, 1.023f, 1.739f, 2.796f, }, /* (28.910) 29 */
- {0.750f, 1.114f, 1.563f, 1.045f, 1.802f, 2.681f, }, /* (29.976) 30 */
- {0.692f, 1.000f, 1.431f, 1.023f, 1.739f, 2.796f, }, /* (30.956) 31 */
- {0.720f, 1.012f, 1.598f, 1.512f, 0.926f, 2.137f, }, /* 32 (31.980) */
- {0.681f, 0.973f, 1.649f, 1.381f, 0.876f, 2.129f, }, /* 33 (32.990) */
- {0.684f, 0.964f, 1.640f, 1.168f, 1.776f, 0.787f, }, /* 34 (33.974) */
- {0.668f, 0.935f, 1.551f, 1.016f, 1.518f, 0.712f, }, /* 35 (34.989) */
- {0.659f, 0.911f, 1.425f, 1.337f, 0.889f, 0.642f, }, /* 36 (35.988) */
- {0.659f, 0.911f, 1.425f, 0.839f, 1.287f, 0.607f, }, /* 37 (36.989) */ /* GENERIC 16k*/
-
- {1.633f, 0.000f, 0.000f, 1.687f, 0.000f, 0.000f, }, /* 16 (15.826) */
- {1.691f, 0.000f, 0.000f, 1.674f, 0.000f, 0.000f, }, /* (15.826) 16 */
- {1.328f, 2.564f, 0.000f, 1.553f, 0.000f, 0.000f, }, /* (17.479) 18 */
- {1.250f, 1.992f, 0.000f, 1.553f, 0.000f, 0.000f, }, /* (18.703) 19 */
- {1.250f, 1.992f, 0.000f, 1.674f, 0.000f, 0.000f, }, /* (19.796) 20 */
- {1.076f, 1.790f, 2.942f, 1.687f, 0.000f, 0.000f, }, /* 21 (20.910) */
- {1.066f, 1.683f, 4.077f, 1.674f, 0.000f, 0.000f, }, /* (21.776) 22 */
- {1.280f, 0.911f, 2.477f, 1.674f, 0.000f, 0.000f, }, /* (22.791) 23 */
- {0.834f, 1.229f, 1.890f, 1.687f, 0.000f, 0.000f, }, /* 24 (23.999) */
- {0.938f, 1.404f, 2.153f, 1.306f, 2.630f, 0.000f, }, /* 25 (24.992) */
- {1.340f, 0.886f, 2.320f, 1.306f, 2.630f, 0.000f, }, /* 26 (25.917) */
- {0.833f, 1.250f, 1.908f, 1.306f, 2.630f, 0.000f, }, /* 27 (26.883) */
- {0.833f, 1.213f, 1.873f, 1.125f, 1.839f, 2.819f, }, /* 28 (27.901) */
- {0.854f, 1.267f, 1.828f, 1.044f, 1.760f, 2.882f, }, /* (28.937) 29 */
- {0.765f, 1.162f, 1.690f, 1.024f, 1.738f, 2.838f, }, /* 30 (29.916) */
- {0.725f, 1.050f, 1.791f, 1.480f, 0.922f, 3.104f, }, /* 31 (30.993) */
- {0.712f, 1.012f, 1.549f, 1.494f, 0.903f, 3.364f, }, /* 32 (31.980) */
- {0.659f, 0.927f, 1.357f, 1.494f, 0.903f, 3.364f, }, /* 33 (32.958) */
- {0.822f, 0.614f, 1.288f, 0.910f, 1.509f, 2.255f, }, /* 34 (33.987) */
- {0.841f, 0.624f, 1.278f, 1.161f, 0.762f, 1.808f, }, /* 35 (34.994) */
- {0.838f, 0.622f, 1.266f, 1.080f, 0.711f, 1.710f, }, /* 36 (35.968) */
- {0.832f, 0.619f, 1.275f, 0.938f, 1.430f, 0.644f, }, /* 37 (36.971) */ /* GENERIC 12.8k MA*/
-
- {0.884f, 1.349f, 2.570f, 1.314f, 2.609f, 0.000f, }, /* 26 (25.917) */
- {0.981f, 1.473f, 2.784f, 1.690f, 3.342f, 0.000f, }, /* (26.981) 27 */
- {0.965f, 1.514f, 2.686f, 1.409f, 2.485f, 3.946f, }, /* (27.989) 28 */
- {0.976f, 1.457f, 2.663f, 2.151f, 1.271f, 4.176f, }, /* (28.976) 29 */
- {0.991f, 1.504f, 3.086f, 2.486f, 1.315f, 4.530f, }, /* (29.968) 30 */
- {0.946f, 1.448f, 2.723f, 1.394f, 2.645f, 4.581f, }, /* (30.967) 31 */
- {0.711f, 1.018f, 1.615f, 1.482f, 0.921f, 3.431f, }, /* 32 (31.980) */
- {0.679f, 0.974f, 1.659f, 0.948f, 1.549f, 3.448f, }, /* 33 (32.995) */
- {0.831f, 0.618f, 1.481f, 0.933f, 1.514f, 2.310f, }, /* 34 (33.993) */
- {0.816f, 0.610f, 1.402f, 1.426f, 0.877f, 2.265f, }, /* 35 (34.992) */
- {0.787f, 1.257f, 0.596f, 0.859f, 1.447f, 2.431f, }, /* 36 (35.997) */
- {0.787f, 1.257f, 0.596f, 1.106f, 0.735f, 1.659f, }, /* 37 (36.961) */ /* AUDIO 16k */
-};
-
const Word16 scales_fx[][6] =//Q11
{
{3129, 0, 0, 3138, 0, 0, }, /* 14 */
@@ -13238,45 +12567,6 @@ const Word16 scales_p_fx[][6] =
};
-/* An 16-by-34 matrix in Scale = 20.48f */
-const float sigma_MSLVQ[][16] =
-{
- { 1.0f }, /* IA NB */
- { 1.0f }, /* UV NB */
- {41.8457031f, 43.9453125f, 62.5976563f, 72.3632813f, 78.7597656f, 82.4707031f, 85.4492188f, 86.5722656f, 86.6210938f, 84.9121094f, 85.2050781f, 105.5664063f, 127.8320313f, 68.6523438f, 25.7324219f, 16.9433594f }, /* V NB */
- {48.9257813f, 50.5859375f, 71.0449219f, 72.4609375f, 74.5117188f, 77.8808594f, 79.5898438f, 80.8105469f, 79.9804688f, 74.5117188f, 70.0683594f, 88.7207031f, 119.1406250f, 102.0019531f, 37.1093750f, 25.0976563f }, /* G NB */
- {48.2421875f, 48.0468750f, 68.7500000f, 76.9531250f, 80.9570313f, 85.1562500f, 89.0625000f, 91.8457031f, 90.4296875f, 85.2050781f, 81.5917969f, 106.2988281f, 133.6425781f, 84.3750000f, 34.7656250f, 26.6113281f }, /* T NB */
- {85.5957031f, 82.9101563f, 99.5605469f, 105.9570313f, 106.6406250f, 106.8847656f, 101.6601563f, 99.5605469f, 97.7050781f, 97.0703125f, 97.1191406f, 117.8710938f, 128.1738281f, 153.9550781f, 33.1542969f, 14.5996094f },/* AU NB*/
- { 1.0f },
- { 1.0f }, /* UV WB*/
- {44.2382813f, 52.1972656f, 85.7910156f, 98.6816406f, 101.7089844f, 107.2753906f, 106.9824219f, 112.0605469f, 118.8476563f, 126.3183594f, 125.4882813f, 126.8554688f, 136.3281250f, 136.7675781f, 146.9726563f, 129.7851563f }, /* V WB */
- {61.8164063f, 69.8730469f, 94.6289063f, 97.0214844f, 96.0449219f, 101.3671875f, 100.5371094f, 104.3945313f, 108.5937500f, 106.9824219f, 107.9101563f, 112.8417969f, 120.7519531f, 120.6542969f, 122.0214844f, 119.6289063f }, /* G WB */
- {56.8847656f, 56.9335938f, 86.7187500f, 100.1953125f, 101.9042969f, 108.5449219f, 113.4765625f, 117.9199219f, 124.1699219f, 122.1679688f, 126.3183594f, 137.4023438f, 153.9550781f, 158.8867188f, 161.9140625f, 155.9570313f }, /* T WB */
- {84.8632813f, 88.6230469f, 112.0605469f, 118.3593750f, 123.3886719f, 121.0937500f, 115.4785156f, 118.7011719f, 118.5058594f, 119.0429688f, 123.9257813f, 127.6855469f, 138.5742188f, 125.2441406f, 118.9941406f, 109.0332031f },/* AU WB */
- { 1.0f },
- { 1.0f },
- {75.2441406f, 84.3261719f, 110.6933594f, 125.0000000f, 134.0332031f, 140.3808594f, 146.6308594f, 159.5214844f, 161.3281250f, 173.9746094f, 186.9628906f, 190.9667969f, 196.2402344f, 181.9335938f, 177.9785156f, 187.2070313f }, /* VO 16k */
- {89.6972656f, 92.9687500f, 122.0703125f, 129.0527344f, 130.4687500f, 128.3691406f, 132.5683594f, 139.2578125f, 137.9882813f, 139.9902344f, 152.8320313f, 157.3730469f, 172.4121094f, 179.4433594f, 147.9980469f, 194.1894531f }, /* G 16k */
- {90.3320313f, 108.3496094f, 118.7500000f, 125.7324219f, 135.7421875f, 137.9882813f, 143.0175781f, 145.1660156f, 145.8007813f, 155.1757813f, 171.2402344f, 176.1230469f, 165.4785156f, 161.3769531f, 148.6816406f, 174.4140625f }, /* T 16k */
- {103.1250000f, 112.3046875f, 142.3339844f, 150.6347656f, 150.0488281f, 145.8496094f, 149.3164063f, 145.8496094f, 153.5156250f, 157.3242188f, 175.0000000f, 170.9960938f, 157.4707031f, 168.1152344f, 156.5917969f, 229.0527344f },/* AU 16k */
- {87.5488281f, 116.4062500f, 102.3925781f, 103.1738281f, 100.8789063f, 95.2636719f, 101.7578125f, 110.5468750f, 122.2167969f, 115.2343750f, 107.2753906f, 108.8378906f, 101.7089844f, 111.5722656f, 111.6699219f, 155.9570313f },
- {160.5957031f, 122.6074219f, 117.4804688f, 129.7363281f, 130.9570313f, 133.8378906f, 139.1601563f, 159.9121094f, 168.0664063f, 161.3281250f, 141.9433594f, 142.1386719f, 132.0312500f, 129.8828125f, 122.9980469f, 160.9863281f },
- {53.2226563f, 105.1757813f, 133.9355469f, 143.3593750f, 158.2031250f, 168.1640625f, 160.5957031f, 164.4042969f, 173.4863281f, 182.0800781f, 170.0683594f, 165.3320313f, 128.1738281f, 96.5332031f, 91.9433594f, 93.7988281f },
- {69.5312500f, 169.0429688f, 118.9453125f, 104.6875000f, 100.7812500f, 98.3398438f, 98.8281250f, 95.9472656f, 97.8027344f, 97.6562500f, 95.8496094f, 99.8046875f, 94.3847656f, 106.5917969f, 117.1386719f, 144.7265625f },
- {136.1816406f, 130.5175781f, 130.9082031f, 133.3007813f, 131.3476563f, 129.1992188f, 133.8867188f, 166.1621094f, 197.0703125f, 281.9824219f, 305.7617188f, 255.8105469f, 392.7734375f, 336.6699219f, 135.2050781f, 96.7773438f },
- {123.0957031f, 119.6777344f, 126.3183594f, 119.5800781f, 117.3339844f, 108.4472656f, 107.9101563f, 112.2070313f, 148.2910156f, 153.9550781f, 127.6367188f, 129.9316406f, 132.5683594f, 149.3164063f, 144.6777344f, 244.6289063f },
- {92.3339844f, 97.5097656f, 94.0917969f, 90.2832031f, 94.1894531f, 95.8007813f, 92.8710938f, 86.4746094f, 83.8867188f, 74.1699219f, 70.8984375f, 69.3847656f, 71.5332031f, 167.2851563f, 71.8750000f, 21.5820313f },
- {44.0429688f, 73.9257813f, 140.6738281f, 121.8750000f, 129.5410156f, 127.3437500f, 115.7226563f, 104.8339844f, 106.2500000f, 110.0097656f, 125.0000000f, 107.5195313f, 85.6445313f, 79.2968750f, 69.9218750f, 55.9570313f },
- {106.4453125f, 99.4140625f, 95.6542969f, 92.7246094f, 94.3359375f, 92.0898438f, 83.6914063f, 84.7167969f, 87.1582031f, 101.6113281f, 91.1621094f, 75.3417969f, 73.0957031f, 71.5332031f, 68.0175781f, 63.7207031f },
- {43.3105469f, 125.5371094f, 107.4707031f, 85.4003906f, 83.1542969f, 80.7617188f, 78.8574219f, 80.0781250f, 80.1269531f, 88.0859375f, 93.2128906f, 81.3964844f, 74.8535156f, 73.0957031f, 65.8203125f, 59.3750000f },
- {149.6093750f, 127.3925781f, 117.1875000f, 111.9628906f, 113.4277344f, 113.8671875f, 107.8125000f, 97.9492188f, 100.7324219f, 113.5253906f, 167.9687500f, 203.4667969f, 154.9804688f, 119.1894531f, 107.1289063f, 104.8828125f },
- {59.5214844f, 86.2792969f, 106.0058594f, 113.7207031f, 134.4726563f, 120.9960938f, 120.4589844f, 100.4882813f, 98.5839844f, 100.0488281f, 132.3730469f, 191.8457031f, 194.7753906f, 77.8320313f, 70.0195313f, 41.9433594f },
- {88.2812500f, 92.3828125f, 92.1386719f, 93.5546875f, 97.6074219f, 92.7734375f, 89.0625000f, 87.2070313f, 88.8671875f, 94.1406250f, 121.5820313f, 121.9238281f, 116.7968750f, 122.1191406f, 164.5996094f, 140.4296875f },
- {86.2792969f, 92.8710938f, 83.5937500f, 86.0839844f, 95.8984375f, 95.2148438f, 90.5273438f, 86.5234375f, 82.1289063f, 81.3964844f, 77.9785156f, 89.4042969f, 143.7011719f, 168.3593750f, 41.5039063f, 27.6855469f },
- {97.1679688f, 101.0253906f, 104.3945313f, 110.4003906f, 108.7890625f, 107.4707031f, 97.8515625f, 92.6757813f, 79.1503906f, 81.6406250f, 77.1972656f, 108.8867188f, 212.2070313f, 198.8281250f, 47.4609375f, 35.3515625f },
- {74.8535156f, 97.3632813f, 100.1464844f, 91.6992188f, 90.3808594f, 89.6484375f, 83.2031250f, 84.0820313f, 81.9335938f, 96.4355469f, 110.9863281f, 92.6757813f, 83.4960938f, 82.1289063f, 77.8808594f, 70.8984375f}
-};
-
const Word16 sigma_MSLVQ_fx[][16] =
{//Qlog2(2.56)
{3},
@@ -13354,29 +12644,6 @@ const Word16 inv_sigma_MSLVQ_fx[][16] =//Q15
{438, 337, 327, 357, 363, 365, 394, 390, 400, 340, 295, 354, 392, 399, 421, 462},
};
-/* An 16-by-19 matrix in Scale = 20.48f */
-const float sigma_p[][16] =
-{
- {59.3261719f, 63.9160156f, 69.7753906f, 66.3574219f, 67.3339844f, 68.5546875f, 66.6015625f, 66.0156250f, 66.0156250f, 67.9687500f, 68.2617188f, 84.3261719f, 96.5820313f, 118.6523438f, 44.0917969f, 43.1152344f }, /* IA NB */
- {51.2207031f, 66.6015625f, 69.3847656f, 68.6035156f, 67.9199219f, 69.6289063f, 69.6777344f, 69.5800781f, 52.5878906f, 64.9902344f, 65.3808594f, 68.7500000f, 71.4355469f, 77.0507813f, 77.9296875f, 80.3222656f }, /* U NB */
- {32.7148438f, 34.9121094f, 47.0703125f, 55.6152344f, 60.1562500f, 68.3105469f, 71.8261719f, 72.7539063f, 73.8281250f, 70.8984375f, 69.4335938f, 77.1972656f, 95.8007813f, 74.3164063f, 20.8984375f, 10.9375000f }, /* V NB */
- {53.8085938f, 61.3281250f, 78.1738281f, 75.8789063f, 73.7792969f, 81.3964844f, 80.7128906f, 80.5664063f, 83.6914063f, 77.0996094f, 72.5097656f, 86.6210938f, 121.6796875f, 117.7734375f, 40.0390625f, 16.8945313f },/* G NB */
- {1.0f }, /* T NB */
- {57.0312500f, 64.5996094f, 71.4355469f, 75.8789063f, 77.0507813f, 79.0039063f, 74.5117188f, 74.2187500f, 72.9492188f, 72.8515625f, 66.9433594f, 73.9257813f, 109.6191406f, 121.5332031f, 23.7792969f, 13.3789063f }, /* AU NB */
- {55.4687500f, 65.6738281f, 71.8261719f, 71.6308594f, 73.0468750f, 74.3164063f, 73.0957031f, 73.4863281f, 73.8769531f, 75.2441406f, 78.0761719f, 82.6171875f, 90.1367188f, 95.8496094f, 66.0644531f, 68.9941406f }, /* IA WB */
- {67.9687500f, 64.0625000f, 65.8203125f, 76.9531250f, 117.1875000f, 145.5078125f, 77.6855469f, 23.2421875f, 81.0546875f, 81.1035156f, 81.4453125f, 85.0585938f, 90.0878906f, 95.8984375f, 92.3828125f, 90.7226563f }, /* U WB */
- {35.6933594f, 39.4042969f, 57.3242188f, 64.6484375f, 68.0175781f, 76.2695313f, 80.7128906f, 82.0800781f, 85.1562500f, 89.6484375f, 89.9414063f, 95.3613281f, 104.7363281f, 106.0546875f, 105.2734375f, 97.8515625f }, /* V WB */
- {61.4257813f, 75.1464844f, 88.4277344f, 82.1777344f, 82.4218750f, 89.1601563f, 89.2578125f, 94.1894531f, 95.5566406f, 95.9472656f, 97.0703125f, 102.6367188f, 107.2265625f, 107.3730469f, 105.4199219f, 98.1933594f },/* G WB */
- {1.0f },/* T WB */
- {51.1230469f, 62.5976563f, 71.5820313f, 75.5371094f, 78.9550781f, 79.9804688f, 79.4433594f, 82.9101563f, 82.6171875f, 83.1054688f, 84.8632813f, 86.1328125f, 89.5996094f, 83.6914063f, 79.3945313f, 78.2226563f }, /* AU WB */
- {72.9980469f, 86.2792969f, 90.0878906f, 89.5996094f, 92.4316406f, 90.5273438f, 90.5273438f, 92.1386719f, 97.3632813f, 101.3671875f, 111.7675781f, 110.8398438f, 97.5585938f, 93.1640625f, 92.8710938f, 115.7226563f },/* IA 16k */
- {1.0f },/* U 16k */
- {49.714f, 67.480f, 88.315f, 84.931f, 102.979f, 99.871f, 113.361f, 115.387f, 115.951f, 126.902f, 130.543f, 127.340f, 117.813f, 113.104f, 107.586f, 99.412f }, /* V 16k */
- {96.8261719f, 117.3339844f, 132.5683594f, 134.4726563f, 140.7226563f, 136.8652344f, 141.6992188f, 141.1132813f, 143.8964844f, 152.6367188f, 168.5058594f, 169.1406250f, 158.4960938f, 156.1523438f, 147.4609375f, 182.4707031f },/* G 16k */
- {1.0f },/* T 16k */
- {55.1269531f, 70.3613281f, 83.1054688f, 87.2070313f, 90.5273438f, 91.4550781f, 94.7265625f, 93.6035156f, 97.6074219f, 98.7304688f, 104.6875000f, 99.6582031f, 95.6054688f, 91.6503906f, 88.4765625f, 78.2226563f, },/* NOT USED ! AU 16k */
- {69.5312500f, 80.1757813f, 101.3183594f, 100.9277344f, 106.4941406f, 111.1816406f, 107.6171875f, 112.9882813f, 116.6992188f, 117.1875000f, 120.9472656f, 125.0976563f, 130.7617188f, 128.7109375f, 123.3886719f, 104.9316406f} /* G WB for MA*/
-};
/* An 16-by-19 matrix in Scale = 32768.00f */
const Word16 inv_sigma_p_fx[][16] =//Q15
{
@@ -14221,7 +13488,7 @@ const Word16 offset_in_lvq_mode_SN_fx[][21] =
{0}, /*{0,0,0,0,0,0,0,0,0,0,1} */ /* A 16k */
};
-const int16_t offset_in_lvq_mode_pred[][32] =
+const Word16 offset_in_lvq_mode_pred[][32] =
{
{0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I NB */
{0,1,1,1,2,3,4,4,4,4,4,5,5,5,6}, /* UV NB */
@@ -16810,15 +16077,6 @@ const Word16 subf_norm_groups[4][11] =
{6,7,14,15,19,23,27,31,35,39,43}
}; // Q0
-const float gain_att[MAX_P_ATT] =
-{
- 0.4794745f, 0.5910453f, 0.6647078f, 0.7245839f, 0.7598486f, 0.7912783f, 0.8165831f, 0.8396713f,
- 0.8562786f, 0.8716393f, 0.8848335f, 0.8971617f, 0.9061614f, 0.9146075f, 0.9220175f, 0.9290045f,
- 0.9344148f, 0.9395265f, 0.9440797f, 0.9484073f, 0.9518549f, 0.9551361f, 0.9581067f, 0.9609474f,
- 0.9632704f, 0.9654923f, 0.9675346f, 0.9694900f, 0.9711209f, 0.9726879f, 0.9741332f, 0.9755263f,
- 0.9767067f, 0.9778463f, 0.9789108f, 0.9799438f, 0.9808353f, 0.9816967f, 0.9825032f, 0.9832868f
-};
-
const Word16 gain_att_fx[40] = /* Q=15 */
{
15711, 19367, 21781, 23743, 24899, 25929, 26758, 27514,
@@ -16833,24 +16091,12 @@ const Word16 stab_trans_fx[10] = /* Q15 */
16384, 11381, 7232, 4292, 2433,
1341, 728, 391, 209, 112
};
-const float stab_trans[L_STAB_TBL] =
-{
- 0.500000f, 0.347332f, 0.220704f, 0.130976f, 0.074252f,
- 0.040937f, 0.022211f, 0.011944f, 0.006392f, 0.003412f
-};
-
-const float env_stab_tp[2][2] =
-{
- {0.999f, 0.5f},
- {0.001f, 0.5f}
-};
const Word16 env_stab_tp_fx[2][2] = /* Q15 */
{
{32735, 16384},
{33, 16384}
};
-const float att_step[NB_G] = { 4.0000000f, 2.0000000f, 1.3333333f, 1.0000000f};
const Word16 att_step_fx[4] = /* Q=13 */
{
@@ -17168,7 +16414,7 @@ const UWord8 hBitsMinus1_N36[8]=
{
7, 49, 90, 127, 160, 191, 220, 247
}; // Q0
-const uint8_t hBitsMinus1_N37[8]=
+const UWord8 hBitsMinus1_N37[8]=
{
7, 49, 91, 128, 162, 193, 222, 249
}; // Q0
@@ -17248,7 +16494,7 @@ const UWord8 hBitsMinus1_N56[7]=
{
6, 54, 100, 142, 181, 217, 250
}; // Q0
-const uint8_t hBitsMinus1_N57[7]=
+const UWord8 hBitsMinus1_N57[7]=
{
6, 54, 101, 143, 181, 218, 252
};
@@ -17498,18 +16744,6 @@ const Word16 gsc_sfm_end[MBANDS_GN] = {16, 32, 48, 64, 80, 96, 112, 128, 144, 16
const Word16 gsc_sfm_size[MBANDS_GN] = {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}; // Q0
-const float sm_table[] =
-{
- 1.0f, 0.9804f, 0.9607f, 0.9411f, 0.9215f, 0.902f, 0.8825f, 0.863f,
- 0.8436f, 0.8242f, 0.8049f, 0.7857f, 0.7666f, 0.7475f, 0.7286f, 0.7097f, 0.691f, 0.6724f,
- 0.6539f, 0.6355f, 0.6173f, 0.5993f, 0.5813f, 0.5636f, 0.546f, 0.5286f, 0.5114f, 0.4943f,
- 0.4775f, 0.4609f, 0.4444f, 0.4282f, 0.4122f, 0.3964f, 0.3809f, 0.3656f, 0.3506f, 0.3357f,
- 0.3212f, 0.3069f, 0.2929f, 0.2791f, 0.2657f, 0.2525f, 0.2396f, 0.227f, 0.2147f, 0.2027f,
- 0.191f, 0.1796f, 0.1685f, 0.1578f, 0.1474f, 0.1373f, 0.1275f, 0.1181f, 0.109f, 0.1003f,
- 0.0919f, 0.0838f, 0.0761f, 0.0688f, 0.0618f, 0.0552f, 0.0489f, 0.0431f, 0.0375f, 0.0324f,
- 0.0276f, 0.0232f, 0.0192f, 0.0156f, 0.0123f, 0.0094f, 0.0069f, 0.0048f, 0.0031f, 0.0017f,
- 0.0008f, 0.0002f
-};
const Word16 sm_table_fx[] =
{
32767, 32126, 31480, 30838, 30196, 29557, 28918, 28279, 27643, 27007,
@@ -17587,28 +16821,10 @@ const Word16 Compl_GSC_freq_bits[] =
5, 10, 10, 10 /* bitrate > ACELP_16k40 && FS = 16kHz */
}; // Q0
-const float mfreq_loc[] =
-{
- 175.0f, 375.0f, 775.0f, 1175.0f, 1575.0f, 1975.0f, 2375.0f, 2775.0f, 3175.0f, 3575.0f, 3975.0f,
- 4375.0f, 4775.0f, 5175.0f, 5575.0f, 6375.0f, 7175.0f, 7975.0f
-};
-
const Word16 mfreq_bindiv_loc[] = { 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32 }; // Q0
-const float mean_gp[] = { 0.5853f };
const Word16 mean_gp_fx[] = { 9590 }; /*Q14*/
-const float dic_gp[] =
-{
- -0.5847f, -0.4695f, -0.3897f, -0.2731f,
- -0.1986f, -0.1244f, -0.0492f, -0.005f,
- 0.0631f, 0.1379f, 0.211f, 0.2859f,
- 0.3229f, 0.3994f, 0.5217f, 0.6135f,
- -0.5471f, -0.5089f, -0.4285f, -0.3512f,
- -0.3124f, -0.235f, -0.162f, -0.0872f,
- 0.0249f, 0.1013f, 0.1741f, 0.2485f,
- 0.361f, 0.4376f, 0.4776f, 0.5645f
-};
const Word16 dic_gp_fx[] = /*Q14*/
{
-9580, -7692, -6385, -4474, -3254, -2038, -806, -82,
@@ -17616,32 +16832,11 @@ const Word16 dic_gp_fx[] = /*Q14*/
-8964, -8338, -7021, -5754, -5118, -3850, -2654, -1429,
408, 1660, 2852, 4071, 5915, 7170, 7825, 9249
};
-const float Gain_meanNB[] = { 2.4052f };
const Word16 Gain_meanNB_fx[] =
{
9852,
};/* Q12 */
-const float Gain_mean_dicNB[] =
-{
- -0.3197f, -0.2272f, -0.1386f, -0.0966f,
- -0.0132f, 0.1970f, 0.2865f, 0.3743f,
- 0.4640f, 0.5108f, 0.5581f, 0.6086f,
- 0.6588f, 0.7642f, 0.7101f, 0.0698f,
- -0.1827f, 0.2418f, 0.1540f, -0.2733f,
- -0.4144f, -0.5162f, -0.6806f, -1.3182f,
- -2.4026f, -0.4643f, -0.7983f, -1.9470f,
- -1.8160f, -1.6910f, -1.7558f, -0.5677f,
- -0.3673f, -0.6224f, -0.7379f, -0.8624f,
- -0.9321f, -1.0098f, -1.1600f, -1.2380f,
- -1.4052f, -1.4876f, -2.1967f, -1.5599f,
- -2.1399f, -2.3041f, 0.8225f, 0.9564f,
- 0.8835f, 1.1436f, -2.0176f, 1.0387f,
- -1.0822f, -1.6264f, -2.2534f, -1.8746f,
- 1.4304f, 0.0288f, 0.1116f, -0.0553f,
- 0.4192f, 0.3303f, -2.0750f,
- -2.3558f,
-};
const Word16 Gain_mean_dicNB_fx[1 * 64] = /*Q12 */
{
-1309, -931, -568, -396, -54, 807, 1174, 1533,
@@ -17653,142 +16848,13 @@ const Word16 Gain_mean_dicNB_fx[1 * 64] = /*Q12 */
3619, 4684, -8264, 4255, -4433, -6662, -9230, -7678,
5859, 118, 457, -227, 1717, 1353, -8499, -9649
};
-const float Mean_dic_NB[] =
-{
- -0.1084f, -0.0243f, -0.0292f, -0.0091f,
- 0.0061f, 0.0171f, 0.0362f, 0.0153f,
- 0.0416f, 0.0558f,
-};
+
const Word16 Mean_dic_NB_fx[1 * 10] = /*Q12 */
{
-444, -100, -120, -37, 25,
70, 148, 63, 170, 229
};
-const float Gain_dic1_NB[] =
-{
- -0.1479f, -0.0224f, 0.0013f,
- -0.4797f, 0.0718f, 0.1627f,
- -0.1073f, 0.0291f, 0.1613f,
- -0.0258f, 0.0652f, 0.0264f,
- -0.2961f, 0.0842f, -0.0332f,
- -0.3053f, 0.1508f, 0.1381f,
- -0.4650f, -0.1832f, 0.1581f,
- -0.2546f, -0.0879f, -0.1215f,
- -0.0043f, -0.0785f, 0.0235f,
- 0.0816f, 0.0283f, -0.0604f,
- -0.4709f, 0.1612f, 0.0056f,
- -0.4504f, 0.2876f, 0.1183f,
- -0.0440f, 0.2040f, 0.0408f,
- -0.4619f, -0.2252f, -0.0783f,
- 0.1016f, -0.1067f, -0.0839f,
- 0.1452f, -0.1337f, 0.0386f,
- -0.0648f, -0.1970f, -0.0826f,
- -0.2599f, -0.2477f, -0.0048f,
- -0.1528f, 0.1452f, -0.0814f,
- -0.1389f, 0.2661f, 0.1590f,
- 0.0066f, 0.1432f, -0.0809f,
- -0.0450f, -0.0207f, -0.1229f,
- -0.4643f, -0.4412f, 0.0796f,
- -0.4543f, -0.0387f, -0.2415f,
- -0.1626f, 0.0349f, -0.2839f,
- -0.4194f, 0.2517f, -0.1816f,
- 0.2068f, 0.0736f, -0.0144f,
- 0.1757f, -0.2445f, -0.0527f,
- 0.3370f, -0.2115f, -0.2366f,
- 0.1961f, -0.0010f, -0.1484f,
- 0.0568f, 0.0997f, -0.2436f,
- 0.3561f, 0.0213f, 0.0641f,
- 0.0842f, -0.1502f, -0.2506f,
- 0.2140f, -0.0362f, -0.0016f,
- 0.0165f, -0.2625f, 0.0660f,
- 0.1958f, 0.0804f, 0.1159f,
- -0.4695f, -0.0308f, -0.0092f,
- 0.3114f, -0.1023f, -0.0851f,
- 0.0979f, 0.2260f, 0.1403f,
- 0.2066f, -0.0569f, 0.1335f,
- 0.1691f, -0.4590f, 0.0869f,
- -0.0883f, -0.4109f, -0.0535f,
- 0.0565f, -0.0827f, 0.1460f,
- 0.2996f, -0.1503f, 0.0652f,
- 0.2724f, 0.0221f, -0.3213f,
- -0.1344f, -0.1588f, 0.1293f,
- 0.1083f, 0.0079f, 0.0442f,
- -0.0937f, 0.2946f, -0.1892f,
- -0.2424f, 0.2840f, 0.0099f,
- 0.1915f, -0.2486f, 0.1314f,
- 0.1551f, 0.1553f, -0.1036f,
- 0.3353f, -0.3337f, 0.0364f,
- 0.3521f, 0.0979f, -0.1083f,
- 0.2671f, 0.2169f, 0.0300f,
- 0.2135f, 0.2717f, -0.2642f,
- -0.1578f, -0.2715f, -0.2692f,
- 0.1316f, -0.3985f, -0.1668f,
- 0.0981f, 0.1393f, 0.0241f,
- -0.4342f, -0.4417f, -0.2072f,
- -0.1788f, -0.4128f, 0.1708f,
- -0.1655f, 0.1284f, 0.0670f,
- 0.0782f, 0.2996f, -0.0288f,
- -0.2984f, -0.0440f, 0.1108f,
- 0.0423f, 0.0853f, 0.1295f,
-};
-
-const float Gain_dic2_NB[] =
-{
- 0.0069f, 0.0000f, -0.0160f,
- -0.1361f, 0.0009f, 0.0504f,
- 0.0686f, -0.1568f, 0.0088f,
- -0.1019f, 0.0198f, -0.1206f,
- -0.0927f, 0.1671f, 0.1099f,
- 0.1272f, -0.3770f, 0.0631f,
- -0.2733f, 0.1496f, -0.2809f,
- 0.1256f, 0.0058f, 0.1945f,
- 0.0714f, -0.0204f, -0.1284f,
- 0.0723f, 0.1021f, -0.0563f,
- -0.1024f, -0.0165f, 0.2383f,
- 0.0004f, -0.0753f, 0.0971f,
- -0.1114f, -0.2459f, 0.0641f,
- -0.2982f, -0.0906f, 0.1089f,
- -0.0539f, -0.0952f, -0.0441f,
- -0.2955f, 0.1435f, 0.1833f,
- -0.2669f, 0.1288f, -0.0425f,
- 0.1440f, 0.0907f, -0.3104f,
- -0.0192f, -0.0612f, -0.3029f,
- -0.2480f, -0.1188f, -0.1250f,
- 0.1324f, 0.1419f, 0.0826f,
- -0.0648f, 0.1114f, -0.0257f,
- 0.1196f, -0.0173f, 0.0218f,
- 0.0103f, 0.0574f, 0.0926f,
- 0.0076f, 0.2916f, -0.0493f,
- 0.0422f, -0.2048f, 0.2074f,
- -0.0113f, 0.1221f, -0.1958f,
- 0.0371f, 0.2279f, 0.2620f,
- 0.2392f, 0.0843f, -0.0641f,
- 0.1969f, -0.1415f, -0.1273f,
- -0.0055f, -0.2421f, -0.1429f,
- 0.2138f, -0.1407f, 0.1003f,
-};
-
-const float Gain_dic3_NB[] =
-{
- -0.0039f, 0.0159f, -0.0553f, 0.0027f,
- -0.0523f, 0.1349f, 0.0894f, 0.0451f,
- 0.0334f, -0.0825f, -0.0732f, -0.1526f,
- -0.0298f, 0.0199f, 0.1314f, -0.1946f,
- 0.0391f, 0.0695f, -0.2694f, 0.0085f,
- -0.1451f, 0.0762f, -0.0925f, -0.1033f,
- 0.0412f, -0.1568f, -0.0964f, 0.0887f,
- 0.0856f, -0.2846f, 0.1538f, -0.0637f,
- -0.2905f, 0.0529f, 0.1016f, 0.0456f,
- -0.1409f, 0.0596f, -0.1553f, 0.2095f,
- 0.1415f, 0.1177f, -0.0536f, 0.1551f,
- 0.1159f, -0.0458f, 0.0909f, 0.0066f,
- -0.0159f, -0.0901f, 0.1231f, 0.2221f,
- -0.1032f, -0.1080f, 0.0302f, -0.0098f,
- 0.1173f, 0.1404f, -0.0101f, -0.1590f,
- 0.1665f, 0.1661f, 0.2222f, 0.1193f,
-};
-
const Word16 Gain_dic1_NB_fx[3 * 64] = /*Q12 */
{
-606, -92, 5,
@@ -17913,206 +16979,6 @@ const Word16 Gain_dic3_NB_fx[4 * 16] = /*Q12 */
682, 680, 910, 489
};
-const float Gain_dic2_NBHR[] =
-{
- 0.0070f, 0.0001f, -0.0229f,
- -0.1476f, -0.0493f, -0.0424f,
- 0.0791f, -0.0927f, -0.0399f,
- -0.0308f, -0.0735f, -0.0748f,
- -0.0704f, 0.0302f, 0.0273f,
- -0.0211f, 0.1279f, -0.0281f,
- 0.0572f, 0.0045f, -0.1133f,
- -0.0134f, -0.0686f, 0.0436f,
- 0.0393f, 0.1088f, 0.1543f,
- 0.0893f, -0.0201f, 0.0237f,
- 0.0556f, -0.2804f, 0.0660f,
- 0.0715f, 0.0698f, -0.0348f,
- -0.0301f, -0.0085f, -0.2187f,
- -0.1319f, -0.1649f, 0.0427f,
- 0.0807f, -0.1180f, -0.1678f,
- -0.1901f, 0.0498f, -0.1630f,
- -0.1202f, 0.1876f, -0.1245f,
- -0.2966f, -0.1514f, -0.1179f,
- 0.1663f, -0.0185f, -0.0722f,
- -0.1638f, 0.0966f, -0.0110f,
- -0.1854f, 0.0728f, 0.1377f,
- -0.0693f, 0.1437f, 0.0784f,
- -0.3336f, -0.1445f, 0.1210f,
- -0.1093f, -0.1429f, -0.1739f,
- 0.0029f, -0.1845f, -0.0220f,
- 0.1253f, 0.0407f, -0.2262f,
- -0.2861f, 0.2587f, -0.2925f,
- -0.1164f, 0.1825f, 0.2457f,
- 0.0103f, 0.0251f, 0.3118f,
- -0.2296f, 0.2562f, 0.0336f,
- -0.2257f, -0.0035f, -0.3586f,
- 0.1669f, 0.1657f, -0.3857f,
- 0.1019f, -0.0912f, -0.3838f,
- 0.1482f, 0.0660f, 0.0626f,
- 0.1384f, 0.1899f, 0.2057f,
- 0.3452f, -0.0544f, -0.1323f,
- 0.0236f, 0.0488f, 0.0614f,
- 0.0541f, 0.2623f, -0.1335f,
- -0.1744f, -0.0697f, 0.2553f,
- 0.0943f, -0.1671f, 0.2403f,
- 0.0826f, 0.1646f, 0.0282f,
- -0.0668f, 0.0418f, -0.0898f,
- 0.1419f, -0.4567f, 0.0836f,
- 0.0229f, 0.1079f, -0.1457f,
- -0.0715f, -0.2943f, 0.2078f,
- -0.0311f, 0.1224f, -0.3045f,
- 0.0428f, 0.4151f, 0.3314f,
- -0.0059f, 0.2989f, 0.0695f,
- 0.1725f, -0.2325f, -0.0715f,
- 0.1631f, 0.1202f, -0.0993f,
- 0.2841f, 0.1833f, 0.0490f,
- 0.0929f, -0.1452f, 0.0702f,
- -0.3833f, 0.1174f, -0.1297f,
- -0.1458f, -0.0391f, 0.0797f,
- -0.1412f, -0.3200f, -0.0097f,
- -0.0287f, -0.1278f, 0.1406f,
- -0.3695f, 0.1286f, 0.1848f,
- -0.0450f, 0.0097f, 0.1487f,
- -0.2966f, 0.0239f, 0.0167f,
- -0.0159f, -0.3233f, -0.2040f,
- 0.2004f, -0.0729f, 0.0498f,
- 0.1943f, 0.0051f, 0.2050f,
- 0.0757f, -0.0325f, 0.1324f,
- 0.2545f, -0.2377f, 0.1312f,
-};
-
-const float Gain_dic3_NBHR[] =
-{
- 0.0715f, 0.0018f, -0.0493f, -0.0232f,
- 0.1305f, 0.0268f, 0.1323f, -0.1251f,
- -0.1410f, 0.0158f, -0.1367f, -0.0843f,
- 0.0502f, 0.0811f, 0.0024f, -0.1302f,
- -0.0186f, 0.0869f, -0.0034f, 0.0203f,
- 0.0363f, -0.0908f, -0.0475f, -0.1196f,
- -0.1168f, -0.0588f, -0.0135f, 0.0275f,
- -0.0716f, -0.1147f, -0.1479f, 0.0151f,
- 0.1947f, -0.3535f, 0.1525f, -0.2753f,
- 0.0423f, 0.1132f, -0.4115f, -0.0120f,
- -0.0956f, -0.0720f, -0.0388f, -0.1134f,
- -0.1746f, 0.1026f, -0.0357f, -0.2402f,
- -0.0087f, 0.0068f, -0.1182f, 0.0290f,
- 0.1152f, 0.0665f, -0.1780f, -0.0283f,
- 0.0167f, -0.0212f, -0.1534f, -0.1048f,
- 0.1047f, -0.2240f, -0.0385f, -0.0466f,
- -0.1331f, 0.0561f, -0.1063f, 0.0637f,
- -0.0312f, 0.0037f, -0.1930f, 0.1494f,
- 0.0655f, -0.0945f, -0.3072f, 0.0248f,
- 0.0922f, 0.0580f, 0.0735f, 0.0007f,
- -0.1207f, 0.0363f, 0.0319f, -0.0303f,
- 0.1547f, -0.0751f, 0.0242f, 0.0058f,
- 0.1397f, 0.1735f, 0.1842f, -0.2776f,
- -0.2707f, 0.0977f, 0.2668f, 0.0901f,
- -0.2028f, -0.1033f, 0.3865f, 0.2659f,
- -0.0203f, 0.0380f, -0.0256f, 0.2631f,
- -0.2270f, 0.1163f, 0.0372f, 0.0927f,
- 0.1894f, 0.2838f, 0.1924f, -0.0104f,
- 0.0680f, 0.0122f, 0.0997f, 0.1458f,
- 0.1162f, 0.1180f, 0.0179f, 0.1828f,
- 0.2204f, 0.1676f, 0.0196f, -0.1003f,
- 0.0476f, -0.1876f, 0.0683f, 0.0840f,
- -0.0641f, -0.2440f, -0.0112f, -0.0693f,
- -0.0161f, 0.0641f, 0.0769f, -0.3024f,
- 0.1061f, 0.1410f, -0.0572f, -0.2854f,
- 0.0487f, -0.4075f, 0.0459f, 0.0278f,
- -0.0140f, 0.1022f, -0.1243f, -0.1545f,
- 0.0240f, -0.0290f, 0.0314f, -0.1991f,
- -0.0383f, -0.0890f, -0.0607f, 0.1311f,
- 0.0164f, -0.1524f, 0.0296f, 0.2814f,
- 0.3526f, 0.0346f, -0.1425f, 0.0093f,
- 0.2652f, -0.0205f, 0.0395f, 0.2426f,
- 0.0958f, -0.0937f, -0.0302f, 0.1301f,
- 0.0615f, 0.0446f, -0.2835f, -0.2160f,
- -0.1053f, -0.2025f, 0.0248f, 0.1055f,
- -0.1728f, 0.2409f, -0.2493f, -0.1572f,
- -0.0157f, 0.0293f, -0.4112f, 0.2406f,
- 0.0512f, -0.1206f, -0.2211f, 0.3179f,
- 0.0121f, -0.0455f, 0.0431f, 0.0451f,
- -0.0626f, 0.2130f, -0.2451f, 0.0946f,
- 0.1376f, -0.0196f, -0.1657f, 0.1258f,
- -0.1862f, -0.0097f, -0.2866f, 0.0556f,
- -0.2513f, 0.0485f, -0.0144f, -0.0726f,
- 0.0073f, -0.0115f, 0.0484f, -0.0645f,
- -0.0966f, -0.3504f, 0.2229f, -0.2486f,
- -0.0344f, 0.2348f, 0.0088f, 0.1117f,
- 0.0088f, -0.0947f, 0.1894f, -0.2441f,
- -0.0181f, 0.1194f, 0.2775f, 0.0341f,
- -0.2369f, -0.1871f, 0.1625f, -0.0285f,
- 0.0220f, 0.1462f, 0.4066f, 0.3429f,
- -0.0763f, -0.1673f, -0.1866f, -0.1501f,
- 0.1374f, -0.1128f, -0.1530f, -0.1874f,
- 0.1933f, 0.1366f, -0.3527f, 0.1357f,
- -0.1419f, 0.1760f, -0.1364f, 0.2775f,
- -0.1707f, -0.0667f, 0.0668f, -0.2065f,
- 0.2295f, -0.1684f, 0.1824f, -0.0617f,
- -0.0431f, -0.1322f, 0.3309f, -0.0529f,
- -0.1430f, 0.1042f, 0.2921f, -0.2119f,
- 0.0358f, 0.1299f, -0.1342f, 0.0989f,
- 0.0631f, 0.1654f, -0.0598f, -0.0405f,
- 0.1884f, 0.2592f, -0.0807f, 0.1176f,
- 0.0948f, 0.4565f, -0.1406f, 0.3869f,
- 0.1129f, 0.2113f, 0.1108f, 0.2958f,
- 0.1392f, 0.1289f, -0.1663f, 0.3001f,
- -0.0943f, 0.1483f, 0.1463f, 0.2112f,
- -0.0376f, -0.0049f, -0.0515f, -0.0564f,
- 0.0234f, 0.1798f, 0.0996f, -0.0633f,
- 0.1864f, -0.3743f, 0.2672f, 0.0607f,
- 0.1720f, -0.2764f, 0.4289f, -0.2641f,
- 0.0758f, -0.1174f, 0.0803f, -0.0964f,
- 0.0473f, -0.1906f, 0.0144f, -0.2328f,
- -0.2278f, -0.2336f, -0.0060f, 0.4555f,
- -0.2079f, -0.0547f, -0.1176f, 0.2006f,
- -0.3511f, 0.1197f, 0.0539f, 0.3127f,
- 0.0956f, 0.1653f, 0.1317f, 0.0846f,
- 0.2158f, -0.1499f, 0.4502f, 0.1656f,
- -0.1886f, 0.1181f, -0.2266f, 0.6047f,
- -0.0670f, -0.1125f, 0.0923f, -0.0642f,
- -0.0690f, -0.0762f, 0.1423f, 0.0834f,
- 0.1107f, -0.3762f, 0.0924f, 0.3090f,
- 0.1900f, 0.2673f, 0.3150f, 0.2012f,
- -0.2339f, -0.1082f, -0.0508f, -0.0173f,
- 0.2405f, -0.2444f, -0.0301f, 0.1156f,
- 0.0136f, -0.2449f, -0.1253f, 0.1158f,
- -0.0633f, 0.3504f, 0.2381f, 0.0768f,
- -0.0143f, -0.0412f, 0.1767f, 0.2347f,
- -0.0512f, 0.2515f, 0.0832f, -0.2386f,
- 0.2573f, 0.7121f, -0.0018f, -0.2141f,
- -0.2079f, -0.0557f, 0.0805f, 0.1525f,
- 0.0022f, -0.1280f, -0.0237f, -0.0035f,
- 0.0038f, -0.0122f, 0.1163f, 0.5874f,
- 0.0644f, -0.0581f, 0.1875f, 0.0136f,
- 0.0457f, 0.0263f, -0.0413f, 0.1088f,
- 0.1644f, 0.0582f, 0.2423f, 0.1638f,
- -0.0532f, 0.0697f, 0.1184f, 0.0443f,
- 0.1633f, -0.1285f, 0.1561f, 0.1394f,
- 0.1586f, 0.0050f, -0.0458f, -0.1260f,
- 0.2517f, 0.0403f, 0.1285f, 0.0333f,
- -0.0813f, 0.0750f, 0.0248f, -0.1389f,
- -0.0383f, 0.0755f, -0.2281f, -0.0295f,
- -0.0820f, 0.0345f, 0.0096f, 0.1308f,
- 0.1616f, 0.0888f, -0.0324f, 0.0543f,
- -0.3135f, 0.1556f, -0.1552f, 0.0187f,
- 0.3031f, 0.2066f, 0.1139f, 0.1557f,
- 0.2055f, 0.0801f, 0.3248f, -0.0781f,
- 0.0372f, -0.2464f, 0.1343f, -0.0524f,
- -0.1885f, 0.0032f, 0.1451f, -0.0297f,
- 0.0820f, -0.1000f, -0.1336f, -0.0005f,
- 0.2121f, -0.0259f, 0.0784f, -0.2882f,
- 0.1259f, 0.3045f, -0.2021f, -0.1408f,
- -0.1636f, 0.2132f, 0.0897f, -0.0322f,
- -0.1013f, 0.1537f, -0.0700f, -0.0400f,
- -0.0256f, 0.0338f, 0.1603f, -0.1077f,
- -0.0390f, -0.2649f, 0.2294f, 0.1718f,
- -0.0313f, -0.0166f, -0.0901f, -0.2568f,
- -0.3501f, 0.1449f, 0.1334f, -0.1623f,
- -0.4515f, 0.0182f, 0.0428f, 0.0424f,
- -0.3133f, 0.1780f, -0.3883f, 0.2519f,
-};
-
const Word16 Gain_dic2_NBHR_fx[3 * 64] = /*Q12 */
{
29, 0, -94,
@@ -18313,177 +17179,11 @@ const Word16 Gain_dic3_NBHR_fx[4 * 128] = /*Q12 */
-1283, 729, -1590, 1032
};
-const float YG_mean16[] =
-{
- -0.0968f, -0.0468f, -0.0409f, -0.0332f,
- -0.0147f, -0.0042f, 0.0111f, 0.0096f,
- 0.0293f, 0.0198f, 0.0219f, 0.0164f,
- 0.0358f, 0.0083f, 0.0398f, 0.0448f,
-};
const Word16 YG_mean16_fx[1 * 16] = /*Q12 */
{
-396, -192, -168, -136, -60, -17, 45, 39,
120, 81, 90, 67, 147, 34, 163, 184
};
-const float YG_dicMR_1[] =
-{
- -0.4588f, 0.2016f, 0.1315f, -0.0513f,
- -0.0294f, 0.0652f, -0.0335f, -0.0347f,
- -0.1948f, -0.1154f, 0.1059f, 0.0594f,
- 0.0724f, -0.2188f, 0.0901f, 0.0750f,
- -0.4597f, -0.3254f, 0.1015f, 0.1244f,
- -0.4774f, -0.1611f, -0.1151f, 0.0548f,
- -0.2210f, -0.1962f, -0.1262f, 0.1056f,
- -0.2346f, 0.0050f, -0.0631f, -0.0547f,
- 0.0510f, 0.2386f, -0.0519f, -0.0042f,
- 0.1308f, -0.0595f, 0.0388f, 0.0238f,
- -0.0647f, 0.1891f, 0.1005f, -0.0799f,
- 0.0823f, -0.0955f, -0.0579f, -0.1152f,
- -0.4790f, -0.4482f, -0.1689f, 0.1149f,
- 0.1525f, 0.0422f, -0.1130f, -0.0037f,
- -0.2356f, 0.0643f, 0.0151f, 0.1466f,
- -0.1910f, 0.2170f, -0.1056f, 0.0514f,
- -0.4373f, 0.2081f, -0.1106f, -0.1895f,
- -0.0445f, -0.0433f, -0.2631f, 0.0195f,
- -0.0889f, 0.0855f, 0.0683f, 0.0715f,
- -0.2201f, 0.2731f, 0.0719f, -0.2914f,
- 0.0038f, 0.1073f, -0.0835f, 0.1121f,
- -0.4455f, -0.3868f, -0.3375f, -0.1949f,
- 0.1764f, 0.0140f, -0.3015f, -0.1613f,
- 0.2167f, -0.3999f, 0.0677f, 0.0572f,
- 0.0831f, 0.0842f, 0.0345f, -0.1490f,
- 0.3124f, -0.0055f, 0.0042f, 0.0352f,
- -0.1561f, -0.2081f, -0.1269f, -0.1350f,
- 0.2519f, 0.2059f, 0.0364f, 0.1061f,
- 0.1418f, 0.1911f, 0.1266f, -0.0479f,
- 0.1115f, 0.2308f, 0.1216f, -0.3146f,
- -0.4631f, -0.0101f, 0.1038f, 0.1255f,
- 0.1921f, 0.0393f, 0.1236f, 0.0941f,
- -0.1365f, 0.2635f, 0.0780f, 0.1258f,
- 0.1220f, 0.0830f, 0.0146f, 0.0258f,
- 0.0614f, -0.2434f, -0.2840f, -0.2344f,
- 0.0638f, -0.3144f, -0.1540f, 0.0817f,
- 0.3029f, -0.1514f, -0.0944f, -0.1617f,
- 0.0407f, 0.0474f, 0.1163f, 0.0163f,
- 0.2027f, -0.0636f, 0.1049f, -0.2933f,
- -0.1169f, -0.0300f, 0.0174f, -0.2837f,
- 0.0550f, -0.3618f, 0.0322f, -0.1958f,
- 0.1659f, 0.1862f, -0.2466f, 0.1048f,
- 0.0488f, -0.0304f, 0.0638f, 0.1441f,
- 0.1882f, -0.1807f, -0.0447f, 0.0559f,
- -0.4542f, -0.0850f, 0.0678f, -0.1340f,
- -0.4317f, 0.2362f, 0.0687f, 0.1451f,
- -0.4217f, -0.4143f, 0.0213f, -0.1866f,
- 0.2853f, 0.1540f, -0.0279f, -0.1151f,
- -0.3994f, -0.0247f, -0.3232f, -0.0221f,
- 0.2004f, -0.1819f, 0.1119f, -0.0644f,
- 0.2475f, -0.1406f, 0.0951f, 0.1147f,
- 0.2541f, -0.1261f, -0.2486f, 0.0897f,
- 0.2016f, 0.0042f, 0.1040f, -0.0797f,
- -0.1140f, -0.4007f, 0.0491f, 0.0794f,
- -0.4653f, 0.1045f, -0.0824f, 0.0541f,
- -0.2492f, 0.1539f, 0.1023f, -0.0183f,
- -0.0211f, -0.0926f, -0.0495f, 0.0572f,
- 0.1609f, 0.1286f, -0.1199f, -0.3680f,
- -0.1378f, -0.4261f, -0.2389f, -0.0422f,
- -0.4306f, -0.1056f, -0.1813f, -0.2662f,
- 0.0590f, 0.1732f, 0.0657f, 0.1213f,
- 0.1749f, 0.0180f, -0.0507f, 0.1508f,
- -0.0724f, 0.1574f, -0.2109f, -0.1965f,
- -0.0112f, -0.0797f, 0.1006f, -0.0723f,
-};
-
-const float YG_dicMR_2[] =
-{
- 0.0228f, 0.0529f, -0.0298f, 0.0091f,
- -0.0032f, -0.0203f, 0.0257f, -0.1199f,
- -0.0972f, -0.1446f, 0.0973f, -0.0390f,
- 0.1325f, -0.0197f, -0.1147f, 0.0997f,
- 0.0963f, -0.1539f, -0.0230f, -0.0630f,
- -0.1623f, 0.0325f, -0.0331f, -0.0305f,
- 0.0970f, -0.0857f, 0.1538f, -0.0361f,
- -0.2846f, 0.0992f, -0.2111f, 0.1353f,
- -0.0333f, -0.0737f, -0.0642f, 0.0198f,
- -0.1646f, -0.1605f, -0.1393f, -0.1688f,
- -0.0503f, 0.0930f, -0.1707f, 0.0298f,
- 0.0665f, -0.3677f, 0.0868f, 0.0036f,
- 0.1102f, -0.2346f, 0.1557f, -0.2765f,
- 0.0772f, -0.1922f, 0.0404f, 0.1428f,
- 0.0762f, -0.0352f, 0.0451f, 0.0668f,
- 0.0095f, -0.1723f, -0.2433f, 0.0611f,
- -0.2235f, -0.2127f, -0.0279f, 0.1118f,
- -0.2035f, 0.0849f, 0.0888f, -0.2901f,
- 0.1098f, 0.1764f, -0.0625f, 0.1007f,
- 0.0902f, 0.1143f, -0.3346f, 0.1015f,
- 0.0841f, 0.0401f, 0.0707f, -0.2672f,
- 0.1622f, 0.0297f, 0.0082f, -0.0532f,
- 0.1355f, 0.0621f, 0.1365f, 0.2015f,
- 0.0762f, 0.1201f, 0.1211f, -0.0066f,
- -0.0974f, 0.0770f, 0.1685f, -0.0806f,
- -0.1118f, 0.1734f, 0.0503f, 0.1013f,
- 0.0709f, 0.0217f, -0.1615f, -0.1139f,
- -0.0176f, 0.1448f, -0.0264f, -0.1122f,
- -0.0531f, 0.0113f, 0.0778f, 0.0461f,
- -0.3335f, 0.0486f, 0.0892f, 0.0152f,
- -0.1348f, -0.0405f, 0.1884f, 0.2103f,
- -0.0387f, 0.0294f, -0.0525f, 0.1893f,
-};
-
-const float YG_dicMR_3[] =
-{
- -0.0251f, -0.0350f, -0.0207f, -0.0047f,
- -0.0986f, 0.0444f, -0.1942f, 0.0205f,
- 0.0972f, -0.1449f, -0.0134f, -0.0624f,
- 0.0691f, 0.0313f, -0.1153f, 0.0682f,
- -0.0600f, -0.1532f, 0.0686f, 0.0726f,
- -0.2082f, 0.1143f, 0.0874f, -0.2235f,
- 0.0664f, 0.0363f, 0.0510f, -0.1081f,
- -0.0409f, -0.1231f, 0.1104f, -0.1281f,
- 0.1524f, -0.1042f, 0.1901f, 0.0286f,
- 0.2634f, 0.0987f, -0.0240f, 0.0196f,
- 0.0332f, 0.0404f, 0.0347f, -0.3404f,
- 0.1252f, -0.1383f, -0.0367f, 0.2006f,
- 0.0302f, 0.1576f, 0.0487f, 0.0664f,
- -0.0403f, -0.1715f, -0.1502f, 0.0404f,
- 0.0814f, 0.1978f, -0.1116f, 0.2533f,
- -0.0878f, 0.0256f, -0.0268f, 0.1310f,
- -0.0548f, 0.0305f, 0.1372f, -0.0063f,
- 0.1706f, -0.2698f, 0.1976f, -0.3231f,
- -0.3001f, 0.2054f, -0.1872f, 0.1393f,
- -0.0756f, 0.1066f, -0.0278f, -0.0562f,
- -0.2551f, 0.1538f, 0.1377f, 0.0787f,
- 0.0689f, 0.2857f, -0.1765f, -0.0746f,
- -0.0800f, -0.0604f, -0.0612f, -0.1461f,
- 0.0864f, 0.0811f, -0.3889f, 0.1219f,
- 0.0810f, -0.0055f, 0.0534f, 0.0743f,
- 0.0794f, -0.3690f, 0.0922f, 0.0731f,
- -0.0230f, -0.0132f, 0.1657f, 0.2333f,
- 0.1238f, 0.2026f, 0.2103f, -0.1805f,
- -0.2186f, -0.0329f, 0.0040f, -0.0083f,
- 0.1654f, 0.1588f, 0.2346f, 0.1744f,
- 0.1993f, -0.1624f, -0.4251f, -0.1638f,
- 0.0670f, 0.0227f, -0.1506f, -0.1057f,
-};
-
-const float YG_dicMR_4[] =
-{
- -0.0398f, -0.0108f, -0.0263f, 0.0079f,
- 0.1358f, 0.0373f, 0.0281f, 0.0293f,
- 0.1507f, 0.1997f, 0.1958f, 0.1756f,
- -0.1560f, -0.1623f, 0.0297f, 0.1620f,
- 0.0863f, -0.1354f, -0.0860f, -0.0209f,
- -0.2836f, 0.2034f, -0.2525f, 0.0796f,
- -0.1247f, -0.0991f, -0.1167f, -0.1276f,
- 0.1198f, -0.3596f, 0.0987f, -0.0051f,
- 0.0362f, 0.0702f, -0.0111f, -0.1328f,
- -0.0148f, 0.0420f, -0.1931f, -0.0108f,
- 0.1745f, -0.1095f, 0.2103f, 0.1230f,
- -0.0264f, 0.0641f, 0.1489f, 0.0289f,
- 0.2348f, 0.2016f, -0.2473f, -0.0091f,
- -0.0077f, -0.1208f, 0.0883f, -0.0523f,
- -0.0091f, 0.1614f, -0.0183f, 0.0706f,
- -0.2039f, 0.0593f, 0.0207f, -0.0256f,
-};
const Word16 YG_dicMR_1_fx[4 * 64] = /*Q12 */
{
@@ -18643,30 +17343,11 @@ const Word16 YG_dicMR_4_fx[4 * 16] = /*Q12 */
};
-const float mean_m[] = { 2.8717f };
const Word16 mean_m_fx[1 * 1] = /*Q12 */
{
11762
};
-const float mean_gain_dic[] =
-{
- -0.1804f, -0.1267f, -0.0185f, 0.0358f,
- 0.1402f, 0.1903f, 0.2399f, 0.2894f,
- 0.3379f, 0.3858f, 0.4356f, 0.4857f,
- 0.5380f, 0.6452f, 0.6992f, 0.5914f,
- 0.0885f, -0.0721f, -0.2922f, -0.4726f,
- -0.6732f, -2.8699f, -2.0059f, 0.7528f,
- 0.8083f, -0.3501f, -0.4106f, -0.8156f,
- -2.2665f, -2.2112f, -2.1036f, -1.9001f,
- -1.7967f, -1.7001f, -1.6094f, -1.5218f,
- -1.3355f, -1.2328f, -1.1354f, -0.9654f,
- -0.6031f, -0.2352f, -0.5368f, -0.7426f,
- -0.8894f, -1.0479f, -1.4292f, -2.4899f,
- 1.0016f, 0.8661f, 1.0718f, 1.1517f,
- 0.9318f, -2.5695f, -2.8128f, -2.3365f,
- -2.4168f, -2.2389f, -2.6467f, -2.7259f,
- 1.3428f, 1.2399f, 1.4988f, 1.7072f,
-};
+
const Word16 mean_gain_dic_fx[1 * 64] =
{
-739, -519, -76, 147, 574, 779, 983, 1185,
@@ -18678,124 +17359,12 @@ const Word16 mean_gain_dic_fx[1 * 64] =
4103, 3548, 4390, 4717, 3817, -10525, -11521, -9570,
-9899, -9171, -10841, -11165, 5500, 5079, 6139, 6993
}; /* Q12 */
-const float YGain_mean_LR[] =
-{
- -0.0940f, -0.0435f, -0.0348f, -0.0284f,
- -0.0113f, -0.0029f, 0.0156f, 0.0123f,
- 0.0288f, 0.0167f, 0.0324f, 0.0369f,
-};
+
const Word16 YGain_mean_LR_fx[1 * 12] =/* Q12 */
{
-385, -178, -143, -116, -46, -12,
64, 50, 118, 68, 133, 151
};
-const float YGain_dic1_LR[] =
-{
- -0.4660f, 0.0389f, -0.0220f,
- -0.0378f, 0.1016f, -0.0036f,
- -0.0241f, -0.0205f, 0.0967f,
- -0.4472f, -0.2070f, -0.0781f,
- -0.1901f, 0.2501f, 0.0111f,
- -0.4541f, -0.4299f, 0.0666f,
- 0.0197f, -0.0832f, -0.0755f,
- -0.1999f, -0.0008f, -0.0770f,
- 0.1179f, 0.0525f, -0.0474f,
- 0.0591f, 0.2288f, -0.0186f,
- -0.4468f, -0.4279f, -0.2691f,
- -0.3880f, 0.2118f, -0.1605f,
- -0.2224f, 0.0950f, 0.1028f,
- -0.4478f, 0.2234f, 0.0952f,
- -0.0352f, 0.1378f, -0.2121f,
- 0.2143f, -0.3769f, 0.0736f,
- 0.1089f, 0.0811f, 0.0917f,
- -0.1318f, -0.2008f, -0.2444f,
- 0.1339f, -0.0469f, 0.0567f,
- 0.2245f, -0.1437f, -0.0427f,
- 0.2121f, 0.1750f, -0.1378f,
- 0.1945f, -0.0252f, -0.2556f,
- -0.0819f, -0.4228f, -0.0453f,
- -0.4492f, -0.0842f, 0.1383f,
- 0.2943f, 0.0266f, 0.0106f,
- 0.2405f, -0.1113f, 0.1391f,
- 0.1588f, -0.2987f, -0.2134f,
- 0.2265f, 0.1837f, 0.0951f,
- -0.0302f, 0.2034f, 0.1404f,
- -0.4421f, -0.0608f, -0.2788f,
- -0.1736f, -0.1872f, 0.0451f,
- 0.0840f, -0.2138f, 0.0652f,
-};
-
-const float YGain_dic2_LR[] =
-{
- -0.0718f, -0.0178f, -0.0101f, 0.0026f,
- 0.0675f, 0.0806f, -0.3212f, 0.0423f,
- 0.0064f, -0.1738f, 0.0211f, 0.0003f,
- -0.2054f, -0.1316f, 0.0600f, -0.1170f,
- 0.0105f, -0.0505f, 0.1732f, 0.0282f,
- 0.0254f, -0.0482f, 0.0554f, -0.1338f,
- 0.0638f, -0.0556f, 0.0402f, 0.1480f,
- 0.1496f, 0.0983f, -0.0297f, -0.1025f,
- 0.0034f, 0.0444f, -0.1327f, -0.1633f,
- -0.1793f, 0.0958f, -0.1200f, -0.0319f,
- -0.3214f, 0.0670f, 0.0283f, 0.0808f,
- -0.3269f, 0.1307f, -0.3079f, 0.1485f,
- -0.0844f, 0.0677f, -0.1040f, 0.1779f,
- -0.2606f, -0.2042f, -0.1393f, 0.0948f,
- 0.1570f, 0.1228f, 0.1182f, 0.1300f,
- -0.0362f, 0.1092f, 0.0294f, -0.0957f,
- -0.1465f, 0.0641f, 0.1266f, -0.0182f,
- 0.1676f, -0.0844f, 0.0926f, 0.0055f,
- 0.0318f, 0.0583f, 0.0917f, -0.3336f,
- 0.0165f, 0.1601f, -0.0881f, 0.0224f,
- 0.1485f, 0.0699f, -0.0988f, 0.1190f,
- -0.2517f, 0.1238f, 0.1276f, -0.2371f,
- 0.0124f, -0.0108f, -0.1272f, 0.0421f,
- -0.1400f, -0.1221f, 0.0972f, 0.1542f,
- 0.0587f, 0.0358f, 0.0254f, 0.0125f,
- -0.0780f, -0.1659f, -0.2174f, -0.0971f,
- -0.0475f, 0.1229f, 0.0746f, 0.1120f,
- 0.0819f, 0.0898f, 0.1615f, -0.0950f,
- 0.0923f, -0.1925f, -0.1311f, 0.1660f,
- 0.1057f, -0.2756f, 0.1153f, -0.2155f,
- 0.1153f, -0.0761f, -0.0735f, -0.0506f,
- 0.0922f, -0.3286f, 0.1058f, 0.0996f,
-};
-
-const float YGain_dic3_LR[] =
-{
- -0.0810f, -0.0466f, -0.0299f, -0.1110f, -0.0512f,
- 0.0888f, -0.0116f, -0.1622f, 0.0996f, 0.0549f,
- -0.1406f, -0.0835f, 0.0897f, 0.0128f, 0.0658f,
- -0.0958f, -0.0384f, -0.0188f, 0.1526f, -0.0546f,
- -0.0446f, -0.1591f, -0.0990f, 0.0242f, 0.0650f,
- 0.0059f, 0.0158f, 0.0180f, 0.1281f, 0.1497f,
- -0.1966f, 0.0746f, -0.0936f, -0.0051f, 0.0602f,
- 0.0038f, 0.0325f, -0.1016f, -0.0009f, -0.1385f,
- 0.0718f, -0.1831f, 0.1082f, -0.0897f, 0.0557f,
- 0.1308f, 0.1992f, 0.1872f, 0.1371f, 0.1449f,
- -0.0131f, 0.0489f, -0.2706f, -0.1422f, 0.0554f,
- 0.0300f, -0.0106f, 0.1011f, -0.0918f, -0.1585f,
- 0.1445f, -0.1593f, -0.1646f, -0.0943f, -0.0868f,
- 0.0244f, -0.0142f, -0.0110f, -0.0264f, 0.0251f,
- -0.1774f, -0.0473f, -0.2856f, 0.2274f, 0.2675f,
- 0.1251f, 0.1851f, -0.1073f, -0.1877f, -0.2566f,
- 0.0885f, 0.1921f, -0.0673f, -0.0339f, 0.0364f,
- -0.0533f, 0.0944f, 0.1116f, -0.1010f, 0.0646f,
- -0.0492f, 0.1618f, -0.2695f, 0.2154f, -0.0825f,
- -0.0139f, 0.0988f, 0.0656f, 0.0628f, -0.0539f,
- 0.0817f, 0.2109f, 0.2841f, -0.1492f, -0.1509f,
- 0.3113f, 0.1205f, -0.4354f, 0.0290f, 0.2983f,
- 0.1837f, 0.0186f, 0.0660f, 0.0179f, -0.0140f,
- 0.0917f, -0.3063f, 0.0353f, 0.1767f, 0.1473f,
- -0.2414f, 0.1508f, 0.1609f, 0.1647f, 0.1367f,
- 0.0313f, -0.0359f, -0.0337f, -0.0899f, 0.2352f,
- 0.0341f, -0.0414f, 0.2115f, 0.1313f, 0.0311f,
- 0.0299f, -0.1503f, 0.0406f, 0.0575f, -0.0966f,
- 0.0914f, 0.0680f, 0.0994f, 0.1587f, -0.3097f,
- -0.2103f, 0.1496f, -0.1844f, -0.3256f, -0.2372f,
- -0.2251f, 0.0767f, 0.1015f, -0.0279f, -0.1582f,
- 0.0647f, 0.0207f, 0.0148f, -0.2710f, 0.0109f,
-};
const Word16 YGain_dic1_LR_fx[3 * 32] = /*Q12 */
{
@@ -18905,14 +17474,6 @@ const Word16 YGain_dic3_LR_fx[5 * 32] = /*Q12 */
265, 85, 61, -1110, 45
};
-const float YG_mean16HR[] =
-{
- -0.0968f, -0.0468f, -0.0409f, -0.0332f,
- -0.0147f, -0.0042f, 0.0111f, 0.0096f,
- 0.0293f, 0.0198f, 0.0219f, 0.0164f,
- 0.0358f, 0.0083f, 0.0398f, 0.0448f,
-};
-
const Word16 YG_mean16HR_fx[] =
{
//Q12
@@ -18922,138 +17483,6 @@ const Word16 YG_mean16HR_fx[] =
146, 33, 163, 183,
};
-const float YG_dicHR_1[] =
-{
- -0.4774f, 0.1006f, 0.0327f, 0.0080f,
- -0.0832f, 0.0217f, -0.0103f, 0.0049f,
- -0.2440f, 0.0768f, -0.0353f, 0.1115f,
- -0.1048f, -0.0464f, 0.0456f, 0.1336f,
- -0.2582f, 0.0393f, 0.0595f, -0.0481f,
- -0.0114f, -0.0198f, -0.1200f, -0.0546f,
- 0.0351f, 0.2409f, -0.0276f, 0.0037f,
- 0.0699f, -0.0765f, 0.0189f, 0.0008f,
- 0.0610f, -0.3055f, 0.0930f, 0.0745f,
- -0.4662f, -0.0631f, 0.1176f, 0.0212f,
- 0.2203f, 0.0146f, 0.0104f, -0.0456f,
- -0.4809f, -0.2422f, -0.0819f, 0.0545f,
- -0.4672f, -0.0398f, -0.1137f, -0.0410f,
- -0.1970f, 0.2933f, 0.0060f, 0.1176f,
- -0.1377f, -0.4744f, 0.0520f, 0.0928f,
- -0.0293f, -0.1688f, -0.0396f, 0.0339f,
- -0.2359f, 0.2464f, 0.1067f, -0.1134f,
- 0.1061f, 0.0360f, 0.0452f, 0.0388f,
- -0.4747f, -0.0325f, -0.0765f, 0.1470f,
- -0.2514f, 0.0578f, -0.1495f, -0.0912f,
- -0.1831f, -0.1396f, -0.2463f, -0.0975f,
- 0.1628f, -0.2331f, -0.0273f, 0.0217f,
- 0.0455f, -0.0040f, -0.0425f, 0.0827f,
- -0.0575f, -0.0769f, 0.0984f, -0.0597f,
- 0.0696f, 0.0327f, 0.0209f, -0.0854f,
- -0.4838f, -0.3677f, -0.3150f, 0.0826f,
- -0.4827f, -0.4701f, -0.0899f, 0.2140f,
- -0.4713f, 0.0627f, 0.1106f, 0.1629f,
- -0.4600f, 0.0633f, -0.0302f, -0.1902f,
- -0.1985f, 0.2655f, -0.1455f, -0.2476f,
- 0.0968f, 0.0162f, -0.2139f, 0.1007f,
- -0.1328f, 0.2215f, -0.1605f, 0.0736f,
- -0.1185f, 0.1496f, 0.1259f, 0.1897f,
- -0.0884f, 0.1026f, 0.1019f, -0.1266f,
- -0.4284f, 0.3193f, 0.0159f, -0.2937f,
- -0.1511f, 0.1722f, -0.0139f, -0.0138f,
- -0.4732f, 0.2455f, 0.1371f, 0.0145f,
- 0.0152f, 0.1274f, -0.1076f, 0.0780f,
- -0.4338f, 0.2469f, -0.0683f, -0.0405f,
- 0.1364f, 0.0873f, -0.1085f, -0.0116f,
- 0.1958f, -0.4880f, 0.0765f, 0.0780f,
- -0.4573f, -0.2017f, -0.4130f, -0.2389f,
- -0.1437f, -0.0720f, -0.0801f, -0.2493f,
- -0.0224f, 0.1254f, -0.0705f, -0.1295f,
- -0.4750f, -0.4797f, -0.0855f, -0.0717f,
- -0.0751f, -0.2582f, 0.0497f, -0.1541f,
- 0.0231f, -0.4184f, -0.1340f, -0.0153f,
- 0.1505f, -0.0029f, -0.1247f, -0.1905f,
- 0.1667f, -0.3843f, 0.0636f, -0.1079f,
- 0.1239f, -0.1901f, 0.1275f, -0.0215f,
- 0.3226f, -0.1551f, -0.1057f, -0.1512f,
- 0.0901f, -0.1502f, -0.0820f, -0.4019f,
- 0.2507f, -0.1398f, 0.0648f, -0.0626f,
- 0.1902f, 0.0312f, -0.0379f, 0.0871f,
- -0.1130f, -0.0441f, -0.1557f, 0.0990f,
- 0.3247f, 0.2615f, 0.1327f, 0.1916f,
- 0.1061f, -0.1145f, 0.0293f, -0.1419f,
- 0.3159f, -0.1299f, 0.0148f, 0.0922f,
- 0.0156f, -0.3151f, -0.0822f, 0.1729f,
- 0.1848f, 0.0104f, 0.1008f, 0.1483f,
- 0.1787f, 0.2451f, 0.1461f, -0.3391f,
- -0.4440f, -0.4068f, 0.1336f, 0.0454f,
- -0.4677f, -0.1959f, 0.1186f, 0.1927f,
- 0.2215f, 0.1068f, 0.1111f, 0.0264f,
- 0.1240f, -0.0250f, 0.1399f, -0.0267f,
- 0.2534f, -0.3155f, -0.1689f, 0.1250f,
- 0.3487f, 0.0389f, 0.0050f, 0.0662f,
- 0.0273f, -0.2017f, -0.1483f, -0.1375f,
- -0.1520f, -0.3243f, -0.3398f, -0.2442f,
- -0.0039f, 0.2672f, 0.0828f, -0.1671f,
- 0.1096f, 0.1931f, -0.1074f, -0.3950f,
- -0.4310f, -0.2304f, -0.1606f, -0.1649f,
- 0.0262f, -0.2040f, -0.2784f, 0.0590f,
- 0.0081f, 0.0298f, 0.1270f, 0.0592f,
- 0.0475f, 0.0499f, 0.0766f, -0.2637f,
- 0.3194f, 0.1340f, -0.1736f, -0.2076f,
- 0.3712f, 0.1159f, 0.0816f, -0.1261f,
- 0.2666f, -0.0103f, 0.0849f, -0.3768f,
- 0.2682f, -0.0535f, 0.1662f, 0.0341f,
- 0.2089f, -0.2186f, 0.1498f, -0.2405f,
- -0.3982f, -0.3785f, 0.1317f, -0.3119f,
- 0.1642f, 0.2211f, -0.2583f, 0.1052f,
- 0.1357f, 0.1610f, -0.0094f, 0.1101f,
- -0.2731f, -0.0130f, 0.1309f, 0.1191f,
- 0.1376f, -0.1186f, -0.0500f, 0.1589f,
- -0.1657f, -0.2271f, 0.1148f, 0.1038f,
- 0.2881f, -0.0634f, -0.2417f, 0.0781f,
- 0.2425f, 0.0780f, -0.0886f, 0.2261f,
- 0.1911f, -0.0621f, -0.3533f, -0.1305f,
- -0.4753f, 0.2355f, 0.0210f, 0.1508f,
- -0.4033f, 0.1776f, -0.1987f, 0.1256f,
- -0.1350f, 0.0966f, 0.1276f, 0.0305f,
- -0.4175f, 0.1414f, 0.2031f, -0.1324f,
- 0.0085f, 0.1132f, 0.0351f, 0.0005f,
- -0.4254f, -0.0507f, -0.1569f, -0.3704f,
- -0.4804f, -0.1808f, 0.0665f, -0.1480f,
- 0.1621f, 0.1638f, 0.0143f, -0.1516f,
- 0.0561f, 0.0670f, 0.0299f, 0.1654f,
- 0.0160f, 0.2794f, 0.0060f, 0.1692f,
- -0.3377f, 0.2591f, 0.1540f, 0.2183f,
- 0.1311f, 0.1317f, 0.0259f, -0.0077f,
- 0.2639f, 0.1890f, -0.0654f, 0.0164f,
- 0.0867f, 0.1267f, 0.1488f, -0.0822f,
- 0.1899f, -0.1796f, 0.1008f, 0.1346f,
- 0.0535f, -0.1037f, 0.0958f, 0.1103f,
- -0.1326f, -0.4661f, -0.0463f, -0.2278f,
- -0.2291f, -0.0436f, 0.1196f, -0.2462f,
- -0.1829f, -0.2971f, -0.1075f, -0.0384f,
- 0.1663f, -0.0868f, -0.1033f, -0.0047f,
- 0.0731f, 0.2571f, -0.2231f, -0.1236f,
- -0.0632f, 0.0881f, -0.3559f, -0.0095f,
- -0.0645f, 0.2361f, 0.1268f, 0.0144f,
- -0.1754f, -0.4094f, -0.2893f, 0.0454f,
- 0.1811f, -0.0769f, 0.0451f, 0.0513f,
- -0.4348f, -0.0747f, -0.3173f, 0.0408f,
- -0.4670f, -0.4717f, -0.3156f, -0.2369f,
- -0.2484f, -0.1271f, -0.0235f, -0.0333f,
- -0.4466f, 0.1222f, -0.3039f, -0.1527f,
- -0.2543f, -0.1933f, -0.1126f, 0.1443f,
- 0.1729f, -0.3386f, -0.2632f, -0.2335f,
- 0.0828f, 0.1555f, 0.1244f, 0.0997f,
- -0.0321f, 0.0260f, -0.2937f, -0.2730f,
- 0.1999f, 0.0046f, 0.1166f, -0.1652f,
- 0.1631f, 0.2872f, 0.1031f, -0.0089f,
- 0.2623f, -0.3076f, 0.1038f, 0.0652f,
- -0.0688f, 0.1318f, 0.0077f, 0.1051f,
- -0.2922f, 0.1846f, 0.0826f, 0.0577f,
- -0.1389f, 0.2515f, 0.1029f, -0.3880f,
-};
-
const Word16 YG_dicHR_1_fx[] =
{
//Q12
@@ -19186,73 +17615,6 @@ const Word16 YG_dicHR_1_fx[] =
-1196, 756, 338, 236,
-568, 1030, 421, -1589,
};
-const float YG_dicHR_2[] =
-{
- 0.0357f, -0.0180f, -0.0164f, -0.0247f,
- -0.0028f, 0.0807f, -0.0430f, -0.1487f,
- -0.0693f, -0.0078f, -0.0931f, -0.0468f,
- -0.0510f, -0.0198f, 0.0348f, 0.0573f,
- 0.0345f, -0.0919f, -0.0162f, -0.1579f,
- 0.1387f, -0.0093f, -0.1048f, 0.0391f,
- 0.0406f, 0.2031f, 0.0219f, -0.0253f,
- 0.0684f, -0.2153f, -0.0724f, -0.0201f,
- -0.0288f, -0.0010f, 0.0831f, -0.2336f,
- 0.0699f, -0.0333f, -0.1658f, -0.1001f,
- 0.0345f, 0.0443f, -0.0483f, 0.1249f,
- -0.1674f, 0.1583f, 0.0602f, -0.0893f,
- 0.1526f, -0.1636f, 0.1444f, 0.0464f,
- -0.0019f, -0.0723f, -0.1110f, 0.0575f,
- 0.2052f, 0.0309f, 0.1594f, 0.2598f,
- -0.1046f, -0.1393f, -0.0044f, -0.0189f,
- -0.0728f, -0.2377f, 0.1556f, 0.0930f,
- -0.1890f, -0.0078f, -0.0813f, -0.2203f,
- -0.3685f, 0.0409f, 0.1152f, -0.0903f,
- 0.1053f, -0.3510f, 0.0303f, 0.1491f,
- -0.2241f, 0.1248f, 0.1267f, -0.3634f,
- -0.0239f, 0.0640f, -0.2129f, 0.0604f,
- 0.1341f, -0.0406f, 0.1471f, -0.1442f,
- 0.1574f, -0.2515f, 0.1945f, -0.3124f,
- 0.1283f, -0.0092f, 0.0518f, 0.0483f,
- 0.0345f, 0.0844f, 0.0477f, 0.0517f,
- 0.0223f, -0.0175f, 0.1646f, 0.0546f,
- -0.3280f, -0.2203f, -0.0068f, 0.0572f,
- -0.1142f, -0.2396f, -0.1043f, 0.1771f,
- 0.0430f, -0.1288f, 0.0208f, 0.0672f,
- -0.1597f, -0.2099f, 0.1155f, -0.2132f,
- 0.1640f, -0.1117f, -0.0797f, 0.1813f,
- 0.1707f, 0.1498f, -0.0192f, 0.1117f,
- -0.1191f, 0.1235f, 0.0566f, 0.1413f,
- -0.0476f, 0.2265f, -0.1205f, 0.1293f,
- 0.1551f, 0.1354f, -0.2239f, 0.1299f,
- -0.1354f, -0.0030f, -0.0768f, 0.1492f,
- 0.0422f, 0.1630f, 0.1301f, -0.2134f,
- 0.1451f, 0.0660f, -0.0068f, -0.0923f,
- 0.0948f, -0.1294f, -0.3191f, 0.0669f,
- 0.1581f, 0.1102f, 0.1638f, 0.0059f,
- 0.1820f, -0.1148f, 0.0020f, -0.0635f,
- -0.1771f, -0.0715f, -0.2487f, -0.0080f,
- 0.0234f, 0.0451f, 0.0808f, -0.0684f,
- -0.1860f, -0.0331f, 0.1349f, 0.0612f,
- -0.1014f, -0.0008f, 0.0482f, -0.0750f,
- 0.0347f, 0.1714f, 0.1427f, 0.1845f,
- 0.1100f, 0.1455f, -0.2468f, -0.1282f,
- -0.1112f, -0.2792f, -0.1894f, -0.1562f,
- 0.0557f, 0.1211f, -0.4094f, 0.0976f,
- 0.0201f, 0.0593f, -0.1301f, 0.2984f,
- 0.0306f, -0.0523f, 0.0779f, 0.1963f,
- -0.0715f, 0.0928f, -0.0309f, 0.0172f,
- 0.0235f, -0.1172f, 0.0995f, -0.0633f,
- -0.1553f, -0.0363f, 0.2174f, 0.3030f,
- 0.0521f, 0.0987f, -0.0934f, -0.0018f,
- -0.0770f, 0.1243f, 0.1613f, 0.0150f,
- 0.1233f, 0.0046f, 0.0082f, -0.3383f,
- -0.1388f, 0.1750f, -0.1521f, -0.0827f,
- -0.1075f, 0.0095f, 0.2374f, -0.1111f,
- -0.3469f, 0.1407f, -0.2749f, 0.1633f,
- -0.3396f, 0.1176f, 0.0561f, 0.1449f,
- 0.0819f, -0.3576f, 0.1050f, -0.0916f,
- -0.2243f, 0.0304f, -0.0379f, 0.0084f,
-};
const Word16 YG_dicHR_2_fx[] =
{
@@ -19323,74 +17685,6 @@ const Word16 YG_dicHR_2_fx[] =
-918, 124, -155, 34,
};
-const float YG_dicHR_3[] =
-{
- -0.0426f, -0.0202f, -0.0387f, -0.0030f,
- 0.0380f, -0.0984f, 0.0280f, -0.0324f,
- 0.0460f, 0.0006f, -0.0566f, -0.1148f,
- 0.1094f, -0.0542f, -0.1462f, -0.0253f,
- -0.0863f, 0.0744f, -0.2866f, 0.1026f,
- -0.0105f, -0.0188f, -0.1303f, 0.0944f,
- 0.1286f, -0.0140f, 0.0879f, -0.0605f,
- -0.2045f, -0.0537f, -0.0840f, 0.0103f,
- -0.0578f, 0.0215f, -0.1623f, -0.0552f,
- -0.2976f, 0.0162f, 0.0885f, -0.1293f,
- -0.0974f, 0.1213f, -0.0734f, 0.0731f,
- 0.0520f, 0.1242f, -0.1272f, 0.0196f,
- -0.0653f, -0.1276f, 0.0112f, 0.0700f,
- -0.0159f, -0.2792f, 0.0376f, -0.0414f,
- 0.1771f, -0.3623f, 0.2157f, -0.3563f,
- 0.0022f, -0.0268f, 0.0817f, -0.1837f,
- -0.0095f, 0.2102f, -0.0056f, -0.0815f,
- -0.1191f, 0.0831f, 0.0495f, -0.3733f,
- -0.0854f, 0.0945f, 0.1575f, -0.1134f,
- -0.0259f, 0.0180f, 0.0416f, 0.1044f,
- 0.0441f, 0.0938f, -0.0713f, 0.2415f,
- 0.0436f, -0.1234f, 0.1509f, 0.0916f,
- 0.1176f, 0.1316f, -0.4339f, 0.2564f,
- 0.1662f, -0.1935f, 0.0160f, 0.0334f,
- -0.3389f, 0.1950f, -0.2663f, 0.1638f,
- -0.0921f, -0.1238f, -0.0341f, -0.1417f,
- 0.0737f, 0.1500f, 0.0476f, 0.0958f,
- -0.0533f, -0.2820f, 0.0834f, 0.2038f,
- 0.0826f, -0.2616f, -0.2874f, 0.1644f,
- -0.0993f, 0.0460f, -0.0225f, -0.1335f,
- -0.0142f, -0.1604f, 0.1888f, -0.1319f,
- 0.1126f, 0.1585f, 0.2053f, -0.0266f,
- -0.1893f, -0.0861f, 0.1514f, 0.0570f,
- -0.0954f, 0.1628f, 0.1468f, 0.1070f,
- -0.0964f, 0.3893f, -0.0730f, 0.2465f,
- 0.0898f, 0.1094f, 0.0711f, -0.2164f,
- 0.1926f, 0.0187f, 0.1170f, 0.1297f,
- -0.0188f, -0.1601f, -0.1222f, -0.0035f,
- 0.1257f, -0.4262f, 0.1214f, 0.0531f,
- 0.2209f, -0.2352f, 0.1540f, 0.3080f,
- 0.1894f, 0.0548f, -0.1943f, 0.1270f,
- 0.0712f, -0.1064f, -0.0275f, 0.1659f,
- 0.1207f, 0.3370f, -0.2487f, -0.0456f,
- -0.0185f, 0.0212f, 0.1785f, 0.2561f,
- 0.0161f, 0.0183f, 0.1507f, 0.0244f,
- 0.1251f, -0.0114f, 0.1731f, -0.3995f,
- -0.2262f, 0.3021f, 0.2663f, -0.1984f,
- 0.0100f, 0.0727f, 0.0237f, -0.0320f,
- 0.1602f, 0.1882f, 0.2873f, 0.2248f,
- 0.3206f, -0.1423f, -0.4473f, -0.2229f,
- 0.1197f, -0.1583f, -0.0106f, -0.1966f,
- -0.1098f, -0.2154f, -0.3597f, -0.1705f,
- 0.2511f, 0.1028f, -0.0370f, -0.0707f,
- 0.2659f, 0.2704f, -0.0354f, 0.1857f,
- 0.0461f, 0.0873f, -0.1559f, -0.2509f,
- -0.0824f, -0.0513f, 0.0733f, -0.0475f,
- 0.0781f, 0.0546f, -0.3875f, -0.0158f,
- 0.2374f, 0.3380f, 0.1919f, -0.2505f,
- 0.2268f, -0.1145f, 0.2727f, -0.0484f,
- -0.3637f, 0.1569f, 0.0659f, 0.0942f,
- -0.1531f, 0.0612f, 0.0375f, 0.0123f,
- -0.2213f, 0.1497f, -0.1265f, -0.1066f,
- 0.0926f, 0.0044f, -0.0167f, 0.0533f,
- -0.1584f, -0.0208f, -0.0269f, 0.1868f,
-};
-
const Word16 YG_dicHR_3_fx[] =
{
//Q12
@@ -19460,85 +17754,12 @@ const Word16 YG_dicHR_3_fx[] =
-648, -85, -110, 765,
};
-const float YG_mean16HR_16kHz[] =
-{
- 0.0837f, 0.0372f, 0.0912f, 0.0878f,
-};
-
const Word16 YG_mean16HR_16kHz_fx[] =
{
//Q12
342, 152, 373, 359
};
-const float YG_dicHR_4_16kHz[] =
-{
- 0.0336f, 0.0267f, 0.0526f, 0.0053f,
- 0.0802f, -0.0065f, 0.1313f, -0.0660f,
- -0.0335f, -0.2078f, -0.0942f, -0.1717f,
- -0.1312f, -0.0199f, -0.0596f, -0.0058f,
- -0.0426f, -0.1039f, -0.0428f, -0.0858f,
- 0.2103f, 0.2687f, 0.1701f, 0.1402f,
- -0.0368f, -0.0036f, -0.0953f, -0.0589f,
- -0.2022f, 0.0406f, 0.0402f, -0.0370f,
- -0.0552f, 0.1323f, 0.0499f, -0.0270f,
- 0.0450f, 0.2002f, -0.0219f, 0.0645f,
- -0.0065f, 0.2172f, 0.1731f, 0.1270f,
- 0.0205f, -0.0432f, -0.1742f, -0.0674f,
- -0.0365f, -0.3219f, 0.1785f, -0.0473f,
- -0.0792f, -0.0136f, 0.0290f, 0.0446f,
- 0.1158f, -0.1206f, -0.1005f, 0.0128f,
- 0.0381f, -0.3563f, -0.0904f, -0.0175f,
- 0.1253f, 0.1103f, 0.2376f, 0.0693f,
- 0.2207f, -0.0725f, 0.0756f, 0.0296f,
- 0.3080f, 0.0724f, 0.2164f, 0.1716f,
- 0.2403f, -0.2941f, 0.2234f, 0.0037f,
- -0.0980f, 0.1115f, -0.0772f, 0.0333f,
- 0.1119f, -0.4345f, 0.0818f, -0.1924f,
- 0.1152f, -0.1945f, 0.0584f, -0.0809f,
- -0.0954f, -0.5530f, 0.1204f, -0.0747f,
- 0.1146f, -0.4752f, 0.0950f, 0.0684f,
- 0.0368f, 0.1132f, -0.1772f, 0.0279f,
- -0.1005f, 0.0244f, -0.2212f, -0.0313f,
- 0.1534f, 0.2169f, 0.3173f, 0.2538f,
- 0.3552f, 0.3364f, 0.3457f, 0.3297f,
- -0.0003f, 0.0593f, -0.0401f, -0.0028f,
- 0.1544f, 0.1517f, 0.1017f, 0.1697f,
- 0.0969f, -0.2516f, 0.0871f, 0.1202f,
- 0.0119f, -0.0682f, -0.0240f, -0.0075f,
- -0.1389f, -0.0520f, -0.0920f, -0.1396f,
- 0.0672f, 0.1392f, 0.0935f, 0.0373f,
- 0.1082f, 0.0185f, 0.1273f, 0.1021f,
- -0.3336f, -0.3825f, -0.6008f, -0.7142f,
- -0.2587f, 0.0157f, -0.1429f, -0.0564f,
- 0.0328f, 0.1196f, -0.0725f, -0.0929f,
- -0.3548f, -0.2175f, -0.2930f, -0.2825f,
- -0.0066f, 0.0587f, -0.4138f, 0.0117f,
- 0.1133f, 0.0211f, -0.0499f, -0.0194f,
- 0.1823f, 0.1128f, 0.0573f, 0.0140f,
- 0.2655f, -0.1803f, 0.2675f, 0.2565f,
- 0.2253f, 0.1513f, -0.1007f, 0.1000f,
- -0.0639f, 0.0086f, 0.0303f, -0.0766f,
- -0.1939f, 0.2057f, -0.2423f, 0.0769f,
- 0.0686f, -0.1137f, 0.2511f, 0.0480f,
- 0.0571f, -0.0847f, 0.0629f, 0.0448f,
- -0.4005f, 0.0596f, -0.0270f, 0.0070f,
- 0.0922f, 0.0418f, -0.0140f, 0.0958f,
- -0.0218f, 0.0900f, 0.0477f, 0.1115f,
- 0.1225f, 0.3240f, 0.0291f, 0.2393f,
- -0.0158f, -0.0206f, -0.1019f, 0.0642f,
- -0.1011f, -0.1364f, -0.1560f, -0.0251f,
- -0.4360f, 0.0958f, -0.4289f, -0.1051f,
- -0.1723f, -0.0732f, -0.2905f, -0.1783f,
- -0.1166f, 0.0848f, -0.0978f, -0.0897f,
- -0.0229f, -0.2016f, -0.0050f, -0.0033f,
- -0.1734f, -0.1320f, 0.0110f, -0.0649f,
- -0.0370f, -0.1189f, 0.0929f, -0.0594f,
- -0.0657f, 0.0080f, 0.1716f, 0.0350f,
- 0.0503f, -0.0355f, -0.0068f, -0.1159f,
- -0.1695f, 0.1897f, 0.0702f, 0.0873f,
-};
-
const Word16 YG_dicHR_4_16kHz_fx[] =
{
//Q12
@@ -19608,29 +17829,12 @@ const Word16 YG_dicHR_4_16kHz_fx[] =
-694, 777, 287, 357,
};
-const float YG_meanL2G_16kHz[] =
-{
- 0.1036f, 0.1590f,
-};
-
const Word16 YG_meanL2G_16kHz_fx[] =
{
//Q12
424, 651,
};
-const float YG_dicL2G_16kHz[] =
-{
- -0.0624f, 0.0298f,
- 0.0723f, 0.0768f,
- -0.0553f, -0.0814f,
- 0.1633f, 0.1633f,
- 0.0249f, -0.0130f,
- -0.1415f, -0.1581f,
- -0.2937f, -0.3039f,
- 0.2962f, 0.3062f,
-};
-
const Word16 YG_dicL2G_16kHz_fx[] =//Q12
{
-255, 122,
@@ -19649,23 +17853,10 @@ const Word16 Odx_fft64[64] =
32,27,22,17,12,7,2,61,56,51,46,41,36,31,26,21,16,11,6,1,60,55,50,45,40,35,30,25,20,15,10,5
}; // Q0
-const float w_fft64[32] =
-{
- 1.0000000f,0.00000000f,0.70710677f,0.70710677f,0.92387950f,0.38268346f,0.38268346f,0.92387950f,
- 0.98078525f,0.19509032f,0.55557024f,0.83146960f,0.83146960f,0.55557024f,0.19509032f,0.98078525f,
- 0.99518472f,0.098017141f,0.63439327f,0.77301043f,0.88192123f,0.47139674f,0.29028469f,0.95694035f,
- 0.95694035f,0.29028469f,0.47139674f,0.88192123f,0.77301043f,0.63439327f,0.098017141f,0.99518472f
-};
-
const Word16 Ip_fft64[6] = { 32,1,0,64,32,96 }; // Q0
const Word16 Odx_fft32_15[32] = { 0,17,2,19,4,21,6,23,8,25,10,27,12,29,14,31,16,1,18,3,20,5,22,7,24,9,26,11,28,13,30,15 }; // Q0
-const float w_fft32[16] =
-{
- 1.0000000f,0.00000000f,0.70710677f,0.70710677f,0.92387950f,0.38268346f,0.38268346f,0.92387950f,
- 0.98078525f,0.19509032f,0.55557024f,0.83146960f,0.83146960f,0.55557024f,0.19509032f,0.98078525f
-};
const Word32 w_fft32_16fx[16] =//Q30
{
1073741824, 0, 759250113, 759250113, 992008059, 410903236, 410903236, 992008059,
@@ -19677,12 +17868,8 @@ const Word16 Odx_fft32_5[32] = { 0,27,22,17,12,7,2,29,24,19,14,9,4,31,26,21,16,1
const Word16 Odx_fft16[16] = {0,11,6,1,12,7,2,13,8,3,14,9,4,15,10,5}; // Q0
-const float w_fft16[8] = { 1.0000000f,0.00000000f,0.70710677f,0.70710677f,0.92387950f,0.38268346f,0.38268346f,0.92387950f };
-
const Word16 Ip_fft16[6] = {8,1,0,16,8,24}; // Q0
-const float w_fft8[8] = {1.0000000f,0.00000000f,0.70710677f,0.70710677f };
-
const Word16 Ip_fft8[6] = {4,1,0,8,4,12}; // Q0
const Word16 Idx_dortft80[80] =
@@ -19753,17 +17940,6 @@ const Word16 Idx_dortft480[480] =
const Word16 Ip_fft128[10] = { 64, 1, 0, 128, 64, 192, 32, 160, 96, 224 }; // Q0
-const float w_fft128[64] =
-{
- 1.0000000f, 0.00000000f, 0.70710677f, 0.70710677f, 0.92387950f, 0.38268346f, 0.38268346f, 0.92387950f,
- 0.98078525f, 0.19509032f, 0.55557024f, 0.83146960f, 0.83146960f, 0.55557024f, 0.19509032f, 0.98078525f,
- 0.99518472f, 0.09801714f, 0.63439327f, 0.77301043f, 0.88192123f, 0.47139674f, 0.29028469f, 0.95694035f,
- 0.95694035f, 0.29028469f, 0.47139674f, 0.88192123f, 0.77301043f, 0.63439327f, 0.09801714f, 0.99518472f,
- 0.99879545f, 0.04906767f, 0.67155895f, 0.74095112f, 0.90398929f, 0.42755509f, 0.33688985f, 0.94154406f,
- 0.97003125f, 0.24298017f, 0.51410274f, 0.85772861f, 0.80320753f, 0.59569930f, 0.14673047f, 0.98917650f,
- 0.98917650f, 0.14673047f, 0.59569930f, 0.80320753f, 0.85772861f, 0.51410274f, 0.24298017f, 0.97003125f,
- 0.94154406f, 0.33688985f, 0.42755509f, 0.90398929f, 0.74095112f, 0.67155895f, 0.04906767f, 0.99879545f
-};
const Word32 w_fft128_16fx[64] =
{
1073741824, 0, 759250112, 759250112, 992008064, 410903232, 410903232, 992008064,
@@ -19778,63 +17954,8 @@ const Word32 w_fft128_16fx[64] =
const Word16 Ip_fft256[10] = {128, 1, 0, 256, 128, 384, 64, 320,192, 448}; // Q0
-const float w_fft256[128] =
-{
- 1.00000000f, 0.00000000f, 0.70710678f, 0.70710678f, 0.92387953f, 0.38268343f, 0.38268343f, 0.92387953f,
- 0.98078528f, 0.19509032f, 0.55557023f, 0.83146961f, 0.83146961f, 0.55557023f, 0.19509032f, 0.98078528f,
- 0.99518473f, 0.09801714f, 0.63439328f, 0.77301045f, 0.88192126f, 0.47139674f, 0.29028468f, 0.95694034f,
- 0.95694034f, 0.29028468f, 0.47139674f, 0.88192126f, 0.77301045f, 0.63439328f, 0.09801714f, 0.99518473f,
- 0.99879546f, 0.04906767f, 0.67155895f, 0.74095113f, 0.90398929f, 0.42755509f, 0.33688985f, 0.94154407f,
- 0.97003125f, 0.24298018f, 0.51410274f, 0.85772861f, 0.80320753f, 0.59569930f, 0.14673047f, 0.98917651f,
- 0.98917651f, 0.14673047f, 0.59569930f, 0.80320753f, 0.85772861f, 0.51410274f, 0.24298018f, 0.97003125f,
- 0.94154407f, 0.33688985f, 0.42755509f, 0.90398929f, 0.74095113f, 0.67155895f, 0.04906767f, 0.99879546f,
- 0.99969882f, 0.02454123f, 0.68954054f, 0.72424708f, 0.91420976f, 0.40524131f, 0.35989504f, 0.93299280f,
- 0.97570213f, 0.21910124f, 0.53499762f, 0.84485357f, 0.81758481f, 0.57580819f, 0.17096189f, 0.98527764f,
- 0.99247953f, 0.12241068f, 0.61523159f, 0.78834643f, 0.87008699f, 0.49289819f, 0.26671276f, 0.96377607f,
- 0.94952818f, 0.31368174f, 0.44961133f, 0.89322430f, 0.75720885f, 0.65317284f, 0.07356456f, 0.99729046f,
- 0.99729046f, 0.07356456f, 0.65317284f, 0.75720885f, 0.89322430f, 0.44961133f, 0.31368174f, 0.94952818f,
- 0.96377607f, 0.26671276f, 0.49289819f, 0.87008699f, 0.78834643f, 0.61523159f, 0.12241068f, 0.99247953f,
- 0.98527764f, 0.17096189f, 0.57580819f, 0.81758481f, 0.84485357f, 0.53499762f, 0.21910124f, 0.97570213f,
- 0.93299280f, 0.35989504f, 0.40524131f, 0.91420976f, 0.72424708f, 0.68954054f, 0.02454123f, 0.99969882f
-};
-
const Word16 Ip_fft512[18] = {256, 1, 0, 512, 256, 768, 128, 640,384, 896, 64, 576, 320, 832, 192, 704,448, 960}; // Q0
-const float w_fft512[256] =
-{
- 1.00000000f, 0.00000000f, 0.70710678f, 0.70710678f, 0.92387953f, 0.38268343f, 0.38268343f, 0.92387953f,
- 0.98078528f, 0.19509032f, 0.55557023f, 0.83146961f, 0.83146961f, 0.55557023f, 0.19509032f, 0.98078528f,
- 0.99518473f, 0.09801714f, 0.63439328f, 0.77301045f, 0.88192126f, 0.47139674f, 0.29028468f, 0.95694034f,
- 0.95694034f, 0.29028468f, 0.47139674f, 0.88192126f, 0.77301045f, 0.63439328f, 0.09801714f, 0.99518473f,
- 0.99879546f, 0.04906767f, 0.67155895f, 0.74095113f, 0.90398929f, 0.42755509f, 0.33688985f, 0.94154407f,
- 0.97003125f, 0.24298018f, 0.51410274f, 0.85772861f, 0.80320753f, 0.59569930f, 0.14673047f, 0.98917651f,
- 0.98917651f, 0.14673047f, 0.59569930f, 0.80320753f, 0.85772861f, 0.51410274f, 0.24298018f, 0.97003125f,
- 0.94154407f, 0.33688985f, 0.42755509f, 0.90398929f, 0.74095113f, 0.67155895f, 0.04906767f, 0.99879546f,
- 0.99969882f, 0.02454123f, 0.68954054f, 0.72424708f, 0.91420976f, 0.40524131f, 0.35989504f, 0.93299280f,
- 0.97570213f, 0.21910124f, 0.53499762f, 0.84485357f, 0.81758481f, 0.57580819f, 0.17096189f, 0.98527764f,
- 0.99247953f, 0.12241068f, 0.61523159f, 0.78834643f, 0.87008699f, 0.49289819f, 0.26671276f, 0.96377607f,
- 0.94952818f, 0.31368174f, 0.44961133f, 0.89322430f, 0.75720885f, 0.65317284f, 0.07356456f, 0.99729046f,
- 0.99729046f, 0.07356456f, 0.65317284f, 0.75720885f, 0.89322430f, 0.44961133f, 0.31368174f, 0.94952818f,
- 0.96377607f, 0.26671276f, 0.49289819f, 0.87008699f, 0.78834643f, 0.61523159f, 0.12241068f, 0.99247953f,
- 0.98527764f, 0.17096189f, 0.57580819f, 0.81758481f, 0.84485357f, 0.53499762f, 0.21910124f, 0.97570213f,
- 0.93299280f, 0.35989504f, 0.40524131f, 0.91420976f, 0.72424708f, 0.68954054f, 0.02454123f, 0.99969882f,
- 0.99992470f, 0.01227154f, 0.69837625f, 0.71573083f, 0.91911385f, 0.39399204f, 0.37131719f, 0.92850608f,
- 0.97831737f, 0.20711138f, 0.54532499f, 0.83822471f, 0.82458930f, 0.56573181f, 0.18303989f, 0.98310549f,
- 0.99390697f, 0.11022221f, 0.62485949f, 0.78073723f, 0.87607009f, 0.48218377f, 0.27851969f, 0.96043052f,
- 0.95330604f, 0.30200595f, 0.46053871f, 0.88763962f, 0.76516727f, 0.64383154f, 0.08579731f, 0.99631261f,
- 0.99811811f, 0.06132074f, 0.66241578f, 0.74913639f, 0.89867447f, 0.43861624f, 0.32531029f, 0.94560733f,
- 0.96697647f, 0.25486566f, 0.50353838f, 0.86397286f, 0.79583690f, 0.60551104f, 0.13458071f, 0.99090264f,
- 0.98730142f, 0.15885814f, 0.58579786f, 0.81045720f, 0.85135519f, 0.52458968f, 0.23105811f, 0.97293995f,
- 0.93733901f, 0.34841868f, 0.41642956f, 0.90916798f, 0.73265427f, 0.68060100f, 0.03680722f, 0.99932238f,
- 0.99932238f, 0.03680722f, 0.68060100f, 0.73265427f, 0.90916798f, 0.41642956f, 0.34841868f, 0.93733901f,
- 0.97293995f, 0.23105811f, 0.52458968f, 0.85135519f, 0.81045720f, 0.58579786f, 0.15885814f, 0.98730142f,
- 0.99090264f, 0.13458071f, 0.60551104f, 0.79583690f, 0.86397286f, 0.50353838f, 0.25486566f, 0.96697647f,
- 0.94560733f, 0.32531029f, 0.43861624f, 0.89867447f, 0.74913639f, 0.66241578f, 0.06132074f, 0.99811811f,
- 0.99631261f, 0.08579731f, 0.64383154f, 0.76516727f, 0.88763962f, 0.46053871f, 0.30200595f, 0.95330604f,
- 0.96043052f, 0.27851969f, 0.48218377f, 0.87607009f, 0.78073723f, 0.62485949f, 0.11022221f, 0.99390697f,
- 0.98310549f, 0.18303989f, 0.56573181f, 0.82458930f, 0.83822471f, 0.54532499f, 0.20711138f, 0.97831737f,
- 0.92850608f, 0.37131719f, 0.39399204f, 0.91911385f, 0.71573083f, 0.69837625f, 0.01227154f, 0.99992470f
-};
const Word16 w_fft512_fx_evs[256] =//Q14
{
16384, 0, 11585, 11585, 15137, 6270, 6270, 15137,
@@ -19879,23 +18000,9 @@ const Word16 Idx_dortft40[40] =
const Word16 Odx_fft8_5[8] = {0, 3, 6, 1, 4, 7, 2, 5}; // Q0
const Word16 Idx_dortft20[20] = {0, 5, 10, 15, 16, 1, 6, 11, 12, 17, 2, 7, 8, 13, 18, 3, 4, 9, 14, 19}; // Q0
const Word16 Odx_fft4_5[4] = {0, 3, 2, 1}; // Q0
-const float w_fft4[2] = {1.0000000f, 0.00000000f};
const Word16 Ip_fft4[6] = {2,1,0,4,2,6}; // Q0
const Word16 ip_edct2_64[6] = {16, 64, 0, 32, 16, 48}; // Q0
-const float w_edct2_64[80] =
-{
- 1.00000000f, 0.00000000f, 0.70710678f, 0.70710678f, 0.92387953f, 0.38268343f, 0.38268343f, 0.92387953f,
- 0.98078528f, 0.19509032f, 0.55557023f, 0.83146961f, 0.83146961f, 0.55557023f, 0.19509032f, 0.98078528f,
- 0.70710678f, 0.49984940f, 0.49939772f, 0.49864522f, 0.49759236f, 0.49623976f, 0.49458825f, 0.49263882f,
- 0.49039264f, 0.48785106f, 0.48501562f, 0.48188803f, 0.47847016f, 0.47476409f, 0.47077203f, 0.46649639f,
- 0.46193976f, 0.45710487f, 0.45199464f, 0.44661215f, 0.44096063f, 0.43504349f, 0.42886430f, 0.42242678f,
- 0.41573480f, 0.40879240f, 0.40160376f, 0.39417321f, 0.38650522f, 0.37860442f, 0.37047556f, 0.36212354f,
- 0.35355339f, 0.34477027f, 0.33577947f, 0.32658642f, 0.31719664f, 0.30761579f, 0.29784965f, 0.28790409f,
- 0.27778511f, 0.26749880f, 0.25705137f, 0.24644909f, 0.23569836f, 0.22480566f, 0.21377754f, 0.20262065f,
- 0.19134171f, 0.17994751f, 0.16844492f, 0.15684087f, 0.14514233f, 0.13335637f, 0.12149008f, 0.10955062f,
- 0.09754516f, 0.08548094f, 0.07336523f, 0.06120533f, 0.04900857f, 0.03678228f, 0.02453383f, 0.01227061f
-};
const Word16 w_edct2_64_fx[80] = /*Q14 */
{
16384, 0, 11585, 11585, 15137, 6270, 6270, 15137,
@@ -19910,712 +18017,6 @@ const Word16 w_edct2_64_fx[80] = /*Q14 */
1598, 1401, 1202, 1003, 803, 603, 402, 201
};
-const float FFT_RotVector_32[40] = {
- 0.9807852507f, -0.1950903237f, 0.9238796234f, -0.3826834261f, 0.8314696550f, -0.5555702448f, 0.7071067691f, -0.7071067691f,
- 0.5555703044f, -0.8314695954f, 0.3826835155f, -0.9238795042f, 0.1950902939f, -0.9807852507f, 0.9238796234f, -0.3826834261f,
- 0.7071067691f, -0.7071067691f, 0.3826835155f, -0.9238795042f, -0.3826833963f, -0.9238795042f, -0.7071067691f, -0.7071067691f,
- -0.9238795042f, -0.3826834261f, 0.8314696550f, -0.5555702448f, 0.3826835155f, -0.9238795042f, -0.1950902939f, -0.9807852507f,
- -0.7071067691f, -0.7071067691f, -0.9807852507f, -0.1950903237f, -0.9238796234f, 0.3826834261f, -0.5555703044f, 0.8314695954f
-};
-
-const float FFT_RotVector_256[448] = {
- 1.0000000000f, -0.0000000000f, 0.9996988177f, -0.0245412290f, 0.9987954497f, -0.0490676761f, 0.9972904325f, -0.0735645667f,
- 0.9951847196f, -0.0980171412f, 0.9924795628f, -0.1224106774f, 0.9891765118f, -0.1467304677f, 0.9852776527f, -0.1709618866f,
- 0.9807852507f, -0.1950903237f, 0.9757021070f, -0.2191012353f, 0.9700312614f, -0.2429801822f, 0.9637760520f, -0.2667127550f,
- 0.9569403529f, -0.2902846634f, 0.9495281577f, -0.3136817515f, 0.9415440559f, -0.3368898630f, 0.9329928160f, -0.3598950505f,
- 0.9238795042f, -0.3826834261f, 0.9142097831f, -0.4052413106f, 0.9039893150f, -0.4275550842f, 0.8932242990f, -0.4496113360f,
- 0.8819212914f, -0.4713967443f, 0.8700869679f, -0.4928981960f, 0.8577286005f, -0.5141027570f, 0.8448535800f, -0.5349976420f,
- 0.8314695954f, -0.5555702448f, 0.8175848126f, -0.5758081675f, 0.8032075167f, -0.5956993103f, 0.7883464098f, -0.6152315736f,
- 0.7730104327f, -0.6343932748f, 0.7572088242f, -0.6531728506f, 0.7409511209f, -0.6715589762f, 0.7242470980f, -0.6895405650f,
- 1.0000000000f, -0.0000000000f, 0.9987954497f, -0.0490676761f, 0.9951847196f, -0.0980171412f, 0.9891765118f, -0.1467304677f,
- 0.9807852507f, -0.1950903237f, 0.9700312614f, -0.2429801822f, 0.9569403529f, -0.2902846634f, 0.9415440559f, -0.3368898630f,
- 0.9238795042f, -0.3826834261f, 0.9039893150f, -0.4275550842f, 0.8819212914f, -0.4713967443f, 0.8577286005f, -0.5141027570f,
- 0.8314695954f, -0.5555702448f, 0.8032075167f, -0.5956993103f, 0.7730104327f, -0.6343932748f, 0.7409511209f, -0.6715589762f,
- 0.7071067691f, -0.7071067691f, 0.6715589762f, -0.7409511209f, 0.6343932748f, -0.7730104327f, 0.5956993103f, -0.8032075167f,
- 0.5555702448f, -0.8314695954f, 0.5141027570f, -0.8577286005f, 0.4713967443f, -0.8819212914f, 0.4275550842f, -0.9039893150f,
- 0.3826834261f, -0.9238795042f, 0.3368898630f, -0.9415440559f, 0.2902846634f, -0.9569403529f, 0.2429801822f, -0.9700312614f,
- 0.1950903237f, -0.9807852507f, 0.1467304677f, -0.9891765118f, 0.0980171412f, -0.9951847196f, 0.0490676761f, -0.9987954497f,
- 1.0000000000f, -0.0000000000f, 0.9972904325f, -0.0735645667f, 0.9891765118f, -0.1467304677f, 0.9757021070f, -0.2191012353f,
- 0.9569403529f, -0.2902846634f, 0.9329928160f, -0.3598950505f, 0.9039893150f, -0.4275550842f, 0.8700869679f, -0.4928981960f,
- 0.8314695954f, -0.5555702448f, 0.7883464098f, -0.6152315736f, 0.7409511209f, -0.6715589762f, 0.6895405650f, -0.7242470980f,
- 0.6343932748f, -0.7730104327f, 0.5758081675f, -0.8175848126f, 0.5141027570f, -0.8577286005f, 0.4496113360f, -0.8932242990f,
- 0.3826834261f, -0.9238795042f, 0.3136817515f, -0.9495281577f, 0.2429801822f, -0.9700312614f, 0.1709618866f, -0.9852776527f,
- 0.0980171412f, -0.9951847196f, 0.0245412290f, -0.9996988177f, -0.0490676761f, -0.9987954497f, -0.1224106774f, -0.9924795628f,
- -0.1950903237f, -0.9807852507f, -0.2667127550f, -0.9637760520f, -0.3368898630f, -0.9415440559f, -0.4052413106f, -0.9142097831f,
- -0.4713967443f, -0.8819212914f, -0.5349976420f, -0.8448535800f, -0.5956993103f, -0.8032075167f, -0.6531728506f, -0.7572088242f,
- 1.0000000000f, -0.0000000000f, 0.9951847196f, -0.0980171412f, 0.9807852507f, -0.1950903237f, 0.9569403529f, -0.2902846634f,
- 0.9238795042f, -0.3826834261f, 0.8819212914f, -0.4713967443f, 0.8314695954f, -0.5555702448f, 0.7730104327f, -0.6343932748f,
- 0.7071067691f, -0.7071067691f, 0.6343932748f, -0.7730104327f, 0.5555702448f, -0.8314695954f, 0.4713967443f, -0.8819212914f,
- 0.3826834261f, -0.9238795042f, 0.2902846634f, -0.9569403529f, 0.1950903237f, -0.9807852507f, 0.0980171412f, -0.9951847196f,
- -0.0000000000f, -1.0000000000f, -0.0980171412f, -0.9951847196f, -0.1950903237f, -0.9807852507f, -0.2902846634f, -0.9569403529f,
- -0.3826834261f, -0.9238795042f, -0.4713967443f, -0.8819212914f, -0.5555702448f, -0.8314695954f, -0.6343932748f, -0.7730104327f,
- -0.7071067691f, -0.7071067691f, -0.7730104327f, -0.6343932748f, -0.8314695954f, -0.5555702448f, -0.8819212914f, -0.4713967443f,
- -0.9238795042f, -0.3826834261f, -0.9569403529f, -0.2902846634f, -0.9807852507f, -0.1950903237f, -0.9951847196f, -0.0980171412f,
- 1.0000000000f, -0.0000000000f, 0.9924795628f, -0.1224106774f, 0.9700312614f, -0.2429801822f, 0.9329928160f, -0.3598950505f,
- 0.8819212914f, -0.4713967443f, 0.8175848126f, -0.5758081675f, 0.7409511209f, -0.6715589762f, 0.6531728506f, -0.7572088242f,
- 0.5555702448f, -0.8314695954f, 0.4496113360f, -0.8932242990f, 0.3368898630f, -0.9415440559f, 0.2191012353f, -0.9757021070f,
- 0.0980171412f, -0.9951847196f, -0.0245412290f, -0.9996988177f, -0.1467304677f, -0.9891765118f, -0.2667127550f, -0.9637760520f,
- -0.3826834261f, -0.9238795042f, -0.4928981960f, -0.8700869679f, -0.5956993103f, -0.8032075167f, -0.6895405650f, -0.7242470980f,
- -0.7730104327f, -0.6343932748f, -0.8448535800f, -0.5349976420f, -0.9039893150f, -0.4275550842f, -0.9495281577f, -0.3136817515f,
- -0.9807852507f, -0.1950903237f, -0.9972904325f, -0.0735645667f, -0.9987954497f, 0.0490676761f, -0.9852776527f, 0.1709618866f,
- -0.9569403529f, 0.2902846634f, -0.9142097831f, 0.4052413106f, -0.8577286005f, 0.5141027570f, -0.7883464098f, 0.6152315736f,
- 1.0000000000f, -0.0000000000f, 0.9891765118f, -0.1467304677f, 0.9569403529f, -0.2902846634f, 0.9039893150f, -0.4275550842f,
- 0.8314695954f, -0.5555702448f, 0.7409511209f, -0.6715589762f, 0.6343932748f, -0.7730104327f, 0.5141027570f, -0.8577286005f,
- 0.3826834261f, -0.9238795042f, 0.2429801822f, -0.9700312614f, 0.0980171412f, -0.9951847196f, -0.0490676761f, -0.9987954497f,
- -0.1950903237f, -0.9807852507f, -0.3368898630f, -0.9415440559f, -0.4713967443f, -0.8819212914f, -0.5956993103f, -0.8032075167f,
- -0.7071067691f, -0.7071067691f, -0.8032075167f, -0.5956993103f, -0.8819212914f, -0.4713967443f, -0.9415440559f, -0.3368898630f,
- -0.9807852507f, -0.1950903237f, -0.9987954497f, -0.0490676761f, -0.9951847196f, 0.0980171412f, -0.9700312614f, 0.2429801822f,
- -0.9238795042f, 0.3826834261f, -0.8577286005f, 0.5141027570f, -0.7730104327f, 0.6343932748f, -0.6715589762f, 0.7409511209f,
- -0.5555702448f, 0.8314695954f, -0.4275550842f, 0.9039893150f, -0.2902846634f, 0.9569403529f, -0.1467304677f, 0.9891765118f,
- 1.0000000000f, -0.0000000000f, 0.9852776527f, -0.1709618866f, 0.9415440559f, -0.3368898630f, 0.8700869679f, -0.4928981960f,
- 0.7730104327f, -0.6343932748f, 0.6531728506f, -0.7572088242f, 0.5141027570f, -0.8577286005f, 0.3598950505f, -0.9329928160f,
- 0.1950903237f, -0.9807852507f, 0.0245412290f, -0.9996988177f, -0.1467304677f, -0.9891765118f, -0.3136817515f, -0.9495281577f,
- -0.4713967443f, -0.8819212914f, -0.6152315736f, -0.7883464098f, -0.7409511209f, -0.6715589762f, -0.8448535800f, -0.5349976420f,
- -0.9238795042f, -0.3826834261f, -0.9757021070f, -0.2191012353f, -0.9987954497f, -0.0490676761f, -0.9924795628f, 0.1224106774f,
- -0.9569403529f, 0.2902846634f, -0.8932242990f, 0.4496113360f, -0.8032075167f, 0.5956993103f, -0.6895405650f, 0.7242470980f,
- -0.5555702448f, 0.8314695954f, -0.4052413106f, 0.9142097831f, -0.2429801822f, 0.9700312614f, -0.0735645667f, 0.9972904325f,
- 0.0980171412f, 0.9951847196f, 0.2667127550f, 0.9637760520f, 0.4275550842f, 0.9039893150f, 0.5758081675f, 0.8175848126f
-};
-
-const float FFT_RotVector_400[760] = {
- 1.0000000000f, -0.0000000000f, 0.9995065331f, -0.0314107575f, 0.9980267286f, -0.0627905205f, 0.9955619574f, -0.0941083133f,
- 0.9921147227f, -0.1253332347f, 0.9876883626f, -0.1564344615f, 0.9822872281f, -0.1873813123f, 0.9759167433f, -0.2181432396f,
- 0.9685831666f, -0.2486898899f, 0.9602937102f, -0.2789911032f, 0.9510565400f, -0.3090170026f, 0.9408807755f, -0.3387379348f,
- 0.9297764897f, -0.3681245446f, 0.9177546501f, -0.3971478939f, 0.9048270583f, -0.4257792830f, 0.8910065293f, -0.4539904892f,
- 0.8763066530f, -0.4817536771f, 0.8607420325f, -0.5090414286f, 0.8443279266f, -0.5358268023f, 0.8270805478f, -0.5620833635f,
- 1.0000000000f, -0.0000000000f, 0.9980267286f, -0.0627905205f, 0.9921147227f, -0.1253332347f, 0.9822872281f, -0.1873813123f,
- 0.9685831666f, -0.2486898899f, 0.9510565400f, -0.3090170026f, 0.9297764897f, -0.3681245446f, 0.9048270583f, -0.4257792830f,
- 0.8763066530f, -0.4817536771f, 0.8443279266f, -0.5358268023f, 0.8090170026f, -0.5877852440f, 0.7705132365f, -0.6374239922f,
- 0.7289686203f, -0.6845471263f, 0.6845471263f, -0.7289686203f, 0.6374239922f, -0.7705132365f, 0.5877852440f, -0.8090170026f,
- 0.5358268023f, -0.8443279266f, 0.4817536771f, -0.8763066530f, 0.4257792830f, -0.9048270583f, 0.3681245446f, -0.9297764897f,
- 1.0000000000f, -0.0000000000f, 0.9955619574f, -0.0941083133f, 0.9822872281f, -0.1873813123f, 0.9602937102f, -0.2789911032f,
- 0.9297764897f, -0.3681245446f, 0.8910065293f, -0.4539904892f, 0.8443279266f, -0.5358268023f, 0.7901549935f, -0.6129070520f,
- 0.7289686203f, -0.6845471263f, 0.6613118649f, -0.7501110435f, 0.5877852440f, -0.8090170026f, 0.5090414286f, -0.8607420325f,
- 0.4257792830f, -0.9048270583f, 0.3387379348f, -0.9408807755f, 0.2486898899f, -0.9685831666f, 0.1564344615f, -0.9876883626f,
- 0.0627905205f, -0.9980267286f, -0.0314107575f, -0.9995065331f, -0.1253332347f, -0.9921147227f, -0.2181432396f, -0.9759167433f,
- 1.0000000000f, -0.0000000000f, 0.9921147227f, -0.1253332347f, 0.9685831666f, -0.2486898899f, 0.9297764897f, -0.3681245446f,
- 0.8763066530f, -0.4817536771f, 0.8090170026f, -0.5877852440f, 0.7289686203f, -0.6845471263f, 0.6374239922f, -0.7705132365f,
- 0.5358268023f, -0.8443279266f, 0.4257792830f, -0.9048270583f, 0.3090170026f, -0.9510565400f, 0.1873813123f, -0.9822872281f,
- 0.0627905205f, -0.9980267286f, -0.0627905205f, -0.9980267286f, -0.1873813123f, -0.9822872281f, -0.3090170026f, -0.9510565400f,
- -0.4257792830f, -0.9048270583f, -0.5358268023f, -0.8443279266f, -0.6374239922f, -0.7705132365f, -0.7289686203f, -0.6845471263f,
- 1.0000000000f, -0.0000000000f, 0.9876883626f, -0.1564344615f, 0.9510565400f, -0.3090170026f, 0.8910065293f, -0.4539904892f,
- 0.8090170026f, -0.5877852440f, 0.7071067691f, -0.7071067691f, 0.5877852440f, -0.8090170026f, 0.4539904892f, -0.8910065293f,
- 0.3090170026f, -0.9510565400f, 0.1564344615f, -0.9876883626f, -0.0000000000f, -1.0000000000f, -0.1564344615f, -0.9876883626f,
- -0.3090170026f, -0.9510565400f, -0.4539904892f, -0.8910065293f, -0.5877852440f, -0.8090170026f, -0.7071067691f, -0.7071067691f,
- -0.8090170026f, -0.5877852440f, -0.8910065293f, -0.4539904892f, -0.9510565400f, -0.3090170026f, -0.9876883626f, -0.1564344615f,
- 1.0000000000f, -0.0000000000f, 0.9822872281f, -0.1873813123f, 0.9297764897f, -0.3681245446f, 0.8443279266f, -0.5358268023f,
- 0.7289686203f, -0.6845471263f, 0.5877852440f, -0.8090170026f, 0.4257792830f, -0.9048270583f, 0.2486898899f, -0.9685831666f,
- 0.0627905205f, -0.9980267286f, -0.1253332347f, -0.9921147227f, -0.3090170026f, -0.9510565400f, -0.4817536771f, -0.8763066530f,
- -0.6374239922f, -0.7705132365f, -0.7705132365f, -0.6374239922f, -0.8763066530f, -0.4817536771f, -0.9510565400f, -0.3090170026f,
- -0.9921147227f, -0.1253332347f, -0.9980267286f, 0.0627905205f, -0.9685831666f, 0.2486898899f, -0.9048270583f, 0.4257792830f,
- 1.0000000000f, -0.0000000000f, 0.9759167433f, -0.2181432396f, 0.9048270583f, -0.4257792830f, 0.7901549935f, -0.6129070520f,
- 0.6374239922f, -0.7705132365f, 0.4539904892f, -0.8910065293f, 0.2486898899f, -0.9685831666f, 0.0314107575f, -0.9995065331f,
- -0.1873813123f, -0.9822872281f, -0.3971478939f, -0.9177546501f, -0.5877852440f, -0.8090170026f, -0.7501110435f, -0.6613118649f,
- -0.8763066530f, -0.4817536771f, -0.9602937102f, -0.2789911032f, -0.9980267286f, -0.0627905205f, -0.9876883626f, 0.1564344615f,
- -0.9297764897f, 0.3681245446f, -0.8270805478f, 0.5620833635f, -0.6845471263f, 0.7289686203f, -0.5090414286f, 0.8607420325f,
- 1.0000000000f, -0.0000000000f, 0.9685831666f, -0.2486898899f, 0.8763066530f, -0.4817536771f, 0.7289686203f, -0.6845471263f,
- 0.5358268023f, -0.8443279266f, 0.3090170026f, -0.9510565400f, 0.0627905205f, -0.9980267286f, -0.1873813123f, -0.9822872281f,
- -0.4257792830f, -0.9048270583f, -0.6374239922f, -0.7705132365f, -0.8090170026f, -0.5877852440f, -0.9297764897f, -0.3681245446f,
- -0.9921147227f, -0.1253332347f, -0.9921147227f, 0.1253332347f, -0.9297764897f, 0.3681245446f, -0.8090170026f, 0.5877852440f,
- -0.6374239922f, 0.7705132365f, -0.4257792830f, 0.9048270583f, -0.1873813123f, 0.9822872281f, 0.0627905205f, 0.9980267286f,
- 1.0000000000f, -0.0000000000f, 0.9602937102f, -0.2789911032f, 0.8443279266f, -0.5358268023f, 0.6613118649f, -0.7501110435f,
- 0.4257792830f, -0.9048270583f, 0.1564344615f, -0.9876883626f, -0.1253332347f, -0.9921147227f, -0.3971478939f, -0.9177546501f,
- -0.6374239922f, -0.7705132365f, -0.8270805478f, -0.5620833635f, -0.9510565400f, -0.3090170026f, -0.9995065331f, -0.0314107575f,
- -0.9685831666f, 0.2486898899f, -0.8607420325f, 0.5090414286f, -0.6845471263f, 0.7289686203f, -0.4539904892f, 0.8910065293f,
- -0.1873813123f, 0.9822872281f, 0.0941083133f, 0.9955619574f, 0.3681245446f, 0.9297764897f, 0.6129070520f, 0.7901549935f,
- 1.0000000000f, -0.0000000000f, 0.9998766184f, -0.0157073177f, 0.9995065331f, -0.0314107575f, 0.9988898635f, -0.0471064523f,
- 0.9980267286f, -0.0627905205f, 0.9969173074f, -0.0784590989f, 0.9955619574f, -0.0941083133f, 0.9939609766f, -0.1097343117f,
- 0.9921147227f, -0.1253332347f, 0.9900236726f, -0.1409012377f, 0.9876883626f, -0.1564344615f, 0.9851093292f, -0.1719291061f,
- 0.9822872281f, -0.1873813123f, 0.9792228341f, -0.2027872950f, 0.9759167433f, -0.2181432396f, 0.9723699093f, -0.2334453613f,
- 0.9685831666f, -0.2486898899f, 0.9645574093f, -0.2638730407f, 0.9602937102f, -0.2789911032f, 0.9557930231f, -0.2940403223f,
- 1.0000000000f, -0.0000000000f, 0.9988898635f, -0.0471064523f, 0.9955619574f, -0.0941083133f, 0.9900236726f, -0.1409012377f,
- 0.9822872281f, -0.1873813123f, 0.9723699093f, -0.2334453613f, 0.9602937102f, -0.2789911032f, 0.9460853338f, -0.3239174187f,
- 0.9297764897f, -0.3681245446f, 0.9114032984f, -0.4115143716f, 0.8910065293f, -0.4539904892f, 0.8686315417f, -0.4954586625f,
- 0.8443279266f, -0.5358268023f, 0.8181497455f, -0.5750052333f, 0.7901549935f, -0.6129070520f, 0.7604059577f, -0.6494480371f,
- 0.7289686203f, -0.6845471263f, 0.6959127784f, -0.7181262970f, 0.6613118649f, -0.7501110435f, 0.6252426505f, -0.7804304361f,
- 1.0000000000f, -0.0000000000f, 0.9969173074f, -0.0784590989f, 0.9876883626f, -0.1564344615f, 0.9723699093f, -0.2334453613f,
- 0.9510565400f, -0.3090170026f, 0.9238795042f, -0.3826834261f, 0.8910065293f, -0.4539904892f, 0.8526401520f, -0.5224985480f,
- 0.8090170026f, -0.5877852440f, 0.7604059577f, -0.6494480371f, 0.7071067691f, -0.7071067691f, 0.6494480371f, -0.7604059577f,
- 0.5877852440f, -0.8090170026f, 0.5224985480f, -0.8526401520f, 0.4539904892f, -0.8910065293f, 0.3826834261f, -0.9238795042f,
- 0.3090170026f, -0.9510565400f, 0.2334453613f, -0.9723699093f, 0.1564344615f, -0.9876883626f, 0.0784590989f, -0.9969173074f,
- 1.0000000000f, -0.0000000000f, 0.9939609766f, -0.1097343117f, 0.9759167433f, -0.2181432396f, 0.9460853338f, -0.3239174187f,
- 0.9048270583f, -0.4257792830f, 0.8526401520f, -0.5224985480f, 0.7901549935f, -0.6129070520f, 0.7181262970f, -0.6959127784f,
- 0.6374239922f, -0.7705132365f, 0.5490227938f, -0.8358073831f, 0.4539904892f, -0.8910065293f, 0.3534748554f, -0.9354440570f,
- 0.2486898899f, -0.9685831666f, 0.1409012377f, -0.9900236726f, 0.0314107575f, -0.9995065331f, -0.0784590989f, -0.9969173074f,
- -0.1873813123f, -0.9822872281f, -0.2940403223f, -0.9557930231f, -0.3971478939f, -0.9177546501f, -0.4954586625f, -0.8686315417f,
- 1.0000000000f, -0.0000000000f, 0.9900236726f, -0.1409012377f, 0.9602937102f, -0.2789911032f, 0.9114032984f, -0.4115143716f,
- 0.8443279266f, -0.5358268023f, 0.7604059577f, -0.6494480371f, 0.6613118649f, -0.7501110435f, 0.5490227938f, -0.8358073831f,
- 0.4257792830f, -0.9048270583f, 0.2940403223f, -0.9557930231f, 0.1564344615f, -0.9876883626f, 0.0157073177f, -0.9998766184f,
- -0.1253332347f, -0.9921147227f, -0.2638730407f, -0.9645574093f, -0.3971478939f, -0.9177546501f, -0.5224985480f, -0.8526401520f,
- -0.6374239922f, -0.7705132365f, -0.7396311164f, -0.6730124950f, -0.8270805478f, -0.5620833635f, -0.8980275989f, -0.4399391711f,
- 1.0000000000f, -0.0000000000f, 0.9851093292f, -0.1719291061f, 0.9408807755f, -0.3387379348f, 0.8686315417f, -0.4954586625f,
- 0.7705132365f, -0.6374239922f, 0.6494480371f, -0.7604059577f, 0.5090414286f, -0.8607420325f, 0.3534748554f, -0.9354440570f,
- 0.1873813123f, -0.9822872281f, 0.0157073177f, -0.9998766184f, -0.1564344615f, -0.9876883626f, -0.3239174187f, -0.9460853338f,
- -0.4817536771f, -0.8763066530f, -0.6252426505f, -0.7804304361f, -0.7501110435f, -0.6613118649f, -0.8526401520f, -0.5224985480f,
- -0.9297764897f, -0.3681245446f, -0.9792228341f, -0.2027872950f, -0.9995065331f, -0.0314107575f, -0.9900236726f, 0.1409012377f,
- 1.0000000000f, -0.0000000000f, 0.9792228341f, -0.2027872950f, 0.9177546501f, -0.3971478939f, 0.8181497455f, -0.5750052333f,
- 0.6845471263f, -0.7289686203f, 0.5224985480f, -0.8526401520f, 0.3387379348f, -0.9408807755f, 0.1409012377f, -0.9900236726f,
- -0.0627905205f, -0.9980267286f, -0.2638730407f, -0.9645574093f, -0.4539904892f, -0.8910065293f, -0.6252426505f, -0.7804304361f,
- -0.7705132365f, -0.6374239922f, -0.8837656379f, -0.4679298103f, -0.9602937102f, -0.2789911032f, -0.9969173074f, -0.0784590989f,
- -0.9921147227f, 0.1253332347f, -0.9460853338f, 0.3239174187f, -0.8607420325f, 0.5090414286f, -0.7396311164f, 0.6730124950f,
- 1.0000000000f, -0.0000000000f, 0.9723699093f, -0.2334453613f, 0.8910065293f, -0.4539904892f, 0.7604059577f, -0.6494480371f,
- 0.5877852440f, -0.8090170026f, 0.3826834261f, -0.9238795042f, 0.1564344615f, -0.9876883626f, -0.0784590989f, -0.9969173074f,
- -0.3090170026f, -0.9510565400f, -0.5224985480f, -0.8526401520f, -0.7071067691f, -0.7071067691f, -0.8526401520f, -0.5224985480f,
- -0.9510565400f, -0.3090170026f, -0.9969173074f, -0.0784590989f, -0.9876883626f, 0.1564344615f, -0.9238795042f, 0.3826834261f,
- -0.8090170026f, 0.5877852440f, -0.6494480371f, 0.7604059577f, -0.4539904892f, 0.8910065293f, -0.2334453613f, 0.9723699093f,
- 1.0000000000f, -0.0000000000f, 0.9645574093f, -0.2638730407f, 0.8607420325f, -0.5090414286f, 0.6959127784f, -0.7181262970f,
- 0.4817536771f, -0.8763066530f, 0.2334453613f, -0.9723699093f, -0.0314107575f, -0.9995065331f, -0.2940403223f, -0.9557930231f,
- -0.5358268023f, -0.8443279266f, -0.7396311164f, -0.6730124950f, -0.8910065293f, -0.4539904892f, -0.9792228341f, -0.2027872950f,
- -0.9980267286f, 0.0627905205f, -0.9460853338f, 0.3239174187f, -0.8270805478f, 0.5620833635f, -0.6494480371f, 0.7604059577f,
- -0.4257792830f, 0.9048270583f, -0.1719291061f, 0.9851093292f, 0.0941083133f, 0.9955619574f, 0.3534748554f, 0.9354440570f,
- 1.0000000000f, -0.0000000000f, 0.9557930231f, -0.2940403223f, 0.8270805478f, -0.5620833635f, 0.6252426505f, -0.7804304361f,
- 0.3681245446f, -0.9297764897f, 0.0784590989f, -0.9969173074f, -0.2181432396f, -0.9759167433f, -0.4954586625f, -0.8686315417f,
- -0.7289686203f, -0.6845471263f, -0.8980275989f, -0.4399391711f, -0.9876883626f, -0.1564344615f, -0.9900236726f, 0.1409012377f,
- -0.9048270583f, 0.4257792830f, -0.7396311164f, 0.6730124950f, -0.5090414286f, 0.8607420325f, -0.2334453613f, 0.9723699093f,
- 0.0627905205f, 0.9980267286f, 0.3534748554f, 0.9354440570f, 0.6129070520f, 0.7901549935f, 0.8181497455f, 0.5750052333f
-};
-
-const float FFT_RotVector_600[1140] = {
- 1.0000000000f, -0.0000000000f, 0.9997806549f, -0.0209424198f,
- 0.9991228580f, -0.0418756530f, 0.9980267286f, -0.0627905205f, 0.9964928627f, -0.0836778432f, 0.9945219159f, -0.1045284644f,
- 0.9921147227f, -0.1253332347f, 0.9892723560f, -0.1460830271f, 0.9859960079f, -0.1667687446f, 0.9822872281f, -0.1873813123f,
- 0.9781476259f, -0.2079116851f, 0.9735789299f, -0.2283508629f, 0.9685831666f, -0.2486898899f, 0.9631625414f, -0.2689198256f,
- 0.9573194981f, -0.2890318036f, 0.9510565400f, -0.3090170026f, 0.9443763494f, -0.3288666606f, 0.9372819662f, -0.3485720456f,
- 0.9297764897f, -0.3681245446f, 0.9218631387f, -0.3875155747f, 0.9135454297f, -0.4067366421f, 0.9048270583f, -0.4257792830f,
- 0.8957117796f, -0.4446351826f, 0.8862035871f, -0.4632960260f, 0.8763066530f, -0.4817536771f, 0.8660253882f, -0.5000000000f,
- 0.8553642631f, -0.5180270076f, 0.8443279266f, -0.5358268023f, 0.8329212666f, -0.5533915758f, 0.8211492300f, -0.5707135797f,
- 1.0000000000f, -0.0000000000f, 0.9991228580f, -0.0418756530f, 0.9964928627f, -0.0836778432f, 0.9921147227f, -0.1253332347f,
- 0.9859960079f, -0.1667687446f, 0.9781476259f, -0.2079116851f, 0.9685831666f, -0.2486898899f, 0.9573194981f, -0.2890318036f,
- 0.9443763494f, -0.3288666606f, 0.9297764897f, -0.3681245446f, 0.9135454297f, -0.4067366421f, 0.8957117796f, -0.4446351826f,
- 0.8763066530f, -0.4817536771f, 0.8553642631f, -0.5180270076f, 0.8329212666f, -0.5533915758f, 0.8090170026f, -0.5877852440f,
- 0.7836934328f, -0.6211477518f, 0.7569950819f, -0.6534206271f, 0.7289686203f, -0.6845471263f, 0.6996633410f, -0.7144726515f,
- 0.6691306233f, -0.7431448102f, 0.6374239922f, -0.7705132365f, 0.6045991182f, -0.7965298891f, 0.5707135797f, -0.8211492300f,
- 0.5358268023f, -0.8443279266f, 0.5000000000f, -0.8660253882f, 0.4632960260f, -0.8862035871f, 0.4257792830f, -0.9048270583f,
- 0.3875155747f, -0.9218631387f, 0.3485720456f, -0.9372819662f, 1.0000000000f, -0.0000000000f, 0.9980267286f, -0.0627905205f,
- 0.9921147227f, -0.1253332347f, 0.9822872281f, -0.1873813123f, 0.9685831666f, -0.2486898899f, 0.9510565400f, -0.3090170026f,
- 0.9297764897f, -0.3681245446f, 0.9048270583f, -0.4257792830f, 0.8763066530f, -0.4817536771f, 0.8443279266f, -0.5358268023f,
- 0.8090170026f, -0.5877852440f, 0.7705132365f, -0.6374239922f, 0.7289686203f, -0.6845471263f, 0.6845471263f, -0.7289686203f,
- 0.6374239922f, -0.7705132365f, 0.5877852440f, -0.8090170026f, 0.5358268023f, -0.8443279266f, 0.4817536771f, -0.8763066530f,
- 0.4257792830f, -0.9048270583f, 0.3681245446f, -0.9297764897f, 0.3090170026f, -0.9510565400f, 0.2486898899f, -0.9685831666f,
- 0.1873813123f, -0.9822872281f, 0.1253332347f, -0.9921147227f, 0.0627905205f, -0.9980267286f, -0.0000000000f, -1.0000000000f,
- -0.0627905205f, -0.9980267286f, -0.1253332347f, -0.9921147227f, -0.1873813123f, -0.9822872281f, -0.2486898899f, -0.9685831666f,
- 1.0000000000f, -0.0000000000f, 0.9964928627f, -0.0836778432f, 0.9859960079f, -0.1667687446f, 0.9685831666f, -0.2486898899f,
- 0.9443763494f, -0.3288666606f, 0.9135454297f, -0.4067366421f, 0.8763066530f, -0.4817536771f, 0.8329212666f, -0.5533915758f,
- 0.7836934328f, -0.6211477518f, 0.7289686203f, -0.6845471263f, 0.6691306233f, -0.7431448102f, 0.6045991182f, -0.7965298891f,
- 0.5358268023f, -0.8443279266f, 0.4632960260f, -0.8862035871f, 0.3875155747f, -0.9218631387f, 0.3090170026f, -0.9510565400f,
- 0.2283508629f, -0.9735789299f, 0.1460830271f, -0.9892723560f, 0.0627905205f, -0.9980267286f, -0.0209424198f, -0.9997806549f,
- -0.1045284644f, -0.9945219159f, -0.1873813123f, -0.9822872281f, -0.2689198256f, -0.9631625414f, -0.3485720456f, -0.9372819662f,
- -0.4257792830f, -0.9048270583f, -0.5000000000f, -0.8660253882f, -0.5707135797f, -0.8211492300f, -0.6374239922f, -0.7705132365f,
- -0.6996633410f, -0.7144726515f, -0.7569950819f, -0.6534206271f, 1.0000000000f, -0.0000000000f, 0.9945219159f, -0.1045284644f,
- 0.9781476259f, -0.2079116851f, 0.9510565400f, -0.3090170026f, 0.9135454297f, -0.4067366421f, 0.8660253882f, -0.5000000000f,
- 0.8090170026f, -0.5877852440f, 0.7431448102f, -0.6691306233f, 0.6691306233f, -0.7431448102f, 0.5877852440f, -0.8090170026f,
- 0.5000000000f, -0.8660253882f, 0.4067366421f, -0.9135454297f, 0.3090170026f, -0.9510565400f, 0.2079116851f, -0.9781476259f,
- 0.1045284644f, -0.9945219159f, -0.0000000000f, -1.0000000000f, -0.1045284644f, -0.9945219159f, -0.2079116851f, -0.9781476259f,
- -0.3090170026f, -0.9510565400f, -0.4067366421f, -0.9135454297f, -0.5000000000f, -0.8660253882f, -0.5877852440f, -0.8090170026f,
- -0.6691306233f, -0.7431448102f, -0.7431448102f, -0.6691306233f, -0.8090170026f, -0.5877852440f, -0.8660253882f, -0.5000000000f,
- -0.9135454297f, -0.4067366421f, -0.9510565400f, -0.3090170026f, -0.9781476259f, -0.2079116851f, -0.9945219159f, -0.1045284644f,
- 1.0000000000f, -0.0000000000f, 0.9921147227f, -0.1253332347f, 0.9685831666f, -0.2486898899f, 0.9297764897f, -0.3681245446f,
- 0.8763066530f, -0.4817536771f, 0.8090170026f, -0.5877852440f, 0.7289686203f, -0.6845471263f, 0.6374239922f, -0.7705132365f,
- 0.5358268023f, -0.8443279266f, 0.4257792830f, -0.9048270583f, 0.3090170026f, -0.9510565400f, 0.1873813123f, -0.9822872281f,
- 0.0627905205f, -0.9980267286f, -0.0627905205f, -0.9980267286f, -0.1873813123f, -0.9822872281f, -0.3090170026f, -0.9510565400f,
- -0.4257792830f, -0.9048270583f, -0.5358268023f, -0.8443279266f, -0.6374239922f, -0.7705132365f, -0.7289686203f, -0.6845471263f,
- -0.8090170026f, -0.5877852440f, -0.8763066530f, -0.4817536771f, -0.9297764897f, -0.3681245446f, -0.9685831666f, -0.2486898899f,
- -0.9921147227f, -0.1253332347f, -1.0000000000f, 0.0000000000f, -0.9921147227f, 0.1253332347f, -0.9685831666f, 0.2486898899f,
- -0.9297764897f, 0.3681245446f, -0.8763066530f, 0.4817536771f, 1.0000000000f, -0.0000000000f, 0.9892723560f, -0.1460830271f,
- 0.9573194981f, -0.2890318036f, 0.9048270583f, -0.4257792830f, 0.8329212666f, -0.5533915758f, 0.7431448102f, -0.6691306233f,
- 0.6374239922f, -0.7705132365f, 0.5180270076f, -0.8553642631f, 0.3875155747f, -0.9218631387f, 0.2486898899f, -0.9685831666f,
- 0.1045284644f, -0.9945219159f, -0.0418756530f, -0.9991228580f, -0.1873813123f, -0.9822872281f, -0.3288666606f, -0.9443763494f,
- -0.4632960260f, -0.8862035871f, -0.5877852440f, -0.8090170026f, -0.6996633410f, -0.7144726515f, -0.7965298891f, -0.6045991182f,
- -0.8763066530f, -0.4817536771f, -0.9372819662f, -0.3485720456f, -0.9781476259f, -0.2079116851f, -0.9980267286f, -0.0627905205f,
- -0.9964928627f, 0.0836778432f, -0.9735789299f, 0.2283508629f, -0.9297764897f, 0.3681245446f, -0.8660253882f, 0.5000000000f,
- -0.7836934328f, 0.6211477518f, -0.6845471263f, 0.7289686203f, -0.5707135797f, 0.8211492300f, -0.4446351826f, 0.8957117796f,
- 1.0000000000f, -0.0000000000f, 0.9859960079f, -0.1667687446f, 0.9443763494f, -0.3288666606f, 0.8763066530f, -0.4817536771f,
- 0.7836934328f, -0.6211477518f, 0.6691306233f, -0.7431448102f, 0.5358268023f, -0.8443279266f, 0.3875155747f, -0.9218631387f,
- 0.2283508629f, -0.9735789299f, 0.0627905205f, -0.9980267286f, -0.1045284644f, -0.9945219159f, -0.2689198256f, -0.9631625414f,
- -0.4257792830f, -0.9048270583f, -0.5707135797f, -0.8211492300f, -0.6996633410f, -0.7144726515f, -0.8090170026f, -0.5877852440f,
- -0.8957117796f, -0.4446351826f, -0.9573194981f, -0.2890318036f, -0.9921147227f, -0.1253332347f, -0.9991228580f, 0.0418756530f,
- -0.9781476259f, 0.2079116851f, -0.9297764897f, 0.3681245446f, -0.8553642631f, 0.5180270076f, -0.7569950819f, 0.6534206271f,
- -0.6374239922f, 0.7705132365f, -0.5000000000f, 0.8660253882f, -0.3485720456f, 0.9372819662f, -0.1873813123f, 0.9822872281f,
- -0.0209424198f, 0.9997806549f, 0.1460830271f, 0.9892723560f, 1.0000000000f, -0.0000000000f, 0.9822872281f, -0.1873813123f,
- 0.9297764897f, -0.3681245446f, 0.8443279266f, -0.5358268023f, 0.7289686203f, -0.6845471263f, 0.5877852440f, -0.8090170026f,
- 0.4257792830f, -0.9048270583f, 0.2486898899f, -0.9685831666f, 0.0627905205f, -0.9980267286f, -0.1253332347f, -0.9921147227f,
- -0.3090170026f, -0.9510565400f, -0.4817536771f, -0.8763066530f, -0.6374239922f, -0.7705132365f, -0.7705132365f, -0.6374239922f,
- -0.8763066530f, -0.4817536771f, -0.9510565400f, -0.3090170026f, -0.9921147227f, -0.1253332347f, -0.9980267286f, 0.0627905205f,
- -0.9685831666f, 0.2486898899f, -0.9048270583f, 0.4257792830f, -0.8090170026f, 0.5877852440f, -0.6845471263f, 0.7289686203f,
- -0.5358268023f, 0.8443279266f, -0.3681245446f, 0.9297764897f, -0.1873813123f, 0.9822872281f, 0.0000000000f, 1.0000000000f,
- 0.1873813123f, 0.9822872281f, 0.3681245446f, 0.9297764897f, 0.5358268023f, 0.8443279266f, 0.6845471263f, 0.7289686203f,
- 1.0000000000f, -0.0000000000f, 0.9999451637f, -0.0104717845f, 0.9997806549f, -0.0209424198f, 0.9995065331f, -0.0314107575f,
- 0.9991228580f, -0.0418756530f, 0.9986295104f, -0.0523359552f, 0.9980267286f, -0.0627905205f, 0.9973144531f, -0.0732381940f,
- 0.9964928627f, -0.0836778432f, 0.9955619574f, -0.0941083133f, 0.9945219159f, -0.1045284644f, 0.9933727384f, -0.1149371490f,
- 0.9921147227f, -0.1253332347f, 0.9907478690f, -0.1357155740f, 0.9892723560f, -0.1460830271f, 0.9876883626f, -0.1564344615f,
- 0.9859960079f, -0.1667687446f, 0.9841955900f, -0.1770847440f, 0.9822872281f, -0.1873813123f, 0.9802711606f, -0.1976573467f,
- 0.9781476259f, -0.2079116851f, 0.9759167433f, -0.2181432396f, 0.9735789299f, -0.2283508629f, 0.9711343050f, -0.2385334522f,
- 0.9685831666f, -0.2486898899f, 0.9659258127f, -0.2588190436f, 0.9631625414f, -0.2689198256f, 0.9602937102f, -0.2789911032f,
- 0.9573194981f, -0.2890318036f, 0.9542403221f, -0.2990407944f, 1.0000000000f, -0.0000000000f, 0.9995065331f, -0.0314107575f,
- 0.9980267286f, -0.0627905205f, 0.9955619574f, -0.0941083133f, 0.9921147227f, -0.1253332347f, 0.9876883626f, -0.1564344615f,
- 0.9822872281f, -0.1873813123f, 0.9759167433f, -0.2181432396f, 0.9685831666f, -0.2486898899f, 0.9602937102f, -0.2789911032f,
- 0.9510565400f, -0.3090170026f, 0.9408807755f, -0.3387379348f, 0.9297764897f, -0.3681245446f, 0.9177546501f, -0.3971478939f,
- 0.9048270583f, -0.4257792830f, 0.8910065293f, -0.4539904892f, 0.8763066530f, -0.4817536771f, 0.8607420325f, -0.5090414286f,
- 0.8443279266f, -0.5358268023f, 0.8270805478f, -0.5620833635f, 0.8090170026f, -0.5877852440f, 0.7901549935f, -0.6129070520f,
- 0.7705132365f, -0.6374239922f, 0.7501110435f, -0.6613118649f, 0.7289686203f, -0.6845471263f, 0.7071067691f, -0.7071067691f,
- 0.6845471263f, -0.7289686203f, 0.6613118649f, -0.7501110435f, 0.6374239922f, -0.7705132365f, 0.6129070520f, -0.7901549935f,
- 1.0000000000f, -0.0000000000f, 0.9986295104f, -0.0523359552f, 0.9945219159f, -0.1045284644f, 0.9876883626f, -0.1564344615f,
- 0.9781476259f, -0.2079116851f, 0.9659258127f, -0.2588190436f, 0.9510565400f, -0.3090170026f, 0.9335803986f, -0.3583679497f,
- 0.9135454297f, -0.4067366421f, 0.8910065293f, -0.4539904892f, 0.8660253882f, -0.5000000000f, 0.8386705518f, -0.5446390510f,
- 0.8090170026f, -0.5877852440f, 0.7771459818f, -0.6293203831f, 0.7431448102f, -0.6691306233f, 0.7071067691f, -0.7071067691f,
- 0.6691306233f, -0.7431448102f, 0.6293203831f, -0.7771459818f, 0.5877852440f, -0.8090170026f, 0.5446390510f, -0.8386705518f,
- 0.5000000000f, -0.8660253882f, 0.4539904892f, -0.8910065293f, 0.4067366421f, -0.9135454297f, 0.3583679497f, -0.9335803986f,
- 0.3090170026f, -0.9510565400f, 0.2588190436f, -0.9659258127f, 0.2079116851f, -0.9781476259f, 0.1564344615f, -0.9876883626f,
- 0.1045284644f, -0.9945219159f, 0.0523359552f, -0.9986295104f, 1.0000000000f, -0.0000000000f, 0.9973144531f, -0.0732381940f,
- 0.9892723560f, -0.1460830271f, 0.9759167433f, -0.2181432396f, 0.9573194981f, -0.2890318036f, 0.9335803986f, -0.3583679497f,
- 0.9048270583f, -0.4257792830f, 0.8712137938f, -0.4909037650f, 0.8329212666f, -0.5533915758f, 0.7901549935f, -0.6129070520f,
- 0.7431448102f, -0.6691306233f, 0.6921432018f, -0.7217602134f, 0.6374239922f, -0.7705132365f, 0.5792811513f, -0.8151277900f,
- 0.5180270076f, -0.8553642631f, 0.4539904892f, -0.8910065293f, 0.3875155747f, -0.9218631387f, 0.3189592957f, -0.9477683902f,
- 0.2486898899f, -0.9685831666f, 0.1770847440f, -0.9841955900f, 0.1045284644f, -0.9945219159f, 0.0314107575f, -0.9995065331f,
- -0.0418756530f, -0.9991228580f, -0.1149371490f, -0.9933727384f, -0.1873813123f, -0.9822872281f, -0.2588190436f, -0.9659258127f,
- -0.3288666606f, -0.9443763494f, -0.3971478939f, -0.9177546501f, -0.4632960260f, -0.8862035871f, -0.5269557834f, -0.8498926759f,
- 1.0000000000f, -0.0000000000f, 0.9955619574f, -0.0941083133f, 0.9822872281f, -0.1873813123f, 0.9602937102f, -0.2789911032f,
- 0.9297764897f, -0.3681245446f, 0.8910065293f, -0.4539904892f, 0.8443279266f, -0.5358268023f, 0.7901549935f, -0.6129070520f,
- 0.7289686203f, -0.6845471263f, 0.6613118649f, -0.7501110435f, 0.5877852440f, -0.8090170026f, 0.5090414286f, -0.8607420325f,
- 0.4257792830f, -0.9048270583f, 0.3387379348f, -0.9408807755f, 0.2486898899f, -0.9685831666f, 0.1564344615f, -0.9876883626f,
- 0.0627905205f, -0.9980267286f, -0.0314107575f, -0.9995065331f, -0.1253332347f, -0.9921147227f, -0.2181432396f, -0.9759167433f,
- -0.3090170026f, -0.9510565400f, -0.3971478939f, -0.9177546501f, -0.4817536771f, -0.8763066530f, -0.5620833635f, -0.8270805478f,
- -0.6374239922f, -0.7705132365f, -0.7071067691f, -0.7071067691f, -0.7705132365f, -0.6374239922f, -0.8270805478f, -0.5620833635f,
- -0.8763066530f, -0.4817536771f, -0.9177546501f, -0.3971478939f, 1.0000000000f, -0.0000000000f, 0.9933727384f, -0.1149371490f,
- 0.9735789299f, -0.2283508629f, 0.9408807755f, -0.3387379348f, 0.8957117796f, -0.4446351826f, 0.8386705518f, -0.5446390510f,
- 0.7705132365f, -0.6374239922f, 0.6921432018f, -0.7217602134f, 0.6045991182f, -0.7965298891f, 0.5090414286f, -0.8607420325f,
- 0.4067366421f, -0.9135454297f, 0.2990407944f, -0.9542403221f, 0.1873813123f, -0.9822872281f, 0.0732381940f, -0.9973144531f,
- -0.0418756530f, -0.9991228580f, -0.1564344615f, -0.9876883626f, -0.2689198256f, -0.9631625414f, -0.3778407872f, -0.9258705974f,
- -0.4817536771f, -0.8763066530f, -0.5792811513f, -0.8151277900f, -0.6691306233f, -0.7431448102f, -0.7501110435f, -0.6613118649f,
- -0.8211492300f, -0.5707135797f, -0.8813034296f, -0.4725507796f, -0.9297764897f, -0.3681245446f, -0.9659258127f, -0.2588190436f,
- -0.9892723560f, -0.1460830271f, -0.9995065331f, -0.0314107575f, -0.9964928627f, 0.0836778432f, -0.9802711606f, 0.1976573467f,
- 1.0000000000f, -0.0000000000f, 0.9907478690f, -0.1357155740f, 0.9631625414f, -0.2689198256f, 0.9177546501f, -0.3971478939f,
- 0.8553642631f, -0.5180270076f, 0.7771459818f, -0.6293203831f, 0.6845471263f, -0.7289686203f, 0.5792811513f, -0.8151277900f,
- 0.4632960260f, -0.8862035871f, 0.3387379348f, -0.9408807755f, 0.2079116851f, -0.9781476259f, 0.0732381940f, -0.9973144531f,
- -0.0627905205f, -0.9980267286f, -0.1976573467f, -0.9802711606f, -0.3288666606f, -0.9443763494f, -0.4539904892f, -0.8910065293f,
- -0.5707135797f, -0.8211492300f, -0.6768759489f, -0.7360970974f, -0.7705132365f, -0.6374239922f, -0.8498926759f, -0.5269557834f,
- -0.9135454297f, -0.4067366421f, -0.9602937102f, -0.2789911032f, -0.9892723560f, -0.1460830271f, -0.9999451637f, -0.0104717845f,
- -0.9921147227f, 0.1253332347f, -0.9659258127f, 0.2588190436f, -0.9218631387f, 0.3875155747f, -0.8607420325f, 0.5090414286f,
- -0.7836934328f, 0.6211477518f, -0.6921432018f, 0.7217602134f, 1.0000000000f, -0.0000000000f, 0.9876883626f, -0.1564344615f,
- 0.9510565400f, -0.3090170026f, 0.8910065293f, -0.4539904892f, 0.8090170026f, -0.5877852440f, 0.7071067691f, -0.7071067691f,
- 0.5877852440f, -0.8090170026f, 0.4539904892f, -0.8910065293f, 0.3090170026f, -0.9510565400f, 0.1564344615f, -0.9876883626f,
- -0.0000000000f, -1.0000000000f, -0.1564344615f, -0.9876883626f, -0.3090170026f, -0.9510565400f, -0.4539904892f, -0.8910065293f,
- -0.5877852440f, -0.8090170026f, -0.7071067691f, -0.7071067691f, -0.8090170026f, -0.5877852440f, -0.8910065293f, -0.4539904892f,
- -0.9510565400f, -0.3090170026f, -0.9876883626f, -0.1564344615f, -1.0000000000f, 0.0000000000f, -0.9876883626f, 0.1564344615f,
- -0.9510565400f, 0.3090170026f, -0.8910065293f, 0.4539904892f, -0.8090170026f, 0.5877852440f, -0.7071067691f, 0.7071067691f,
- -0.5877852440f, 0.8090170026f, -0.4539904892f, 0.8910065293f, -0.3090170026f, 0.9510565400f, -0.1564344615f, 0.9876883626f,
- 1.0000000000f, -0.0000000000f, 0.9841955900f, -0.1770847440f, 0.9372819662f, -0.3485720456f, 0.8607420325f, -0.5090414286f,
- 0.7569950819f, -0.6534206271f, 0.6293203831f, -0.7771459818f, 0.4817536771f, -0.8763066530f, 0.3189592957f, -0.9477683902f,
- 0.1460830271f, -0.9892723560f, -0.0314107575f, -0.9995065331f, -0.2079116851f, -0.9781476259f, -0.3778407872f, -0.9258705974f,
- -0.5358268023f, -0.8443279266f, -0.6768759489f, -0.7360970974f, -0.7965298891f, -0.6045991182f, -0.8910065293f, -0.4539904892f,
- -0.9573194981f, -0.2890318036f, -0.9933727384f, -0.1149371490f, -0.9980267286f, 0.0627905205f, -0.9711343050f, 0.2385334522f,
- -0.9135454297f, 0.4067366421f, -0.8270805478f, 0.5620833635f, -0.7144726515f, 0.6996633410f, -0.5792811513f, 0.8151277900f,
- -0.4257792830f, 0.9048270583f, -0.2588190436f, 0.9659258127f, -0.0836778432f, 0.9964928627f, 0.0941083133f, 0.9955619574f,
- 0.2689198256f, 0.9631625414f, 0.4352310896f, 0.9003187418f, 1.0000000000f, -0.0000000000f, 0.9802711606f, -0.1976573467f,
- 0.9218631387f, -0.3875155747f, 0.8270805478f, -0.5620833635f, 0.6996633410f, -0.7144726515f, 0.5446390510f, -0.8386705518f,
- 0.3681245446f, -0.9297764897f, 0.1770847440f, -0.9841955900f, -0.0209424198f, -0.9997806549f, -0.2181432396f, -0.9759167433f,
- -0.4067366421f, -0.9135454297f, -0.5792811513f, -0.8151277900f, -0.7289686203f, -0.6845471263f, -0.8498926759f, -0.5269557834f,
- -0.9372819662f, -0.3485720456f, -0.9876883626f, -0.1564344615f, -0.9991228580f, 0.0418756530f, -0.9711343050f, 0.2385334522f,
- -0.9048270583f, 0.4257792830f, -0.8028174639f, 0.5962249041f, -0.6691306233f, 0.7431448102f, -0.5090414286f, 0.8607420325f,
- -0.3288666606f, 0.9443763494f, -0.1357155740f, 0.9907478690f, 0.0627905205f, 0.9980267286f, 0.2588190436f, 0.9659258127f,
- 0.4446351826f, 0.8957117796f, 0.6129070520f, 0.7901549935f, 0.7569950819f, 0.6534206271f, 0.8712137938f, 0.4909037650f
-};
-
-const float FFT_RotVector_640[1240] = {
- 1.0000000000f, -0.0000000000f, 0.9998072386f, -0.0196336918f, 0.9992290139f, -0.0392598175f, 0.9982656240f, -0.0588708036f,
- 0.9969173074f, -0.0784590989f, 0.9951847196f, -0.0980171412f, 0.9930684566f, -0.1175373942f, 0.9905693531f, -0.1370123476f,
- 0.9876883626f, -0.1564344615f, 0.9844265580f, -0.1757962853f, 0.9807852507f, -0.1950903237f, 0.9767658710f, -0.2143091559f,
- 0.9723699093f, -0.2334453613f, 0.9675990939f, -0.2524915636f, 0.9624552131f, -0.2714404464f, 0.9569403529f, -0.2902846634f,
- 0.9510565400f, -0.3090170026f, 0.9448060393f, -0.3276301920f, 0.9381913543f, -0.3461170495f, 0.9312149286f, -0.3644705117f,
- 1.0000000000f, -0.0000000000f, 0.9992290139f, -0.0392598175f, 0.9969173074f, -0.0784590989f, 0.9930684566f, -0.1175373942f,
- 0.9876883626f, -0.1564344615f, 0.9807852507f, -0.1950903237f, 0.9723699093f, -0.2334453613f, 0.9624552131f, -0.2714404464f,
- 0.9510565400f, -0.3090170026f, 0.9381913543f, -0.3461170495f, 0.9238795042f, -0.3826834261f, 0.9081431627f, -0.4186597466f,
- 0.8910065293f, -0.4539904892f, 0.8724960089f, -0.4886212349f, 0.8526401520f, -0.5224985480f, 0.8314695954f, -0.5555702448f,
- 0.8090170026f, -0.5877852440f, 0.7853169441f, -0.6190939546f, 0.7604059577f, -0.6494480371f, 0.7343224883f, -0.6788007617f,
- 1.0000000000f, -0.0000000000f, 0.9982656240f, -0.0588708036f, 0.9930684566f, -0.1175373942f, 0.9844265580f, -0.1757962853f,
- 0.9723699093f, -0.2334453613f, 0.9569403529f, -0.2902846634f, 0.9381913543f, -0.3461170495f, 0.9161879420f, -0.4007488191f,
- 0.8910065293f, -0.4539904892f, 0.8627343774f, -0.5056573749f, 0.8314695954f, -0.5555702448f, 0.7973206639f, -0.6035559177f,
- 0.7604059577f, -0.6494480371f, 0.7208535671f, -0.6930873394f, 0.6788007617f, -0.7343224883f, 0.6343932748f, -0.7730104327f,
- 0.5877852440f, -0.8090170026f, 0.5391383171f, -0.8422172070f, 0.4886212349f, -0.8724960089f, 0.4364092350f, -0.8997482657f,
- 1.0000000000f, -0.0000000000f, 0.9969173074f, -0.0784590989f, 0.9876883626f, -0.1564344615f, 0.9723699093f, -0.2334453613f,
- 0.9510565400f, -0.3090170026f, 0.9238795042f, -0.3826834261f, 0.8910065293f, -0.4539904892f, 0.8526401520f, -0.5224985480f,
- 0.8090170026f, -0.5877852440f, 0.7604059577f, -0.6494480371f, 0.7071067691f, -0.7071067691f, 0.6494480371f, -0.7604059577f,
- 0.5877852440f, -0.8090170026f, 0.5224985480f, -0.8526401520f, 0.4539904892f, -0.8910065293f, 0.3826834261f, -0.9238795042f,
- 0.3090170026f, -0.9510565400f, 0.2334453613f, -0.9723699093f, 0.1564344615f, -0.9876883626f, 0.0784590989f, -0.9969173074f,
- 1.0000000000f, -0.0000000000f, 0.9951847196f, -0.0980171412f, 0.9807852507f, -0.1950903237f, 0.9569403529f, -0.2902846634f,
- 0.9238795042f, -0.3826834261f, 0.8819212914f, -0.4713967443f, 0.8314695954f, -0.5555702448f, 0.7730104327f, -0.6343932748f,
- 0.7071067691f, -0.7071067691f, 0.6343932748f, -0.7730104327f, 0.5555702448f, -0.8314695954f, 0.4713967443f, -0.8819212914f,
- 0.3826834261f, -0.9238795042f, 0.2902846634f, -0.9569403529f, 0.1950903237f, -0.9807852507f, 0.0980171412f, -0.9951847196f,
- -0.0000000000f, -1.0000000000f, -0.0980171412f, -0.9951847196f, -0.1950903237f, -0.9807852507f, -0.2902846634f, -0.9569403529f,
- 1.0000000000f, -0.0000000000f, 0.9930684566f, -0.1175373942f, 0.9723699093f, -0.2334453613f, 0.9381913543f, -0.3461170495f,
- 0.8910065293f, -0.4539904892f, 0.8314695954f, -0.5555702448f, 0.7604059577f, -0.6494480371f, 0.6788007617f, -0.7343224883f,
- 0.5877852440f, -0.8090170026f, 0.4886212349f, -0.8724960089f, 0.3826834261f, -0.9238795042f, 0.2714404464f, -0.9624552131f,
- 0.1564344615f, -0.9876883626f, 0.0392598175f, -0.9992290139f, -0.0784590989f, -0.9969173074f, -0.1950903237f, -0.9807852507f,
- -0.3090170026f, -0.9510565400f, -0.4186597466f, -0.9081431627f, -0.5224985480f, -0.8526401520f, -0.6190939546f, -0.7853169441f,
- 1.0000000000f, -0.0000000000f, 0.9905693531f, -0.1370123476f, 0.9624552131f, -0.2714404464f, 0.9161879420f, -0.4007488191f,
- 0.8526401520f, -0.5224985480f, 0.7730104327f, -0.6343932748f, 0.6788007617f, -0.7343224883f, 0.5717879534f, -0.8204014301f,
- 0.4539904892f, -0.8910065293f, 0.3276301920f, -0.9448060393f, 0.1950903237f, -0.9807852507f, 0.0588708036f, -0.9982656240f,
- -0.0784590989f, -0.9969173074f, -0.2143091559f, -0.9767658710f, -0.3461170495f, -0.9381913543f, -0.4713967443f, -0.8819212914f,
- -0.5877852440f, -0.8090170026f, -0.6930873394f, -0.7208535671f, -0.7853169441f, -0.6190939546f, -0.8627343774f, -0.5056573749f,
- 1.0000000000f, -0.0000000000f, 0.9876883626f, -0.1564344615f, 0.9510565400f, -0.3090170026f, 0.8910065293f, -0.4539904892f,
- 0.8090170026f, -0.5877852440f, 0.7071067691f, -0.7071067691f, 0.5877852440f, -0.8090170026f, 0.4539904892f, -0.8910065293f,
- 0.3090170026f, -0.9510565400f, 0.1564344615f, -0.9876883626f, -0.0000000000f, -1.0000000000f, -0.1564344615f, -0.9876883626f,
- -0.3090170026f, -0.9510565400f, -0.4539904892f, -0.8910065293f, -0.5877852440f, -0.8090170026f, -0.7071067691f, -0.7071067691f,
- -0.8090170026f, -0.5877852440f, -0.8910065293f, -0.4539904892f, -0.9510565400f, -0.3090170026f, -0.9876883626f, -0.1564344615f,
- 1.0000000000f, -0.0000000000f, 0.9844265580f, -0.1757962853f, 0.9381913543f, -0.3461170495f, 0.8627343774f, -0.5056573749f,
- 0.7604059577f, -0.6494480371f, 0.6343932748f, -0.7730104327f, 0.4886212349f, -0.8724960089f, 0.3276301920f, -0.9448060393f,
- 0.1564344615f, -0.9876883626f, -0.0196336918f, -0.9998072386f, -0.1950903237f, -0.9807852507f, -0.3644705117f, -0.9312149286f,
- -0.5224985480f, -0.8526401520f, -0.6642524600f, -0.7475083470f, -0.7853169441f, -0.6190939546f, -0.8819212914f, -0.4713967443f,
- -0.9510565400f, -0.3090170026f, -0.9905693531f, -0.1370123476f, -0.9992290139f, 0.0392598175f, -0.9767658710f, 0.2143091559f,
- 1.0000000000f, -0.0000000000f, 0.9807852507f, -0.1950903237f, 0.9238795042f, -0.3826834261f, 0.8314695954f, -0.5555702448f,
- 0.7071067691f, -0.7071067691f, 0.5555702448f, -0.8314695954f, 0.3826834261f, -0.9238795042f, 0.1950903237f, -0.9807852507f,
- -0.0000000000f, -1.0000000000f, -0.1950903237f, -0.9807852507f, -0.3826834261f, -0.9238795042f, -0.5555702448f, -0.8314695954f,
- -0.7071067691f, -0.7071067691f, -0.8314695954f, -0.5555702448f, -0.9238795042f, -0.3826834261f, -0.9807852507f, -0.1950903237f,
- -1.0000000000f, 0.0000000000f, -0.9807852507f, 0.1950903237f, -0.9238795042f, 0.3826834261f, -0.8314695954f, 0.5555702448f,
- 1.0000000000f, -0.0000000000f, 0.9767658710f, -0.2143091559f, 0.9081431627f, -0.4186597466f, 0.7973206639f, -0.6035559177f,
- 0.6494480371f, -0.7604059577f, 0.4713967443f, -0.8819212914f, 0.2714404464f, -0.9624552131f, 0.0588708036f, -0.9982656240f,
- -0.1564344615f, -0.9876883626f, -0.3644705117f, -0.9312149286f, -0.5555702448f, -0.8314695954f, -0.7208535671f, -0.6930873394f,
- -0.8526401520f, -0.5224985480f, -0.9448060393f, -0.3276301920f, -0.9930684566f, -0.1175373942f, -0.9951847196f, 0.0980171412f,
- -0.9510565400f, 0.3090170026f, -0.8627343774f, 0.5056573749f, -0.7343224883f, 0.6788007617f, -0.5717879534f, 0.8204014301f,
- 1.0000000000f, -0.0000000000f, 0.9723699093f, -0.2334453613f, 0.8910065293f, -0.4539904892f, 0.7604059577f, -0.6494480371f,
- 0.5877852440f, -0.8090170026f, 0.3826834261f, -0.9238795042f, 0.1564344615f, -0.9876883626f, -0.0784590989f, -0.9969173074f,
- -0.3090170026f, -0.9510565400f, -0.5224985480f, -0.8526401520f, -0.7071067691f, -0.7071067691f, -0.8526401520f, -0.5224985480f,
- -0.9510565400f, -0.3090170026f, -0.9969173074f, -0.0784590989f, -0.9876883626f, 0.1564344615f, -0.9238795042f, 0.3826834261f,
- -0.8090170026f, 0.5877852440f, -0.6494480371f, 0.7604059577f, -0.4539904892f, 0.8910065293f, -0.2334453613f, 0.9723699093f,
- 1.0000000000f, -0.0000000000f, 0.9675990939f, -0.2524915636f, 0.8724960089f, -0.4886212349f, 0.7208535671f, -0.6930873394f,
- 0.5224985480f, -0.8526401520f, 0.2902846634f, -0.9569403529f, 0.0392598175f, -0.9992290139f, -0.2143091559f, -0.9767658710f,
- -0.4539904892f, -0.8910065293f, -0.6642524600f, -0.7475083470f, -0.8314695954f, -0.5555702448f, -0.9448060393f, -0.3276301920f,
- -0.9969173074f, -0.0784590989f, -0.9844265580f, 0.1757962853f, -0.9081431627f, 0.4186597466f, -0.7730104327f, 0.6343932748f,
- -0.5877852440f, 0.8090170026f, -0.3644705117f, 0.9312149286f, -0.1175373942f, 0.9930684566f, 0.1370123476f, 0.9905693531f,
- 1.0000000000f, -0.0000000000f, 0.9624552131f, -0.2714404464f, 0.8526401520f, -0.5224985480f, 0.6788007617f, -0.7343224883f,
- 0.4539904892f, -0.8910065293f, 0.1950903237f, -0.9807852507f, -0.0784590989f, -0.9969173074f, -0.3461170495f, -0.9381913543f,
- -0.5877852440f, -0.8090170026f, -0.7853169441f, -0.6190939546f, -0.9238795042f, -0.3826834261f, -0.9930684566f, -0.1175373942f,
- -0.9876883626f, 0.1564344615f, -0.9081431627f, 0.4186597466f, -0.7604059577f, 0.6494480371f, -0.5555702448f, 0.8314695954f,
- -0.3090170026f, 0.9510565400f, -0.0392598175f, 0.9992290139f, 0.2334453613f, 0.9723699093f, 0.4886212349f, 0.8724960089f,
- 1.0000000000f, -0.0000000000f, 0.9569403529f, -0.2902846634f, 0.8314695954f, -0.5555702448f, 0.6343932748f, -0.7730104327f,
- 0.3826834261f, -0.9238795042f, 0.0980171412f, -0.9951847196f, -0.1950903237f, -0.9807852507f, -0.4713967443f, -0.8819212914f,
- -0.7071067691f, -0.7071067691f, -0.8819212914f, -0.4713967443f, -0.9807852507f, -0.1950903237f, -0.9951847196f, 0.0980171412f,
- -0.9238795042f, 0.3826834261f, -0.7730104327f, 0.6343932748f, -0.5555702448f, 0.8314695954f, -0.2902846634f, 0.9569403529f,
- 0.0000000000f, 1.0000000000f, 0.2902846634f, 0.9569403529f, 0.5555702448f, 0.8314695954f, 0.7730104327f, 0.6343932748f,
- 1.0000000000f, -0.0000000000f, 0.9999517798f, -0.0098173190f, 0.9998072386f, -0.0196336918f, 0.9995663166f, -0.0294481739f,
- 0.9992290139f, -0.0392598175f, 0.9987954497f, -0.0490676761f, 0.9982656240f, -0.0588708036f, 0.9976395369f, -0.0686682612f,
- 0.9969173074f, -0.0784590989f, 0.9960990548f, -0.0882423669f, 0.9951847196f, -0.0980171412f, 0.9941744804f, -0.1077824607f,
- 0.9930684566f, -0.1175373942f, 0.9918667078f, -0.1272810102f, 0.9905693531f, -0.1370123476f, 0.9891765118f, -0.1467304677f,
- 0.9876883626f, -0.1564344615f, 0.9861049652f, -0.1661233753f, 0.9844265580f, -0.1757962853f, 0.9826532602f, -0.1854522377f,
- 1.0000000000f, -0.0000000000f, 0.9995663166f, -0.0294481739f, 0.9982656240f, -0.0588708036f, 0.9960990548f, -0.0882423669f,
- 0.9930684566f, -0.1175373942f, 0.9891765118f, -0.1467304677f, 0.9844265580f, -0.1757962853f, 0.9788227677f, -0.2047096044f,
- 0.9723699093f, -0.2334453613f, 0.9650736451f, -0.2619786263f, 0.9569403529f, -0.2902846634f, 0.9479769468f, -0.3183389306f,
- 0.9381913543f, -0.3461170495f, 0.9275919199f, -0.3735949695f, 0.9161879420f, -0.4007488191f, 0.9039893150f, -0.4275550842f,
- 0.8910065293f, -0.4539904892f, 0.8772509098f, -0.4800321162f, 0.8627343774f, -0.5056573749f, 0.8474695683f, -0.5308440328f,
- 1.0000000000f, -0.0000000000f, 0.9987954497f, -0.0490676761f, 0.9951847196f, -0.0980171412f, 0.9891765118f, -0.1467304677f,
- 0.9807852507f, -0.1950903237f, 0.9700312614f, -0.2429801822f, 0.9569403529f, -0.2902846634f, 0.9415440559f, -0.3368898630f,
- 0.9238795042f, -0.3826834261f, 0.9039893150f, -0.4275550842f, 0.8819212914f, -0.4713967443f, 0.8577286005f, -0.5141027570f,
- 0.8314695954f, -0.5555702448f, 0.8032075167f, -0.5956993103f, 0.7730104327f, -0.6343932748f, 0.7409511209f, -0.6715589762f,
- 0.7071067691f, -0.7071067691f, 0.6715589762f, -0.7409511209f, 0.6343932748f, -0.7730104327f, 0.5956993103f, -0.8032075167f,
- 1.0000000000f, -0.0000000000f, 0.9976395369f, -0.0686682612f, 0.9905693531f, -0.1370123476f, 0.9788227677f, -0.2047096044f,
- 0.9624552131f, -0.2714404464f, 0.9415440559f, -0.3368898630f, 0.9161879420f, -0.4007488191f, 0.8865066171f, -0.4627159238f,
- 0.8526401520f, -0.5224985480f, 0.8147484660f, -0.5798145533f, 0.7730104327f, -0.6343932748f, 0.7276231050f, -0.6859771013f,
- 0.6788007617f, -0.7343224883f, 0.6267738342f, -0.7792012691f, 0.5717879534f, -0.8204014301f, 0.5141027570f, -0.8577286005f,
- 0.4539904892f, -0.8910065293f, 0.3917350173f, -0.9200780988f, 0.3276301920f, -0.9448060393f, 0.2619786263f, -0.9650736451f,
- 1.0000000000f, -0.0000000000f, 0.9960990548f, -0.0882423669f, 0.9844265580f, -0.1757962853f, 0.9650736451f, -0.2619786263f,
- 0.9381913543f, -0.3461170495f, 0.9039893150f, -0.4275550842f, 0.8627343774f, -0.5056573749f, 0.8147484660f, -0.5798145533f,
- 0.7604059577f, -0.6494480371f, 0.7001308203f, -0.7140145898f, 0.6343932748f, -0.7730104327f, 0.5637062788f, -0.8259753585f,
- 0.4886212349f, -0.8724960089f, 0.4097240269f, -0.9122095108f, 0.3276301920f, -0.9448060393f, 0.2429801822f, -0.9700312614f,
- 0.1564344615f, -0.9876883626f, 0.0686682612f, -0.9976395369f, -0.0196336918f, -0.9998072386f, -0.1077824607f, -0.9941744804f,
- 1.0000000000f, -0.0000000000f, 0.9941744804f, -0.1077824607f, 0.9767658710f, -0.2143091559f, 0.9479769468f, -0.3183389306f,
- 0.9081431627f, -0.4186597466f, 0.8577286005f, -0.5141027570f, 0.7973206639f, -0.6035559177f, 0.7276231050f, -0.6859771013f,
- 0.6494480371f, -0.7604059577f, 0.5637062788f, -0.8259753585f, 0.4713967443f, -0.8819212914f, 0.3735949695f, -0.9275919199f,
- 0.2714404464f, -0.9624552131f, 0.1661233753f, -0.9861049652f, 0.0588708036f, -0.9982656240f, -0.0490676761f, -0.9987954497f,
- -0.1564344615f, -0.9876883626f, -0.2619786263f, -0.9650736451f, -0.3644705117f, -0.9312149286f, -0.4627159238f, -0.8865066171f,
- 1.0000000000f, -0.0000000000f, 0.9918667078f, -0.1272810102f, 0.9675990939f, -0.2524915636f, 0.9275919199f, -0.3735949695f,
- 0.8724960089f, -0.4886212349f, 0.8032075167f, -0.5956993103f, 0.7208535671f, -0.6930873394f, 0.6267738342f, -0.7792012691f,
- 0.5224985480f, -0.8526401520f, 0.4097240269f, -0.9122095108f, 0.2902846634f, -0.9569403529f, 0.1661233753f, -0.9861049652f,
- 0.0392598175f, -0.9992290139f, -0.0882423669f, -0.9960990548f, -0.2143091559f, -0.9767658710f, -0.3368898630f, -0.9415440559f,
- -0.4539904892f, -0.8910065293f, -0.5637062788f, -0.8259753585f, -0.6642524600f, -0.7475083470f, -0.7539935112f, -0.6568819284f,
- 1.0000000000f, -0.0000000000f, 0.9891765118f, -0.1467304677f, 0.9569403529f, -0.2902846634f, 0.9039893150f, -0.4275550842f,
- 0.8314695954f, -0.5555702448f, 0.7409511209f, -0.6715589762f, 0.6343932748f, -0.7730104327f, 0.5141027570f, -0.8577286005f,
- 0.3826834261f, -0.9238795042f, 0.2429801822f, -0.9700312614f, 0.0980171412f, -0.9951847196f, -0.0490676761f, -0.9987954497f,
- -0.1950903237f, -0.9807852507f, -0.3368898630f, -0.9415440559f, -0.4713967443f, -0.8819212914f, -0.5956993103f, -0.8032075167f,
- -0.7071067691f, -0.7071067691f, -0.8032075167f, -0.5956993103f, -0.8819212914f, -0.4713967443f, -0.9415440559f, -0.3368898630f,
- 1.0000000000f, -0.0000000000f, 0.9861049652f, -0.1661233753f, 0.9448060393f, -0.3276301920f, 0.8772509098f, -0.4800321162f,
- 0.7853169441f, -0.6190939546f, 0.6715589762f, -0.7409511209f, 0.5391383171f, -0.8422172070f, 0.3917350173f, -0.9200780988f,
- 0.2334453613f, -0.9723699093f, 0.0686682612f, -0.9976395369f, -0.0980171412f, -0.9951847196f, -0.2619786263f, -0.9650736451f,
- -0.4186597466f, -0.9081431627f, -0.5637062788f, -0.8259753585f, -0.6930873394f, -0.7208535671f, -0.8032075167f, -0.5956993103f,
- -0.8910065293f, -0.4539904892f, -0.9540444016f, -0.2996652722f, -0.9905693531f, -0.1370123476f, -0.9995663166f, 0.0294481739f,
- 1.0000000000f, -0.0000000000f, 0.9826532602f, -0.1854522377f, 0.9312149286f, -0.3644705117f, 0.8474695683f, -0.5308440328f,
- 0.7343224883f, -0.6788007617f, 0.5956993103f, -0.8032075167f, 0.4364092350f, -0.8997482657f, 0.2619786263f, -0.9650736451f,
- 0.0784590989f, -0.9969173074f, -0.1077824607f, -0.9941744804f, -0.2902846634f, -0.9569403529f, -0.4627159238f, -0.8865066171f,
- -0.6190939546f, -0.7853169441f, -0.7539935112f, -0.6568819284f, -0.8627343774f, -0.5056573749f, -0.9415440559f, -0.3368898630f,
- -0.9876883626f, -0.1564344615f, -0.9995663166f, 0.0294481739f, -0.9767658710f, 0.2143091559f, -0.9200780988f, 0.3917350173f,
- 1.0000000000f, -0.0000000000f, 0.9788227677f, -0.2047096044f, 0.9161879420f, -0.4007488191f, 0.8147484660f, -0.5798145533f,
- 0.6788007617f, -0.7343224883f, 0.5141027570f, -0.8577286005f, 0.3276301920f, -0.9448060393f, 0.1272810102f, -0.9918667078f,
- -0.0784590989f, -0.9969173074f, -0.2808761001f, -0.9597440362f, -0.4713967443f, -0.8819212914f, -0.6419516206f, -0.7667451501f,
- -0.7853169441f, -0.6190939546f, -0.8954205513f, -0.4452213347f, -0.9675990939f, -0.2524915636f, -0.9987954497f, -0.0490676761f,
- -0.9876883626f, 0.1564344615f, -0.9347481728f, 0.3553108871f, -0.8422172070f, 0.5391383171f, -0.7140145898f, 0.7001308203f,
- 1.0000000000f, -0.0000000000f, 0.9746148586f, -0.2238880545f, 0.8997482657f, -0.4364092350f, 0.7792012691f, -0.6267738342f,
- 0.6190939546f, -0.7853169441f, 0.4275550842f, -0.9039893150f, 0.2143091559f, -0.9767658710f, -0.0098173190f, -0.9999517798f,
- -0.2334453613f, -0.9723699093f, -0.4452213347f, -0.8954205513f, -0.6343932748f, -0.7730104327f, -0.7913569212f, -0.6113544106f,
- -0.9081431627f, -0.4186597466f, -0.9788227677f, -0.2047096044f, -0.9998072386f, 0.0196336918f, -0.9700312614f, 0.2429801822f,
- -0.8910065293f, 0.4539904892f, -0.7667451501f, 0.6419516206f, -0.6035559177f, 0.7973206639f, -0.4097240269f, 0.9122095108f,
- 1.0000000000f, -0.0000000000f, 0.9700312614f, -0.2429801822f, 0.8819212914f, -0.4713967443f, 0.7409511209f, -0.6715589762f,
- 0.5555702448f, -0.8314695954f, 0.3368898630f, -0.9415440559f, 0.0980171412f, -0.9951847196f, -0.1467304677f, -0.9891765118f,
- -0.3826834261f, -0.9238795042f, -0.5956993103f, -0.8032075167f, -0.7730104327f, -0.6343932748f, -0.9039893150f, -0.4275550842f,
- -0.9807852507f, -0.1950903237f, -0.9987954497f, 0.0490676761f, -0.9569403529f, 0.2902846634f, -0.8577286005f, 0.5141027570f,
- -0.7071067691f, 0.7071067691f, -0.5141027570f, 0.8577286005f, -0.2902846634f, 0.9569403529f, -0.0490676761f, 0.9987954497f,
- 1.0000000000f, -0.0000000000f, 0.9650736451f, -0.2619786263f, 0.8627343774f, -0.5056573749f, 0.7001308203f, -0.7140145898f,
- 0.4886212349f, -0.8724960089f, 0.2429801822f, -0.9700312614f, -0.0196336918f, -0.9998072386f, -0.2808761001f, -0.9597440362f,
- -0.5224985480f, -0.8526401520f, -0.7276231050f, -0.6859771013f, -0.8819212914f, -0.4713967443f, -0.9746148586f, -0.2238880545f,
- -0.9992290139f, 0.0392598175f, -0.9540444016f, 0.2996652722f, -0.8422172070f, 0.5391383171f, -0.6715589762f, 0.7409511209f,
- -0.4539904892f, 0.8910065293f, -0.2047096044f, 0.9788227677f, 0.0588708036f, 0.9982656240f, 0.3183389306f, 0.9479769468f,
- 1.0000000000f, -0.0000000000f, 0.9597440362f, -0.2808761001f, 0.8422172070f, -0.5391383171f, 0.6568819284f, -0.7539935112f,
- 0.4186597466f, -0.9081431627f, 0.1467304677f, -0.9891765118f, -0.1370123476f, -0.9905693531f, -0.4097240269f, -0.9122095108f,
- -0.6494480371f, -0.7604059577f, -0.8368837237f, -0.5473806858f, -0.9569403529f, -0.2902846634f, -0.9999517798f, -0.0098173190f,
- -0.9624552131f, 0.2714404464f, -0.8474695683f, 0.5308440328f, -0.6642524600f, 0.7475083470f, -0.4275550842f, 0.9039893150f,
- -0.1564344615f, 0.9876883626f, 0.1272810102f, 0.9918667078f, 0.4007488191f, 0.9161879420f, 0.6419516206f, 0.7667451501f,
- 1.0000000000f, -0.0000000000f, 0.9540444016f, -0.2996652722f, 0.8204014301f, -0.5717879534f, 0.6113544106f, -0.7913569212f,
- 0.3461170495f, -0.9381913543f, 0.0490676761f, -0.9987954497f, -0.2524915636f, -0.9675990939f, -0.5308440328f, -0.8474695683f,
- -0.7604059577f, -0.6494480371f, -0.9200780988f, -0.3917350173f, -0.9951847196f, -0.0980171412f, -0.9788227677f, 0.2047096044f,
- -0.8724960089f, 0.4886212349f, -0.6859771013f, 0.7276231050f, -0.4364092350f, 0.8997482657f, -0.1467304677f, 0.9891765118f,
- 0.1564344615f, 0.9876883626f, 0.4452213347f, 0.8954205513f, 0.6930873394f, 0.7208535671f, 0.8772509098f, 0.4800321162f
-};
-
-const float FFT_RotVector_960[1860] = {
- 1.0000000000f, -0.0000000000f, 0.9999143481f, -0.0130895954f,
- 0.9996573329f, -0.0261769481f, 0.9992290139f, -0.0392598175f, 0.9986295104f, -0.0523359552f, 0.9978589416f, -0.0654031262f,
- 0.9969173074f, -0.0784590989f, 0.9958049059f, -0.0915016159f, 0.9945219159f, -0.1045284644f, 0.9930684566f, -0.1175373942f,
- 0.9914448857f, -0.1305261850f, 0.9896513820f, -0.1434926242f, 0.9876883626f, -0.1564344615f, 0.9855560660f, -0.1693495065f,
- 0.9832549095f, -0.1822355241f, 0.9807852507f, -0.1950903237f, 0.9781476259f, -0.2079116851f, 0.9753423333f, -0.2206974328f,
- 0.9723699093f, -0.2334453613f, 0.9692308903f, -0.2461532950f, 0.9659258127f, -0.2588190436f, 0.9624552131f, -0.2714404464f,
- 0.9588197470f, -0.2840153575f, 0.9550199509f, -0.2965415716f, 0.9510565400f, -0.3090170026f, 0.9469301105f, -0.3214394748f,
- 0.9426414967f, -0.3338068724f, 0.9381913543f, -0.3461170495f, 0.9335803986f, -0.3583679497f, 0.9288095236f, -0.3705574274f,
- 1.0000000000f, -0.0000000000f, 0.9996573329f, -0.0261769481f, 0.9986295104f, -0.0523359552f, 0.9969173074f, -0.0784590989f,
- 0.9945219159f, -0.1045284644f, 0.9914448857f, -0.1305261850f, 0.9876883626f, -0.1564344615f, 0.9832549095f, -0.1822355241f,
- 0.9781476259f, -0.2079116851f, 0.9723699093f, -0.2334453613f, 0.9659258127f, -0.2588190436f, 0.9588197470f, -0.2840153575f,
- 0.9510565400f, -0.3090170026f, 0.9426414967f, -0.3338068724f, 0.9335803986f, -0.3583679497f, 0.9238795042f, -0.3826834261f,
- 0.9135454297f, -0.4067366421f, 0.9025852680f, -0.4305110872f, 0.8910065293f, -0.4539904892f, 0.8788171411f, -0.4771587551f,
- 0.8660253882f, -0.5000000000f, 0.8526401520f, -0.5224985480f, 0.8386705518f, -0.5446390510f, 0.8241261840f, -0.5664062500f,
- 0.8090170026f, -0.5877852440f, 0.7933533192f, -0.6087614298f, 0.7771459818f, -0.6293203831f, 0.7604059577f, -0.6494480371f,
- 0.7431448102f, -0.6691306233f, 0.7253744006f, -0.6883545518f, 1.0000000000f, -0.0000000000f, 0.9992290139f, -0.0392598175f,
- 0.9969173074f, -0.0784590989f, 0.9930684566f, -0.1175373942f, 0.9876883626f, -0.1564344615f, 0.9807852507f, -0.1950903237f,
- 0.9723699093f, -0.2334453613f, 0.9624552131f, -0.2714404464f, 0.9510565400f, -0.3090170026f, 0.9381913543f, -0.3461170495f,
- 0.9238795042f, -0.3826834261f, 0.9081431627f, -0.4186597466f, 0.8910065293f, -0.4539904892f, 0.8724960089f, -0.4886212349f,
- 0.8526401520f, -0.5224985480f, 0.8314695954f, -0.5555702448f, 0.8090170026f, -0.5877852440f, 0.7853169441f, -0.6190939546f,
- 0.7604059577f, -0.6494480371f, 0.7343224883f, -0.6788007617f, 0.7071067691f, -0.7071067691f, 0.6788007617f, -0.7343224883f,
- 0.6494480371f, -0.7604059577f, 0.6190939546f, -0.7853169441f, 0.5877852440f, -0.8090170026f, 0.5555702448f, -0.8314695954f,
- 0.5224985480f, -0.8526401520f, 0.4886212349f, -0.8724960089f, 0.4539904892f, -0.8910065293f, 0.4186597466f, -0.9081431627f,
- 1.0000000000f, -0.0000000000f, 0.9986295104f, -0.0523359552f, 0.9945219159f, -0.1045284644f, 0.9876883626f, -0.1564344615f,
- 0.9781476259f, -0.2079116851f, 0.9659258127f, -0.2588190436f, 0.9510565400f, -0.3090170026f, 0.9335803986f, -0.3583679497f,
- 0.9135454297f, -0.4067366421f, 0.8910065293f, -0.4539904892f, 0.8660253882f, -0.5000000000f, 0.8386705518f, -0.5446390510f,
- 0.8090170026f, -0.5877852440f, 0.7771459818f, -0.6293203831f, 0.7431448102f, -0.6691306233f, 0.7071067691f, -0.7071067691f,
- 0.6691306233f, -0.7431448102f, 0.6293203831f, -0.7771459818f, 0.5877852440f, -0.8090170026f, 0.5446390510f, -0.8386705518f,
- 0.5000000000f, -0.8660253882f, 0.4539904892f, -0.8910065293f, 0.4067366421f, -0.9135454297f, 0.3583679497f, -0.9335803986f,
- 0.3090170026f, -0.9510565400f, 0.2588190436f, -0.9659258127f, 0.2079116851f, -0.9781476259f, 0.1564344615f, -0.9876883626f,
- 0.1045284644f, -0.9945219159f, 0.0523359552f, -0.9986295104f, 1.0000000000f, -0.0000000000f, 0.9978589416f, -0.0654031262f,
- 0.9914448857f, -0.1305261850f, 0.9807852507f, -0.1950903237f, 0.9659258127f, -0.2588190436f, 0.9469301105f, -0.3214394748f,
- 0.9238795042f, -0.3826834261f, 0.8968727589f, -0.4422886968f, 0.8660253882f, -0.5000000000f, 0.8314695954f, -0.5555702448f,
- 0.7933533192f, -0.6087614298f, 0.7518398166f, -0.6593458056f, 0.7071067691f, -0.7071067691f, 0.6593458056f, -0.7518398166f,
- 0.6087614298f, -0.7933533192f, 0.5555702448f, -0.8314695954f, 0.5000000000f, -0.8660253882f, 0.4422886968f, -0.8968727589f,
- 0.3826834261f, -0.9238795042f, 0.3214394748f, -0.9469301105f, 0.2588190436f, -0.9659258127f, 0.1950903237f, -0.9807852507f,
- 0.1305261850f, -0.9914448857f, 0.0654031262f, -0.9978589416f, -0.0000000000f, -1.0000000000f, -0.0654031262f, -0.9978589416f,
- -0.1305261850f, -0.9914448857f, -0.1950903237f, -0.9807852507f, -0.2588190436f, -0.9659258127f, -0.3214394748f, -0.9469301105f,
- 1.0000000000f, -0.0000000000f, 0.9969173074f, -0.0784590989f, 0.9876883626f, -0.1564344615f, 0.9723699093f, -0.2334453613f,
- 0.9510565400f, -0.3090170026f, 0.9238795042f, -0.3826834261f, 0.8910065293f, -0.4539904892f, 0.8526401520f, -0.5224985480f,
- 0.8090170026f, -0.5877852440f, 0.7604059577f, -0.6494480371f, 0.7071067691f, -0.7071067691f, 0.6494480371f, -0.7604059577f,
- 0.5877852440f, -0.8090170026f, 0.5224985480f, -0.8526401520f, 0.4539904892f, -0.8910065293f, 0.3826834261f, -0.9238795042f,
- 0.3090170026f, -0.9510565400f, 0.2334453613f, -0.9723699093f, 0.1564344615f, -0.9876883626f, 0.0784590989f, -0.9969173074f,
- -0.0000000000f, -1.0000000000f, -0.0784590989f, -0.9969173074f, -0.1564344615f, -0.9876883626f, -0.2334453613f, -0.9723699093f,
- -0.3090170026f, -0.9510565400f, -0.3826834261f, -0.9238795042f, -0.4539904892f, -0.8910065293f, -0.5224985480f, -0.8526401520f,
- -0.5877852440f, -0.8090170026f, -0.6494480371f, -0.7604059577f, 1.0000000000f, -0.0000000000f, 0.9958049059f, -0.0915016159f,
- 0.9832549095f, -0.1822355241f, 0.9624552131f, -0.2714404464f, 0.9335803986f, -0.3583679497f, 0.8968727589f, -0.4422886968f,
- 0.8526401520f, -0.5224985480f, 0.8012537956f, -0.5983245969f, 0.7431448102f, -0.6691306233f, 0.6788007617f, -0.7343224883f,
- 0.6087614298f, -0.7933533192f, 0.5336145163f, -0.8457278013f, 0.4539904892f, -0.8910065293f, 0.3705574274f, -0.9288095236f,
- 0.2840153575f, -0.9588197470f, 0.1950903237f, -0.9807852507f, 0.1045284644f, -0.9945219159f, 0.0130895954f, -0.9999143481f,
- -0.0784590989f, -0.9969173074f, -0.1693495065f, -0.9855560660f, -0.2588190436f, -0.9659258127f, -0.3461170495f, -0.9381913543f,
- -0.4305110872f, -0.9025852680f, -0.5112931132f, -0.8594064116f, -0.5877852440f, -0.8090170026f, -0.6593458056f, -0.7518398166f,
- -0.7253744006f, -0.6883545518f, -0.7853169441f, -0.6190939546f, -0.8386705518f, -0.5446390510f, -0.8849876523f, -0.4656145275f,
- 1.0000000000f, -0.0000000000f, 0.9945219159f, -0.1045284644f, 0.9781476259f, -0.2079116851f, 0.9510565400f, -0.3090170026f,
- 0.9135454297f, -0.4067366421f, 0.8660253882f, -0.5000000000f, 0.8090170026f, -0.5877852440f, 0.7431448102f, -0.6691306233f,
- 0.6691306233f, -0.7431448102f, 0.5877852440f, -0.8090170026f, 0.5000000000f, -0.8660253882f, 0.4067366421f, -0.9135454297f,
- 0.3090170026f, -0.9510565400f, 0.2079116851f, -0.9781476259f, 0.1045284644f, -0.9945219159f, -0.0000000000f, -1.0000000000f,
- -0.1045284644f, -0.9945219159f, -0.2079116851f, -0.9781476259f, -0.3090170026f, -0.9510565400f, -0.4067366421f, -0.9135454297f,
- -0.5000000000f, -0.8660253882f, -0.5877852440f, -0.8090170026f, -0.6691306233f, -0.7431448102f, -0.7431448102f, -0.6691306233f,
- -0.8090170026f, -0.5877852440f, -0.8660253882f, -0.5000000000f, -0.9135454297f, -0.4067366421f, -0.9510565400f, -0.3090170026f,
- -0.9781476259f, -0.2079116851f, -0.9945219159f, -0.1045284644f, 1.0000000000f, -0.0000000000f, 0.9930684566f, -0.1175373942f,
- 0.9723699093f, -0.2334453613f, 0.9381913543f, -0.3461170495f, 0.8910065293f, -0.4539904892f, 0.8314695954f, -0.5555702448f,
- 0.7604059577f, -0.6494480371f, 0.6788007617f, -0.7343224883f, 0.5877852440f, -0.8090170026f, 0.4886212349f, -0.8724960089f,
- 0.3826834261f, -0.9238795042f, 0.2714404464f, -0.9624552131f, 0.1564344615f, -0.9876883626f, 0.0392598175f, -0.9992290139f,
- -0.0784590989f, -0.9969173074f, -0.1950903237f, -0.9807852507f, -0.3090170026f, -0.9510565400f, -0.4186597466f, -0.9081431627f,
- -0.5224985480f, -0.8526401520f, -0.6190939546f, -0.7853169441f, -0.7071067691f, -0.7071067691f, -0.7853169441f, -0.6190939546f,
- -0.8526401520f, -0.5224985480f, -0.9081431627f, -0.4186597466f, -0.9510565400f, -0.3090170026f, -0.9807852507f, -0.1950903237f,
- -0.9969173074f, -0.0784590989f, -0.9992290139f, 0.0392598175f, -0.9876883626f, 0.1564344615f, -0.9624552131f, 0.2714404464f,
- 1.0000000000f, -0.0000000000f, 0.9914448857f, -0.1305261850f, 0.9659258127f, -0.2588190436f, 0.9238795042f, -0.3826834261f,
- 0.8660253882f, -0.5000000000f, 0.7933533192f, -0.6087614298f, 0.7071067691f, -0.7071067691f, 0.6087614298f, -0.7933533192f,
- 0.5000000000f, -0.8660253882f, 0.3826834261f, -0.9238795042f, 0.2588190436f, -0.9659258127f, 0.1305261850f, -0.9914448857f,
- -0.0000000000f, -1.0000000000f, -0.1305261850f, -0.9914448857f, -0.2588190436f, -0.9659258127f, -0.3826834261f, -0.9238795042f,
- -0.5000000000f, -0.8660253882f, -0.6087614298f, -0.7933533192f, -0.7071067691f, -0.7071067691f, -0.7933533192f, -0.6087614298f,
- -0.8660253882f, -0.5000000000f, -0.9238795042f, -0.3826834261f, -0.9659258127f, -0.2588190436f, -0.9914448857f, -0.1305261850f,
- -1.0000000000f, 0.0000000000f, -0.9914448857f, 0.1305261850f, -0.9659258127f, 0.2588190436f, -0.9238795042f, 0.3826834261f,
- -0.8660253882f, 0.5000000000f, -0.7933533192f, 0.6087614298f, 1.0000000000f, -0.0000000000f, 0.9896513820f, -0.1434926242f,
- 0.9588197470f, -0.2840153575f, 0.9081431627f, -0.4186597466f, 0.8386705518f, -0.5446390510f, 0.7518398166f, -0.6593458056f,
- 0.6494480371f, -0.7604059577f, 0.5336145163f, -0.8457278013f, 0.4067366421f, -0.9135454297f, 0.2714404464f, -0.9624552131f,
- 0.1305261850f, -0.9914448857f, -0.0130895954f, -0.9999143481f, -0.1564344615f, -0.9876883626f, -0.2965415716f, -0.9550199509f,
- -0.4305110872f, -0.9025852680f, -0.5555702448f, -0.8314695954f, -0.6691306233f, -0.7431448102f, -0.7688418031f, -0.6394389868f,
- -0.8526401520f, -0.5224985480f, -0.9187912345f, -0.3947438598f, -0.9659258127f, -0.2588190436f, -0.9930684566f, -0.1175373942f,
- -0.9996573329f, 0.0261769481f, -0.9855560660f, 0.1693495065f, -0.9510565400f, 0.3090170026f, -0.8968727589f, 0.4422886968f,
- -0.8241261840f, 0.5664062500f, -0.7343224883f, 0.6788007617f, -0.6293203831f, 0.7771459818f, -0.5112931132f, 0.8594064116f,
- 1.0000000000f, -0.0000000000f, 0.9876883626f, -0.1564344615f, 0.9510565400f, -0.3090170026f, 0.8910065293f, -0.4539904892f,
- 0.8090170026f, -0.5877852440f, 0.7071067691f, -0.7071067691f, 0.5877852440f, -0.8090170026f, 0.4539904892f, -0.8910065293f,
- 0.3090170026f, -0.9510565400f, 0.1564344615f, -0.9876883626f, -0.0000000000f, -1.0000000000f, -0.1564344615f, -0.9876883626f,
- -0.3090170026f, -0.9510565400f, -0.4539904892f, -0.8910065293f, -0.5877852440f, -0.8090170026f, -0.7071067691f, -0.7071067691f,
- -0.8090170026f, -0.5877852440f, -0.8910065293f, -0.4539904892f, -0.9510565400f, -0.3090170026f, -0.9876883626f, -0.1564344615f,
- -1.0000000000f, 0.0000000000f, -0.9876883626f, 0.1564344615f, -0.9510565400f, 0.3090170026f, -0.8910065293f, 0.4539904892f,
- -0.8090170026f, 0.5877852440f, -0.7071067691f, 0.7071067691f, -0.5877852440f, 0.8090170026f, -0.4539904892f, 0.8910065293f,
- -0.3090170026f, 0.9510565400f, -0.1564344615f, 0.9876883626f, 1.0000000000f, -0.0000000000f, 0.9855560660f, -0.1693495065f,
- 0.9426414967f, -0.3338068724f, 0.8724960089f, -0.4886212349f, 0.7771459818f, -0.6293203831f, 0.6593458056f, -0.7518398166f,
- 0.5224985480f, -0.8526401520f, 0.3705574274f, -0.9288095236f, 0.2079116851f, -0.9781476259f, 0.0392598175f, -0.9992290139f,
- -0.1305261850f, -0.9914448857f, -0.2965415716f, -0.9550199509f, -0.4539904892f, -0.8910065293f, -0.5983245969f, -0.8012537956f,
- -0.7253744006f, -0.6883545518f, -0.8314695954f, -0.5555702448f, -0.9135454297f, -0.4067366421f, -0.9692308903f, -0.2461532950f,
- -0.9969173074f, -0.0784590989f, -0.9958049059f, 0.0915016159f, -0.9659258127f, 0.2588190436f, -0.9081431627f, 0.4186597466f,
- -0.8241261840f, 0.5664062500f, -0.7163019180f, 0.6977904439f, -0.5877852440f, 0.8090170026f, -0.4422886968f, 0.8968727589f,
- -0.2840153575f, 0.9588197470f, -0.1175373942f, 0.9930684566f, 0.0523359552f, 0.9986295104f, 0.2206974328f, 0.9753423333f,
- 1.0000000000f, -0.0000000000f, 0.9832549095f, -0.1822355241f, 0.9335803986f, -0.3583679497f, 0.8526401520f, -0.5224985480f,
- 0.7431448102f, -0.6691306233f, 0.6087614298f, -0.7933533192f, 0.4539904892f, -0.8910065293f, 0.2840153575f, -0.9588197470f,
- 0.1045284644f, -0.9945219159f, -0.0784590989f, -0.9969173074f, -0.2588190436f, -0.9659258127f, -0.4305110872f, -0.9025852680f,
- -0.5877852440f, -0.8090170026f, -0.7253744006f, -0.6883545518f, -0.8386705518f, -0.5446390510f, -0.9238795042f, -0.3826834261f,
- -0.9781476259f, -0.2079116851f, -0.9996573329f, -0.0261769481f, -0.9876883626f, 0.1564344615f, -0.9426414967f, 0.3338068724f,
- -0.8660253882f, 0.5000000000f, -0.7604059577f, 0.6494480371f, -0.6293203831f, 0.7771459818f, -0.4771587551f, 0.8788171411f,
- -0.3090170026f, 0.9510565400f, -0.1305261850f, 0.9914448857f, 0.0523359552f, 0.9986295104f, 0.2334453613f, 0.9723699093f,
- 0.4067366421f, 0.9135454297f, 0.5664062500f, 0.8241261840f, 1.0000000000f, -0.0000000000f, 0.9807852507f, -0.1950903237f,
- 0.9238795042f, -0.3826834261f, 0.8314695954f, -0.5555702448f, 0.7071067691f, -0.7071067691f, 0.5555702448f, -0.8314695954f,
- 0.3826834261f, -0.9238795042f, 0.1950903237f, -0.9807852507f, -0.0000000000f, -1.0000000000f, -0.1950903237f, -0.9807852507f,
- -0.3826834261f, -0.9238795042f, -0.5555702448f, -0.8314695954f, -0.7071067691f, -0.7071067691f, -0.8314695954f, -0.5555702448f,
- -0.9238795042f, -0.3826834261f, -0.9807852507f, -0.1950903237f, -1.0000000000f, 0.0000000000f, -0.9807852507f, 0.1950903237f,
- -0.9238795042f, 0.3826834261f, -0.8314695954f, 0.5555702448f, -0.7071067691f, 0.7071067691f, -0.5555702448f, 0.8314695954f,
- -0.3826834261f, 0.9238795042f, -0.1950903237f, 0.9807852507f, 0.0000000000f, 1.0000000000f, 0.1950903237f, 0.9807852507f,
- 0.3826834261f, 0.9238795042f, 0.5555702448f, 0.8314695954f, 0.7071067691f, 0.7071067691f, 0.8314695954f, 0.5555702448f,
- 1.0000000000f, -0.0000000000f, 0.9999786019f, -0.0065449378f, 0.9999143481f, -0.0130895954f, 0.9998072386f, -0.0196336918f,
- 0.9996573329f, -0.0261769481f, 0.9994645715f, -0.0327190831f, 0.9992290139f, -0.0392598175f, 0.9989506602f, -0.0457988679f,
- 0.9986295104f, -0.0523359552f, 0.9982656240f, -0.0588708036f, 0.9978589416f, -0.0654031262f, 0.9974094629f, -0.0719326511f,
- 0.9969173074f, -0.0784590989f, 0.9963824749f, -0.0849821791f, 0.9958049059f, -0.0915016159f, 0.9951847196f, -0.0980171412f,
- 0.9945219159f, -0.1045284644f, 0.9938164353f, -0.1110353097f, 0.9930684566f, -0.1175373942f, 0.9922779202f, -0.1240344495f,
- 0.9914448857f, -0.1305261850f, 0.9905693531f, -0.1370123476f, 0.9896513820f, -0.1434926242f, 0.9886910319f, -0.1499667615f,
- 0.9876883626f, -0.1564344615f, 0.9866433144f, -0.1628954709f, 0.9855560660f, -0.1693495065f, 0.9844265580f, -0.1757962853f,
- 0.9832549095f, -0.1822355241f, 0.9820411205f, -0.1886669695f, 1.0000000000f, -0.0000000000f, 0.9998072386f, -0.0196336918f,
- 0.9992290139f, -0.0392598175f, 0.9982656240f, -0.0588708036f, 0.9969173074f, -0.0784590989f, 0.9951847196f, -0.0980171412f,
- 0.9930684566f, -0.1175373942f, 0.9905693531f, -0.1370123476f, 0.9876883626f, -0.1564344615f, 0.9844265580f, -0.1757962853f,
- 0.9807852507f, -0.1950903237f, 0.9767658710f, -0.2143091559f, 0.9723699093f, -0.2334453613f, 0.9675990939f, -0.2524915636f,
- 0.9624552131f, -0.2714404464f, 0.9569403529f, -0.2902846634f, 0.9510565400f, -0.3090170026f, 0.9448060393f, -0.3276301920f,
- 0.9381913543f, -0.3461170495f, 0.9312149286f, -0.3644705117f, 0.9238795042f, -0.3826834261f, 0.9161879420f, -0.4007488191f,
- 0.9081431627f, -0.4186597466f, 0.8997482657f, -0.4364092350f, 0.8910065293f, -0.4539904892f, 0.8819212914f, -0.4713967443f,
- 0.8724960089f, -0.4886212349f, 0.8627343774f, -0.5056573749f, 0.8526401520f, -0.5224985480f, 0.8422172070f, -0.5391383171f,
- 1.0000000000f, -0.0000000000f, 0.9994645715f, -0.0327190831f, 0.9978589416f, -0.0654031262f, 0.9951847196f, -0.0980171412f,
- 0.9914448857f, -0.1305261850f, 0.9866433144f, -0.1628954709f, 0.9807852507f, -0.1950903237f, 0.9738769531f, -0.2270762622f,
- 0.9659258127f, -0.2588190436f, 0.9569403529f, -0.2902846634f, 0.9469301105f, -0.3214394748f, 0.9359059334f, -0.3522500396f,
- 0.9238795042f, -0.3826834261f, 0.9108638167f, -0.4127070308f, 0.8968727589f, -0.4422886968f, 0.8819212914f, -0.4713967443f,
- 0.8660253882f, -0.5000000000f, 0.8492021561f, -0.5280678272f, 0.8314695954f, -0.5555702448f, 0.8128466606f, -0.5824776888f,
- 0.7933533192f, -0.6087614298f, 0.7730104327f, -0.6343932748f, 0.7518398166f, -0.6593458056f, 0.7298640609f, -0.6835923195f,
- 0.7071067691f, -0.7071067691f, 0.6835923195f, -0.7298640609f, 0.6593458056f, -0.7518398166f, 0.6343932748f, -0.7730104327f,
- 0.6087614298f, -0.7933533192f, 0.5824776888f, -0.8128466606f, 1.0000000000f, -0.0000000000f, 0.9989506602f, -0.0457988679f,
- 0.9958049059f, -0.0915016159f, 0.9905693531f, -0.1370123476f, 0.9832549095f, -0.1822355241f, 0.9738769531f, -0.2270762622f,
- 0.9624552131f, -0.2714404464f, 0.9490136504f, -0.3152349889f, 0.9335803986f, -0.3583679497f, 0.9161879420f, -0.4007488191f,
- 0.8968727589f, -0.4422886968f, 0.8756753206f, -0.4829003513f, 0.8526401520f, -0.5224985480f, 0.8278156519f, -0.5610002279f,
- 0.8012537956f, -0.5983245969f, 0.7730104327f, -0.6343932748f, 0.7431448102f, -0.6691306233f, 0.7117196321f, -0.7024636865f,
- 0.6788007617f, -0.7343224883f, 0.6444573402f, -0.7646402717f, 0.6087614298f, -0.7933533192f, 0.5717879534f, -0.8204014301f,
- 0.5336145163f, -0.8457278013f, 0.4943211973f, -0.8692793250f, 0.4539904892f, -0.8910065293f, 0.4127070308f, -0.9108638167f,
- 0.3705574274f, -0.9288095236f, 0.3276301920f, -0.9448060393f, 0.2840153575f, -0.9588197470f, 0.2398044616f, -0.9708212018f,
- 1.0000000000f, -0.0000000000f, 0.9982656240f, -0.0588708036f, 0.9930684566f, -0.1175373942f, 0.9844265580f, -0.1757962853f,
- 0.9723699093f, -0.2334453613f, 0.9569403529f, -0.2902846634f, 0.9381913543f, -0.3461170495f, 0.9161879420f, -0.4007488191f,
- 0.8910065293f, -0.4539904892f, 0.8627343774f, -0.5056573749f, 0.8314695954f, -0.5555702448f, 0.7973206639f, -0.6035559177f,
- 0.7604059577f, -0.6494480371f, 0.7208535671f, -0.6930873394f, 0.6788007617f, -0.7343224883f, 0.6343932748f, -0.7730104327f,
- 0.5877852440f, -0.8090170026f, 0.5391383171f, -0.8422172070f, 0.4886212349f, -0.8724960089f, 0.4364092350f, -0.8997482657f,
- 0.3826834261f, -0.9238795042f, 0.3276301920f, -0.9448060393f, 0.2714404464f, -0.9624552131f, 0.2143091559f, -0.9767658710f,
- 0.1564344615f, -0.9876883626f, 0.0980171412f, -0.9951847196f, 0.0392598175f, -0.9992290139f, -0.0196336918f, -0.9998072386f,
- -0.0784590989f, -0.9969173074f, -0.1370123476f, -0.9905693531f, 1.0000000000f, -0.0000000000f, 0.9974094629f, -0.0719326511f,
- 0.9896513820f, -0.1434926242f, 0.9767658710f, -0.2143091559f, 0.9588197470f, -0.2840153575f, 0.9359059334f, -0.3522500396f,
- 0.9081431627f, -0.4186597466f, 0.8756753206f, -0.4829003513f, 0.8386705518f, -0.5446390510f, 0.7973206639f, -0.6035559177f,
- 0.7518398166f, -0.6593458056f, 0.7024636865f, -0.7117196321f, 0.6494480371f, -0.7604059577f, 0.5930676460f, -0.8051526546f,
- 0.5336145163f, -0.8457278013f, 0.4713967443f, -0.8819212914f, 0.4067366421f, -0.9135454297f, 0.3399692476f, -0.9404365420f,
- 0.2714404464f, -0.9624552131f, 0.2015053183f, -0.9794874191f, 0.1305261850f, -0.9914448857f, 0.0588708036f, -0.9982656240f,
- -0.0130895954f, -0.9999143481f, -0.0849821791f, -0.9963824749f, -0.1564344615f, -0.9876883626f, -0.2270762622f, -0.9738769531f,
- -0.2965415716f, -0.9550199509f, -0.3644705117f, -0.9312149286f, -0.4305110872f, -0.9025852680f, -0.4943211973f, -0.8692793250f,
- 1.0000000000f, -0.0000000000f, 0.9963824749f, -0.0849821791f, 0.9855560660f, -0.1693495065f, 0.9675990939f, -0.2524915636f,
- 0.9426414967f, -0.3338068724f, 0.9108638167f, -0.4127070308f, 0.8724960089f, -0.4886212349f, 0.8278156519f, -0.5610002279f,
- 0.7771459818f, -0.6293203831f, 0.7208535671f, -0.6930873394f, 0.6593458056f, -0.7518398166f, 0.5930676460f, -0.8051526546f,
- 0.5224985480f, -0.8526401520f, 0.4481492043f, -0.8939588070f, 0.3705574274f, -0.9288095236f, 0.2902846634f, -0.9569403529f,
- 0.2079116851f, -0.9781476259f, 0.1240344495f, -0.9922779202f, 0.0392598175f, -0.9992290139f, -0.0457988679f, -0.9989506602f,
- -0.1305261850f, -0.9914448857f, -0.2143091559f, -0.9767658710f, -0.2965415716f, -0.9550199509f, -0.3766284883f, -0.9263643622f,
- -0.4539904892f, -0.8910065293f, -0.5280678272f, -0.8492021561f, -0.5983245969f, -0.8012537956f, -0.6642524600f, -0.7475083470f,
- -0.7253744006f, -0.6883545518f, -0.7812481523f, -0.6242205501f, 1.0000000000f, -0.0000000000f, 0.9951847196f, -0.0980171412f,
- 0.9807852507f, -0.1950903237f, 0.9569403529f, -0.2902846634f, 0.9238795042f, -0.3826834261f, 0.8819212914f, -0.4713967443f,
- 0.8314695954f, -0.5555702448f, 0.7730104327f, -0.6343932748f, 0.7071067691f, -0.7071067691f, 0.6343932748f, -0.7730104327f,
- 0.5555702448f, -0.8314695954f, 0.4713967443f, -0.8819212914f, 0.3826834261f, -0.9238795042f, 0.2902846634f, -0.9569403529f,
- 0.1950903237f, -0.9807852507f, 0.0980171412f, -0.9951847196f, -0.0000000000f, -1.0000000000f, -0.0980171412f, -0.9951847196f,
- -0.1950903237f, -0.9807852507f, -0.2902846634f, -0.9569403529f, -0.3826834261f, -0.9238795042f, -0.4713967443f, -0.8819212914f,
- -0.5555702448f, -0.8314695954f, -0.6343932748f, -0.7730104327f, -0.7071067691f, -0.7071067691f, -0.7730104327f, -0.6343932748f,
- -0.8314695954f, -0.5555702448f, -0.8819212914f, -0.4713967443f, -0.9238795042f, -0.3826834261f, -0.9569403529f, -0.2902846634f,
- 1.0000000000f, -0.0000000000f, 0.9938164353f, -0.1110353097f, 0.9753423333f, -0.2206974328f, 0.9448060393f, -0.3276301920f,
- 0.9025852680f, -0.4305110872f, 0.8492021561f, -0.5280678272f, 0.7853169441f, -0.6190939546f, 0.7117196321f, -0.7024636865f,
- 0.6293203831f, -0.7771459818f, 0.5391383171f, -0.8422172070f, 0.4422886968f, -0.8968727589f, 0.3399692476f, -0.9404365420f,
- 0.2334453613f, -0.9723699093f, 0.1240344495f, -0.9922779202f, 0.0130895954f, -0.9999143481f, -0.0980171412f, -0.9951847196f,
- -0.2079116851f, -0.9781476259f, -0.3152349889f, -0.9490136504f, -0.4186597466f, -0.9081431627f, -0.5169069171f, -0.8560416102f,
- -0.6087614298f, -0.7933533192f, -0.6930873394f, -0.7208535671f, -0.7688418031f, -0.6394389868f, -0.8350879550f, -0.5501164198f,
- -0.8910065293f, -0.4539904892f, -0.9359059334f, -0.3522500396f, -0.9692308903f, -0.2461532950f, -0.9905693531f, -0.1370123476f,
- -0.9996573329f, -0.0261769481f, -0.9963824749f, 0.0849821791f, 1.0000000000f, -0.0000000000f, 0.9922779202f, -0.1240344495f,
- 0.9692308903f, -0.2461532950f, 0.9312149286f, -0.3644705117f, 0.8788171411f, -0.4771587551f, 0.8128466606f, -0.5824776888f,
- 0.7343224883f, -0.6788007617f, 0.6444573402f, -0.7646402717f, 0.5446390510f, -0.8386705518f, 0.4364092350f, -0.8997482657f,
- 0.3214394748f, -0.9469301105f, 0.2015053183f, -0.9794874191f, 0.0784590989f, -0.9969173074f, -0.0457988679f, -0.9989506602f,
- -0.1693495065f, -0.9855560660f, -0.2902846634f, -0.9569403529f, -0.4067366421f, -0.9135454297f, -0.5169069171f, -0.8560416102f,
- -0.6190939546f, -0.7853169441f, -0.7117196321f, -0.7024636865f, -0.7933533192f, -0.6087614298f, -0.8627343774f, -0.5056573749f,
- -0.9187912345f, -0.3947438598f, -0.9606580734f, -0.2777338326f, -0.9876883626f, -0.1564344615f, -0.9994645715f, -0.0327190831f,
- -0.9958049059f, 0.0915016159f, -0.9767658710f, 0.2143091559f, -0.9426414967f, 0.3338068724f, -0.8939588070f, 0.4481492043f,
- 1.0000000000f, -0.0000000000f, 0.9905693531f, -0.1370123476f, 0.9624552131f, -0.2714404464f, 0.9161879420f, -0.4007488191f,
- 0.8526401520f, -0.5224985480f, 0.7730104327f, -0.6343932748f, 0.6788007617f, -0.7343224883f, 0.5717879534f, -0.8204014301f,
- 0.4539904892f, -0.8910065293f, 0.3276301920f, -0.9448060393f, 0.1950903237f, -0.9807852507f, 0.0588708036f, -0.9982656240f,
- -0.0784590989f, -0.9969173074f, -0.2143091559f, -0.9767658710f, -0.3461170495f, -0.9381913543f, -0.4713967443f, -0.8819212914f,
- -0.5877852440f, -0.8090170026f, -0.6930873394f, -0.7208535671f, -0.7853169441f, -0.6190939546f, -0.8627343774f, -0.5056573749f,
- -0.9238795042f, -0.3826834261f, -0.9675990939f, -0.2524915636f, -0.9930684566f, -0.1175373942f, -0.9998072386f, 0.0196336918f,
- -0.9876883626f, 0.1564344615f, -0.9569403529f, 0.2902846634f, -0.9081431627f, 0.4186597466f, -0.8422172070f, 0.5391383171f,
- -0.7604059577f, 0.6494480371f, -0.6642524600f, 0.7475083470f, 1.0000000000f, -0.0000000000f, 0.9886910319f, -0.1499667615f,
- 0.9550199509f, -0.2965415716f, 0.8997482657f, -0.4364092350f, 0.8241261840f, -0.5664062500f, 0.7298640609f, -0.6835923195f,
- 0.6190939546f, -0.7853169441f, 0.4943211973f, -0.8692793250f, 0.3583679497f, -0.9335803986f, 0.2143091559f, -0.9767658710f,
- 0.0654031262f, -0.9978589416f, -0.0849821791f, -0.9963824749f, -0.2334453613f, -0.9723699093f, -0.3766284883f, -0.9263643622f,
- -0.5112931132f, -0.8594064116f, -0.6343932748f, -0.7730104327f, -0.7431448102f, -0.6691306233f, -0.8350879550f, -0.5501164198f,
- -0.9081431627f, -0.4186597466f, -0.9606580734f, -0.2777338326f, -0.9914448857f, -0.1305261850f, -0.9998072386f, 0.0196336918f,
- -0.9855560660f, 0.1693495065f, -0.9490136504f, 0.3152349889f, -0.8910065293f, 0.4539904892f, -0.8128466606f, 0.5824776888f,
- -0.7163019180f, 0.6977904439f, -0.6035559177f, 0.7973206639f, -0.4771587551f, 0.8788171411f, -0.3399692476f, 0.9404365420f,
- 1.0000000000f, -0.0000000000f, 0.9866433144f, -0.1628954709f, 0.9469301105f, -0.3214394748f, 0.8819212914f, -0.4713967443f,
- 0.7933533192f, -0.6087614298f, 0.6835923195f, -0.7298640609f, 0.5555702448f, -0.8314695954f, 0.4127070308f, -0.9108638167f,
- 0.2588190436f, -0.9659258127f, 0.0980171412f, -0.9951847196f, -0.0654031262f, -0.9978589416f, -0.2270762622f, -0.9738769531f,
- -0.3826834261f, -0.9238795042f, -0.5280678272f, -0.8492021561f, -0.6593458056f, -0.7518398166f, -0.7730104327f, -0.6343932748f,
- -0.8660253882f, -0.5000000000f, -0.9359059334f, -0.3522500396f, -0.9807852507f, -0.1950903237f, -0.9994645715f, -0.0327190831f,
- -0.9914448857f, 0.1305261850f, -0.9569403529f, 0.2902846634f, -0.8968727589f, 0.4422886968f, -0.8128466606f, 0.5824776888f,
- -0.7071067691f, 0.7071067691f, -0.5824776888f, 0.8128466606f, -0.4422886968f, 0.8968727589f, -0.2902846634f, 0.9569403529f,
- -0.1305261850f, 0.9914448857f, 0.0327190831f, 0.9994645715f, 1.0000000000f, -0.0000000000f, 0.9844265580f, -0.1757962853f,
- 0.9381913543f, -0.3461170495f, 0.8627343774f, -0.5056573749f, 0.7604059577f, -0.6494480371f, 0.6343932748f, -0.7730104327f,
- 0.4886212349f, -0.8724960089f, 0.3276301920f, -0.9448060393f, 0.1564344615f, -0.9876883626f, -0.0196336918f, -0.9998072386f,
- -0.1950903237f, -0.9807852507f, -0.3644705117f, -0.9312149286f, -0.5224985480f, -0.8526401520f, -0.6642524600f, -0.7475083470f,
- -0.7853169441f, -0.6190939546f, -0.8819212914f, -0.4713967443f, -0.9510565400f, -0.3090170026f, -0.9905693531f, -0.1370123476f,
- -0.9992290139f, 0.0392598175f, -0.9767658710f, 0.2143091559f, -0.9238795042f, 0.3826834261f, -0.8422172070f, 0.5391383171f,
- -0.7343224883f, 0.6788007617f, -0.6035559177f, 0.7973206639f, -0.4539904892f, 0.8910065293f, -0.2902846634f, 0.9569403529f,
- -0.1175373942f, 0.9930684566f, 0.0588708036f, 0.9982656240f, 0.2334453613f, 0.9723699093f, 0.4007488191f, 0.9161879420f,
- 1.0000000000f, -0.0000000000f, 0.9820411205f, -0.1886669695f, 0.9288095236f, -0.3705574274f, 0.8422172070f, -0.5391383171f,
- 0.7253744006f, -0.6883545518f, 0.5824776888f, -0.8128466606f, 0.4186597466f, -0.9081431627f, 0.2398044616f, -0.9708212018f,
- 0.0523359552f, -0.9986295104f, -0.1370123476f, -0.9905693531f, -0.3214394748f, -0.9469301105f, -0.4943211973f, -0.8692793250f,
- -0.6494480371f, -0.7604059577f, -0.7812481523f, -0.6242205501f, -0.8849876523f, -0.4656145275f, -0.9569403529f, -0.2902846634f,
- -0.9945219159f, -0.1045284644f, -0.9963824749f, 0.0849821791f, -0.9624552131f, 0.2714404464f, -0.8939588070f, 0.4481492043f,
- -0.7933533192f, 0.6087614298f, -0.6642524600f, 0.7475083470f, -0.5112931132f, 0.8594064116f, -0.3399692476f, 0.9404365420f,
- -0.1564344615f, 0.9876883626f, 0.0327190831f, 0.9994645715f, 0.2206974328f, 0.9753423333f, 0.4007488191f, 0.9161879420f,
- 0.5664062500f, 0.8241261840f, 0.7117196321f, 0.7024636865f, 1.0000000000f, -0.0000000000f, 0.9794874191f, -0.2015053183f,
- 0.9187912345f, -0.3947438598f, 0.8204014301f, -0.5717879534f, 0.6883545518f, -0.7253744006f, 0.5280678272f, -0.8492021561f,
- 0.3461170495f, -0.9381913543f, 0.1499667615f, -0.9886910319f, -0.0523359552f, -0.9986295104f, -0.2524915636f, -0.9675990939f,
- -0.4422886968f, -0.8968727589f, -0.6139408350f, -0.7893520594f, -0.7604059577f, -0.6494480371f, -0.8756753206f, -0.4829003513f,
- -0.9550199509f, -0.2965415716f, -0.9951847196f, -0.0980171412f, -0.9945219159f, 0.1045284644f, -0.9530586600f, 0.3027857840f,
- -0.8724960089f, 0.4886212349f, -0.7561390996f, 0.6544109583f, -0.6087614298f, 0.7933533192f, -0.4364092350f, 0.8997482657f,
- -0.2461532950f, 0.9692308903f, -0.0457988679f, 0.9989506602f, 0.1564344615f, 0.9876883626f, 0.3522500396f, 0.9359059334f,
- 0.5336145163f, 0.8457278013f, 0.6930873394f, 0.7208535671f, 0.8241261840f, 0.5664062500f, 0.9213551283f, 0.3887219727f
-};
-
-
/* HVQ */
const Word16 hvq_thr_adj_fx[5] = { 23170, 16384, 8192, 16384, 23170 }; /* Q15 */
@@ -21902,58 +19303,6 @@ const Word16 cu4_fx[6][3] = /*Q13*/
const Word16 h_high_fx[5] = { -410, -3572, 25602, -3572, -410 };//Q15
-const float sincos_t_rad3[T_SIN_PI_2+1] =
-{
- 0.000000000000000f, 0.004090604026235f, 0.008181139603937f, 0.012271538285720f, 0.016361731626487f, 0.020451651184577f, 0.024541228522912f, 0.028630395210139f,
- 0.032719082821776f, 0.036807222941359f, 0.040894747161583f, 0.044981587085452f, 0.049067674327418f, 0.053152940514528f, 0.057237317287569f, 0.061320736302209f,
- 0.065403129230143f, 0.069484427760237f, 0.073564563599667f, 0.077643468475068f, 0.081721074133668f, 0.085797312344440f, 0.089872114899235f, 0.093945413613929f,
- 0.098017140329561f, 0.102087226913474f, 0.106155605260457f, 0.110222207293883f, 0.114286964966846f, 0.118349810263305f, 0.122410675199216f, 0.126469491823675f,
- 0.130526192220052f, 0.134580708507126f, 0.138632972840227f, 0.142682917412363f, 0.146730474455362f, 0.150775576241001f, 0.154818155082141f, 0.158858143333861f,
- 0.162895473394589f, 0.166930077707230f, 0.170961888760301f, 0.174990839089060f, 0.179016861276633f, 0.183039887955141f, 0.187059851806832f, 0.191076685565203f,
- 0.195090322016128f, 0.199100693998982f, 0.203107734407763f, 0.207111376192219f, 0.211111552358965f, 0.215108195972610f, 0.219101240156870f, 0.223090618095693f,
- 0.227076263034373f, 0.231058108280671f, 0.235036087205927f, 0.239010133246176f, 0.242980179903264f, 0.246946160745958f, 0.250908009411060f, 0.254865659604515f,
- 0.258819045102521f, 0.262768099752639f, 0.266712757474898f, 0.270652952262902f, 0.274588618184932f, 0.278519689385053f, 0.282446100084213f, 0.286367784581343f,
- 0.290284677254462f, 0.294196712561769f, 0.298103825042740f, 0.302005949319228f, 0.305903020096553f, 0.309794972164597f, 0.313681740398891f, 0.317563259761712f,
- 0.321439465303162f, 0.325310292162263f, 0.329175675568039f, 0.333035550840599f, 0.336889853392220f, 0.340738518728429f, 0.344581482449080f, 0.348418680249435f,
- 0.352250047921233f, 0.356075521353776f, 0.359895036534988f, 0.363708529552498f, 0.367515936594704f, 0.371317193951837f, 0.375112238017038f, 0.378901005287410f,
- 0.382683432365090f, 0.386459455958303f, 0.390229012882428f, 0.393992040061048f, 0.397748474527011f, 0.401498253423481f, 0.405241314004990f, 0.408977593638489f,
- 0.412707029804395f, 0.416429560097637f, 0.420145122228702f, 0.423853654024676f, 0.427555093430282f, 0.431249378508924f, 0.434936447443717f, 0.438616238538528f,
- 0.442288690219001f, 0.445953741033595f, 0.449611329654607f, 0.453261394879198f, 0.456903875630421f, 0.460538710958240f, 0.464165840040552f, 0.467785202184201f,
- 0.471396736825998f, 0.475000383533732f, 0.478596082007181f, 0.482183772079123f, 0.485763393716340f, 0.489334887020625f, 0.492898192229784f, 0.496453249718633f,
- 0.500000000000000f, 0.503538383725718f, 0.507068341687617f, 0.510589814818519f, 0.514102744193222f, 0.517607071029487f, 0.521102736689023f, 0.524589682678469f,
- 0.528067850650368f, 0.531537182404149f, 0.534997619887097f, 0.538449105195327f, 0.541891580574752f, 0.545324988422046f, 0.548749271285616f, 0.552164371866554f,
- 0.555570233019602f, 0.558966797754107f, 0.562354009234973f, 0.565731810783613f, 0.569100145878898f, 0.572458958158102f, 0.575808191417845f, 0.579147789615035f,
- 0.582477696867802f, 0.585797857456439f, 0.589108215824328f, 0.592408716578875f, 0.595699304492433f, 0.598979924503229f, 0.602250521716282f, 0.605511041404326f,
- 0.608761429008721f, 0.612001630140370f, 0.615231590580627f, 0.618451256282204f, 0.621660573370077f, 0.624859488142386f, 0.628047947071334f, 0.631225896804083f,
- 0.634393284163645f, 0.637550056149777f, 0.640696159939861f, 0.643831542889791f, 0.646956152534857f, 0.650069936590618f, 0.653172842953777f, 0.656264819703058f,
- 0.659345815100069f, 0.662415777590172f, 0.665474655803342f, 0.668522398555031f, 0.671558954847018f, 0.674584273868271f, 0.677598304995789f, 0.680600997795453f,
- 0.683592302022871f, 0.686572167624217f, 0.689540544737067f, 0.692497383691237f, 0.695442635009612f, 0.698376249408973f, 0.701298177800824f, 0.704208371292213f,
- 0.707106781186547f, 0.709993358984412f, 0.712868056384380f, 0.715730825283819f, 0.718581617779698f, 0.721420386169390f, 0.724247082951467f, 0.727061660826497f,
- 0.729864072697836f, 0.732654271672413f, 0.735432211061519f, 0.738197844381584f, 0.740951125354959f, 0.743692007910687f, 0.746420446185274f, 0.749136394523459f,
- 0.751839807478977f, 0.754530639815318f, 0.757208846506485f, 0.759874382737746f, 0.762527203906388f, 0.765167265622459f, 0.767794523709512f, 0.770408934205345f,
- 0.773010453362737f, 0.775599037650177f, 0.778174643752598f, 0.780737228572094f, 0.783286749228650f, 0.785823163060853f, 0.788346427626606f, 0.790856500703845f,
- 0.793353340291235f, 0.795836904608884f, 0.798307152099031f, 0.800764041426753f, 0.803207531480645f, 0.805637581373517f, 0.808054150443073f, 0.810457198252595f,
- 0.812846684591615f, 0.815222569476594f, 0.817584813151584f, 0.819933376088899f, 0.822268218989775f, 0.824589302785025f, 0.826896588635696f, 0.829190037933717f,
- 0.831469612302545f, 0.833735273597809f, 0.835986983907947f, 0.838224705554838f, 0.840448401094438f, 0.842658033317402f, 0.844853565249707f, 0.847034960153274f,
- 0.849202181526579f, 0.851355193105265f, 0.853493958862750f, 0.855618443010829f, 0.857728610000272f, 0.859824424521420f, 0.861905851504774f, 0.863972856121587f,
- 0.866025403784439f, 0.868063460147822f, 0.870086991108711f, 0.872095962807139f, 0.874090341626759f, 0.876070094195407f, 0.878035187385663f, 0.879985588315404f,
- 0.881921264348355f, 0.883842183094633f, 0.885748312411290f, 0.887639620402854f, 0.889516075421856f, 0.891377646069366f, 0.893224301195515f, 0.895056009900018f,
- 0.896872741532688f, 0.898674465693954f, 0.900461152235364f, 0.902232771260093f, 0.903989293123443f, 0.905730688433339f, 0.907456928050819f, 0.909167983090522f,
- 0.910863824921176f, 0.912544425166069f, 0.914209755703531f, 0.915859788667400f, 0.917494496447491f, 0.919113851690058f, 0.920717827298248f, 0.922306396432559f,
- 0.923879532511287f, 0.925437209210971f, 0.926979400466833f, 0.928506080473216f, 0.930017223684012f, 0.931512804813095f, 0.932992798834739f, 0.934457180984039f,
- 0.935905926757326f, 0.937339011912575f, 0.938756412469813f, 0.940158104711519f, 0.941544065183021f, 0.942914270692887f, 0.944268698313317f, 0.945607325380521f,
- 0.946930129495106f, 0.948237088522441f, 0.949528180593037f, 0.950803384102905f, 0.952062677713924f, 0.953306040354194f, 0.954533451218389f, 0.955744889768105f,
- 0.956940335732209f, 0.958119769107168f, 0.959283170157394f, 0.960430519415566f, 0.961561797682962f, 0.962676986029777f, 0.963776065795440f, 0.964859018588927f,
- 0.965925826289068f, 0.966976471044852f, 0.968010935275723f, 0.969029201671875f, 0.970031253194544f, 0.971017073076290f, 0.971986644821279f, 0.972939952205560f,
- 0.973876979277334f, 0.974797710357222f, 0.975702130038528f, 0.976590223187499f, 0.977461974943572f, 0.978317370719628f, 0.979156396202234f, 0.979979037351883f,
- 0.980785280403230f, 0.981575111865320f, 0.982348518521816f, 0.983105487431216f, 0.983846005927077f, 0.984570061618220f, 0.985277642388941f, 0.985968736399212f,
- 0.986643332084879f, 0.987301418157858f, 0.987942983606322f, 0.988568017694885f, 0.989176509964781f, 0.989768450234042f, 0.990343828597665f, 0.990902635427780f,
- 0.991444861373810f, 0.991970497362629f, 0.992479534598710f, 0.992971964564277f, 0.993447779019444f, 0.993906970002356f, 0.994349529829318f, 0.994775451094928f,
- 0.995184726672197f, 0.995577349712672f, 0.995953313646548f, 0.996312612182778f, 0.996655239309180f, 0.996981189292537f, 0.997290456678690f, 0.997583036292635f,
- 0.997858923238603f, 0.998118112900149f, 0.998360600940223f, 0.998586383301244f, 0.998795456205172f, 0.998987816153567f, 0.999163459927649f, 0.999322384588350f,
- 0.999464587476366f, 0.999590066212200f, 0.999698818696204f, 0.999790843108610f, 0.999866137909562f, 0.999924701839145f, 0.999966533917401f, 0.999991633444351f,
- 1.000000000000000f
-};
const Word16 sincos_t_rad3_fx[T_SIN_PI_2 + 1] =
{//Q15
0, 134, 268, 402, 536, 670, 804, 938,
@@ -23495,7 +20844,7 @@ const Coding codesTnsCoeff3WB[] =
{ 7+INDEX_SHIFT, 2818, 12 } /* 101100000010 */
};
-const int16_t nTnsCoeffCodes = sizeof(codesTnsCoeff0TCX20)/sizeof(codesTnsCoeff0TCX20[0]);
+const Word16 nTnsCoeffCodes = sizeof(codesTnsCoeff0TCX20)/sizeof(codesTnsCoeff0TCX20[0]);
const Coding * const codesTnsCoeffSWBTCX20[] = { codesTnsCoeff0TCX20, codesTnsCoeff1TCX20, codesTnsCoeff2TCX20, codesTnsCoeff3TCX20, codesTnsCoeff4TCX20, codesTnsCoeff5, codesTnsCoeff6, codesTnsCoeff7 };
const Coding * const codesTnsCoeffSWBTCX10[] = { codesTnsCoeff0TCX10, codesTnsCoeff1TCX10, codesTnsCoeff2TCX10, codesTnsCoeff3TCX10, codesTnsCoeff4TCX10, codesTnsCoeff5, codesTnsCoeff6, codesTnsCoeff7 };
diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h
index 822c996b84592db21ca8fa95c906cf7c8c3b9445..431c6b7047870558f861250a47cbd42b32b68e73 100644
--- a/lib_com/rom_com.h
+++ b/lib_com/rom_com.h
@@ -49,13 +49,13 @@
#define INTERP_EXP 0
typedef struct
{
- int32_t fin; /* input frequency */
+ Word32 fin; /* input frequency */
Word32 fin_fx; /* input frequency Q0 */
- int32_t fout; /* output frequency */
+ Word32 fout; /* output frequency */
Word32 fout_fx; /* output frequency Q0 */
- int16_t fac_num; /* numerator of resampling factor */
+ Word16 fac_num; /* numerator of resampling factor */
Word16 fac_num_fx; /* numerator of resampling factor Q0 */
Word16 fac_den_fx; /* denominator of resampling factor Q0 */
@@ -63,7 +63,7 @@ typedef struct
const Word16 *filter_fx; /* resampling filter coefficients Q14 */
- int16_t filt_len; /* number of filter coeff. */
+ Word16 filt_len; /* number of filter coeff. */
Word16 filt_len_fx; /* number of filter coeff. Q0 */
uint16_t flags; /* flags from config. table */
@@ -177,9 +177,7 @@ extern const Word16 h_high_fx[5]; // Q15
extern const Word16 sincos_t_fx[161]; // Q15
extern const Word16 sincos_t_ext_fx[]; // Q15
extern const Word32 crit_bands_fx[];
-extern const float crit_bands[]; /* Table of critical bands */
-extern const float sincos_t_ext[];
-extern const float sincos_t_rad3[];
+extern const float sincos_t_ext[]; // fft_rel dep
extern const Word16 sincos_t_rad3_fx[]; // Q15
extern const Word16 fft256_read_indexes[]; /* FFT Q0*/
extern const Word16 inter4_2_fx_Q15[]; // Q15 /* 1/4 resolution interpolation filter */
@@ -195,12 +193,6 @@ extern const Word32 crit_bands_fx[]; /* Table of criti
extern const Word16 wind_sss_fx[LEN_WIN_SSS]; // Q15 /*window for modify_sf ana*/
extern const Word16 filter5_39s320_120_fx[]; // Q15
-extern const float lag_window_8k_flt[17];
-extern const float lag_window_12k8_flt[][17];
-extern const float lag_window_16k_flt[][17];
-extern const float lag_window_25k6_flt[][17];
-extern const float lag_window_32k_flt[][17];
-extern const float lag_window_48k_flt[17];
extern const Word16 lag_window_8k[2][16]; // Q15
extern const Word16 lag_window_12k8[NUM_LAGW_STRENGTHS][2][16]; // Q15
extern const Word16 lag_window_16k[NUM_LAGW_STRENGTHS][2][16]; // Q15
@@ -273,9 +265,9 @@ extern const Word16 gp_gamma_3sfr_6b_fx[]; // Q14/Q9
extern const Word16 gp_gamma_4sfr_6b_fx[]; // Q14/Q9
-extern const int16_t E_ROM_qua_gain5b_const[];
-extern const int16_t E_ROM_qua_gain6b_const[];
-extern const int16_t E_ROM_qua_gain7b_const[];
+extern const Word16 E_ROM_qua_gain5b_const[];
+extern const Word16 E_ROM_qua_gain6b_const[];
+extern const Word16 E_ROM_qua_gain7b_const[];
extern const Word16 tbl_gain_code_tc_fx[N_GAIN_CODE_TC]; // Q13
extern const Word16 tbl_gain_code_tc_quant_mean[N_GAIN_CODE_TC - 1]; // Q13
@@ -425,8 +417,7 @@ extern const Word16 *const Predictors_fx[]; // Q15
extern const Word16 CBsizes[]; // Q0
extern const Word16 CBbits[]; // Q0
-extern const Word16 CBbits_p[]; // Q0
-extern const float vals[NO_LEADERS][MAX_NO_VALS];
+extern const Word16 CBbits_p[]; // Q0
extern const Word16 vals_fx[NO_LEADERS][MAX_NO_VALS]; // Q1
extern const Word16 no_vals[NO_LEADERS]; // Q0
@@ -438,10 +429,6 @@ extern const Word16 no_vals_ind[NO_LEADERS][MAX_NO_VALS]; // Q0
extern const Word16 C_VQ[LATTICE_DIM + 1][LATTICE_DIM + 1]; // Q0
// extern const Word16 C_VQ_fx[LATTICE_DIM + 1][LATTICE_DIM + 1];
-extern const float sigma_MSLVQ[][16];
-extern const float sigma_p[][16];
-extern const float scales[][MAX_NO_SCALES * 2];
-extern const float scales_p[][MAX_NO_SCALES * 2];
extern const Word16 BitsVQ[]; // Q0
extern const Word16 BitsVQ_p[]; // Q0
extern const UWord8 no_lead_idx[][2]; // Q0
@@ -936,13 +923,9 @@ extern const Word16 fg_inv_tbl_fx[13]; // Q0
/* functions and tables for pvq_indexing */
extern const UWord32 exactdivodd[ODD_DIV_SIZE]; // Q0
-extern const float gain_att[];
-extern const float stab_trans[];
-extern const float env_stab_tp[2][2];
-extern const float att_step[];
extern const Word16 gain_att_fx[40]; // Q15
extern const Word16 att_step_fx[4]; // Q13
-extern const int16_t gain_cb_size[];
+extern const Word16 gain_cb_size[];
extern const Word16 stab_trans_fx[]; // Q15
extern const Word16 env_stab_tp_fx[2][2]; // Q15
/*----------------------------------------------------------------------------------*
@@ -1051,130 +1034,77 @@ extern const Word16 gsc_sfm_start[]; // Q0
extern const Word16 gsc_sfm_end[]; // Q0
extern const Word16 gsc_sfm_size[]; // Q0
-extern const float sm_table[];
-extern const Word16 sm_table_fx[]; // Q15
-extern const float mfreq_loc[];
+extern const Word16 sm_table_fx[]; // Q15
extern const Word16 mfreq_bindiv_loc[]; // Q0
-extern const float mean_gp[];
extern const Word16 mean_gp_fx[]; /*Q14*/
-extern const float dic_gp[];
-extern const Word16 dic_gp_fx[]; /*Q14*/
-extern const float Gain_mean[];
-extern const float Gain_meanHR[];
-extern const float Gain_mean_dic[];
-extern const float Gain_mean_dicHR[];
-
-extern const float YG_mean16[];
-extern const Word16 YG_mean16_fx[]; /*Q12 */
-extern const float YG_dicMR_1[];
-extern const float YG_dicMR_2[];
-extern const float YG_dicMR_3[];
-extern const float YG_dicMR_4[];
+extern const Word16 dic_gp_fx[]; /*Q14*/
+
+extern const Word16 YG_mean16_fx[]; /*Q12 */
extern const Word16 YG_dicMR_1_fx[]; /*Q12 */
extern const Word16 YG_dicMR_2_fx[]; /*Q12 */
extern const Word16 YG_dicMR_3_fx[]; /*Q12 */
extern const Word16 YG_dicMR_4_fx[]; /*Q12 */
-extern const float mean_m[];
-extern const Word16 mean_m_fx[]; /*Q12 */
-extern const float mean_gain_dic[];
+extern const Word16 mean_m_fx[]; /*Q12 */
extern const Word16 mean_gain_dic_fx[]; /*Q12 */
-extern const float YGain_mean_LR[];
-extern const Word16 YGain_mean_LR_fx[]; /* Q12 */
-extern const float YGain_dic1_LR[];
-extern const float YGain_dic2_LR[];
-extern const float YGain_dic3_LR[];
-extern const Word16 YGain_dic1_LR_fx[]; /* Q12 */
-extern const Word16 YGain_dic2_LR_fx[]; /*Q12 */
-extern const Word16 YGain_dic3_LR_fx[]; /*Q12 */
-extern const float Gain_dic2_NBHR[];
-extern const float Gain_dic3_NBHR[];
-extern const Word16 Gain_dic3_NBHR_fx[]; /*Q12 */
-extern const Word16 Gain_dic2_NBHR_fx[]; /*Q12 */
-extern const float YG_mean16HR[];
-extern const Word16 YG_mean16HR_fx[]; /* Q12 */
-extern const float YG_dicHR_1[];
-extern const Word16 YG_dicHR_1_fx[]; /* Q12 */
-extern const float YG_dicHR_2[];
-extern const Word16 YG_dicHR_2_fx[]; /* Q12 */
-extern const float YG_dicHR_3[];
-extern const Word16 YG_dicHR_3_fx[]; /* Q12 */
-extern const float YG_mean16HR_16kHz[];
+extern const Word16 YGain_mean_LR_fx[]; /* Q12 */
+extern const Word16 YGain_dic1_LR_fx[]; /* Q12 */
+extern const Word16 YGain_dic2_LR_fx[]; /*Q12 */
+extern const Word16 YGain_dic3_LR_fx[]; /*Q12 */
+extern const Word16 Gain_dic3_NBHR_fx[]; /*Q12 */
+extern const Word16 Gain_dic2_NBHR_fx[]; /*Q12 */
+extern const Word16 YG_mean16HR_fx[]; /* Q12 */
+extern const Word16 YG_dicHR_1_fx[]; /* Q12 */
+extern const Word16 YG_dicHR_2_fx[]; /* Q12 */
+extern const Word16 YG_dicHR_3_fx[]; /* Q12 */
extern const Word16 YG_mean16HR_16kHz_fx[]; /* Q12 */
-extern const float YG_dicHR_4_16kHz[];
-extern const Word16 YG_dicHR_4_16kHz_fx[]; /* Q12 */
-extern const float YG_meanL2G_16kHz[];
-extern const Word16 YG_meanL2G_16kHz_fx[]; /* Q12 */
-extern const float YG_dicL2G_16kHz[];
+extern const Word16 YG_dicHR_4_16kHz_fx[]; /* Q12 */
+extern const Word16 YG_meanL2G_16kHz_fx[]; /* Q12 */
extern const Word16 YG_dicL2G_16kHz_fx[]; /* Q12 */
extern const Word16 GSC_freq_bits[]; // Q0
extern const Word32 GSC_freq_bits_fx[]; /*Q18*/
extern const Word32 GSC_freq_bits_fx_Q18[]; /*Q18*/
extern const Word16 GSC_freq_DL0_bits[]; /* Q0 */
extern const Word16 Compl_GSC_freq_bits[]; /* Q0 */
-extern const float Gain_meanNB[];
-extern const Word16 Gain_meanNB_fx[]; /*Q12*/
-extern const float Gain_mean_dicNB[];
-extern const Word16 Gain_mean_dicNB_fx[]; /*Q12 */
-extern const float Mean_dic_NB[];
-extern const Word16 Mean_dic_NB_fx[]; /*Q12 */
-extern const float Gain_dic1_NB[];
-extern const float Gain_dic2_NB[];
-extern const float Gain_dic3_NB[];
-extern const Word16 Gain_dic1_NB_fx[]; /*Q12 */
-extern const Word16 Gain_dic2_NB_fx[]; /*Q12 */
-extern const Word16 Gain_dic3_NB_fx[]; /*Q12 */
+extern const Word16 Gain_meanNB_fx[]; /*Q12*/
+extern const Word16 Gain_mean_dicNB_fx[]; /*Q12 */
+extern const Word16 Mean_dic_NB_fx[]; /*Q12 */
+extern const Word16 Gain_dic1_NB_fx[]; /*Q12 */
+extern const Word16 Gain_dic2_NB_fx[]; /*Q12 */
+extern const Word16 Gain_dic3_NB_fx[]; /*Q12 */
/*------------------------------------------------------------------------------*
* FFT transform
*------------------------------------------------------------------------------*/
-extern const Word16 Odx_fft64[64]; // Q0
-extern const float w_fft64[32];
-extern const Word16 Ip_fft64[6]; // Q0
-extern const Word16 Odx_fft32_15[32]; // Q0
-extern const float w_fft32[16];
-extern const Word32 w_fft32_16fx[16]; // Q30
-extern const Word16 Ip_fft32[6]; // Q0
-extern const Word16 Odx_fft32_5[32]; // Q0
-extern const Word16 Odx_fft16[16]; // Q0
-extern const float w_fft16[8];
-extern const Word16 Ip_fft16[6]; // Q0
-extern const float w_fft8[8];
-extern const Word16 Ip_fft8[6]; // Q0
-extern const Word16 Idx_dortft80[80]; // Q0
-extern const Word16 Idx_dortft120[120]; // Q0
-extern const Word16 Idx_dortft160[160]; // Q0
-extern const Word16 Idx_dortft320[320]; // Q0
-extern const Word16 Idx_dortft480[480]; // Q0
-extern const Word16 Ip_fft128[10]; // Q0
-extern const float w_fft128[64];
-extern const Word32 w_fft128_16fx[64]; // Q30
-extern const Word16 Ip_fft256[10]; // Q0
-extern const float w_fft256[128];
-extern const Word16 Ip_fft512[18]; // Q0
-extern const float w_fft512[256];
+extern const Word16 Odx_fft64[64]; // Q0
+extern const Word16 Ip_fft64[6]; // Q0
+extern const Word16 Odx_fft32_15[32]; // Q0
+extern const Word32 w_fft32_16fx[16]; // Q30
+extern const Word16 Ip_fft32[6]; // Q0
+extern const Word16 Odx_fft32_5[32]; // Q0
+extern const Word16 Odx_fft16[16]; // Q0
+extern const Word16 Ip_fft16[6]; // Q0
+extern const Word16 Ip_fft8[6]; // Q0
+extern const Word16 Idx_dortft80[80]; // Q0
+extern const Word16 Idx_dortft120[120]; // Q0
+extern const Word16 Idx_dortft160[160]; // Q0
+extern const Word16 Idx_dortft320[320]; // Q0
+extern const Word16 Idx_dortft480[480]; // Q0
+extern const Word16 Ip_fft128[10]; // Q0
+extern const Word32 w_fft128_16fx[64]; // Q30
+extern const Word16 Ip_fft256[10]; // Q0
+extern const Word16 Ip_fft512[18]; // Q0
extern const Word16 w_fft512_fx_evs[256]; // Q14
-// extern const Word16 w_fft512_fx[256];
-extern const Word16 Idx_dortft40[40]; // Q0
-extern const Word16 Odx_fft8_5[8]; // Q0
-extern const Word16 ip_edct2_64[6]; // Q0
-extern const float w_edct2_64[80];
-extern const Word16 w_edct2_64_fx[80]; /*Q14 */
-extern const Word16 Idx_dortft20[20]; // Q0
-extern const Word16 Odx_fft4_5[4]; // Q0
-extern const float w_fft4[2];
-extern const Word16 Ip_fft4[6]; // Q0
-
-extern const float FFT_RotVector_32[40];
-extern const float FFT_RotVector_256[448];
-extern const float FFT_RotVector_400[760];
-extern const float FFT_RotVector_600[1140];
-extern const float FFT_RotVector_640[1240];
-extern const float FFT_RotVector_960[1860];
-
+extern const Word16 Idx_dortft40[40]; // Q0
+extern const Word16 Odx_fft8_5[8]; // Q0
+extern const Word16 ip_edct2_64[6]; // Q0
+extern const Word16 w_edct2_64_fx[80]; /*Q14 */
+extern const Word16 Idx_dortft20[20]; // Q0
+extern const Word16 Odx_fft4_5[4]; // Q0
+extern const Word16 Ip_fft4[6]; // Q0
/*----------------------------------------------------------------------------------*
* FEC for HQ core
@@ -1432,7 +1362,7 @@ extern const Word16 nTnsCoeffCodes; // Q0
extern const Coding *const codesTnsCoeffSWBTCX20[];
extern const Coding *const codesTnsCoeffSWBTCX10[];
extern const Coding *const codesTnsCoeffWBTCX20[];
-extern const int16_t nTnsCoeffTables;
+extern const Word16 nTnsCoeffTables;
extern const Coding codesTnsOrderTCX20[];
extern const Coding codesTnsOrderTCX10[];
diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h
index 4ab4bf8195b646a8a5f12035aedbfc6d361e3201..5c30ad5da6d01b2350a609285938fef00a34e265 100644
--- a/lib_com/rom_com_fx.h
+++ b/lib_com/rom_com_fx.h
@@ -40,6 +40,9 @@
#ifndef ROM_COM_FX_H
#define ROM_COM_FX_H
+
+#include "typedef.h"
+
/*------------------------------------------------------------------------------*
* FFT transform
*------------------------------------------------------------------------------*/
diff --git a/lib_com/stl.h b/lib_com/stl.h
index 77e55b8668b86fcea757e21530eda7ea030e0e71..6643f5948d80c4a7260efbc6de80b2b20a4a1aee 100644
--- a/lib_com/stl.h
+++ b/lib_com/stl.h
@@ -57,23 +57,11 @@
#ifndef _STL_H
#define _STL_H
-#define ENH_U_32_BIT_OPERATOR
-#define COMPLEX_OPERATOR
-#define CONTROL_CODE_OPS
-#define ENH_32_BIT_OPERATOR
-#define ENH_64_BIT_OPERATOR
-#define BASOP_NOGLOB
-#if defined BASOP_NOGLOB && !defined BASOP_NOGLOB_DEV_USE_GLOBALS
-#define BASOP_NOGLOB_DECLARE_LOCAL
-#endif
-
#include "options.h" /* note: needed until BASOP_NOGLOB is accepted */
#include "typedef.h"
#include "basop32.h"
-#include "count.h"
#include "wmc_auto.h"
#include "move.h"
-#include "control.h"
#include "oper_32b.h"
#include "enh1632.h"
#include "enh40.h"
diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c
index bd22e7e4259ec48ffc7a2626da5143c2fec263bc..873a7093eb5854f60af59e8863be738da3f33328 100644
--- a/lib_com/swb_bwe_com_fx.c
+++ b/lib_com/swb_bwe_com_fx.c
@@ -2202,6 +2202,97 @@ void time_envelop_shaping_fx(
L_tmp = Mult_32_16( SWB_tenv[i], tmp_ener ); /*Q(29-exp) */
tmp = round_fx( L_tmp ); /*Q(13-exp) */
+ FOR( j = 0; j < L / 4; j++ )
+ {
+#ifdef BASOP_NOGLOB
+ *pit = round_fx_sat( L_shl_sat( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */
+#else
+ *pit = round_fx( L_shl( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */
+#endif
+ move16();
+ pit++;
+ }
+ }
+ }
+
+ return;
+}
+
+void time_envelop_shaping_ivas_fx(
+ Word16 werr[], /* i/o: SHB synthesis Q_synth*/
+ Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/
+ const Word16 L, /* i : frame length */
+ Word16 *Q_synth )
+{
+ Word16 *pit;
+ Word32 Energy;
+ Word16 i, j;
+ Word16 tmp_ener, Energy_16;
+ Word64 Energy_64;
+ Word16 exp_L, exp, frac, tmp, inv_L, w_tmp, Energy_Q;
+ Word32 L_tmp;
+
+ pit = werr;
+ exp_L = norm_s( L );
+ inv_L = div_s( shl( 1, sub( 14, exp_L ) ), L ); /*Q(29-exp_L) */
+ FOR( i = 0; i < SWB_TENV; i++ )
+ {
+ Energy_64 = L_deposit_l( 0 );
+ FOR( j = 0; j < L / 4; j++ )
+ {
+ Energy_64 = W_mac0_16_16( Energy_64, *pit, *pit ); /*(2*Q_synth) */
+ pit++;
+ }
+ w_tmp = W_norm( Energy_64 );
+ Energy_64 = W_shl( Energy_64, w_tmp );
+ Energy = W_extract_h( Energy_64 ); /*2*Q_synth + w_tmp -32*/
+ Energy_Q = sub( add( shl( ( *Q_synth ), 1 ), w_tmp ), 32 );
+ Energy = Mult_32_16( Energy, inv_L ); /*Q(29-exp_L-15) -> Q(-exp_L+14+2*Q_synth+w_tmp-32) */
+ Energy_16 = 0;
+ move16();
+ /*exp = 31-(-exp_L+14 +(2*(*Q_synth)+w_tmp-32)); */
+ exp = sub( 17, sub( Energy_Q, exp_L ) );
+
+ IF( Energy != 0 )
+ {
+ exp = norm_l( Energy );
+ frac = extract_h( L_shl( Energy, exp ) );
+ /*exp = sub(exp, 30-(-exp_L+14-2+(2*(*Q_synth)+w_tmp-32))); */
+ exp = sub( exp, sub( 30, add( sub( Energy_Q, exp_L ), 14 - 2 ) ) );
+
+ tmp = div_s( 16384, frac );
+ L_tmp = L_deposit_h( tmp );
+ Energy = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp) */
+ Energy_16 = round_fx( L_shl( Energy, sub( exp, 15 ) ) ); /*Q0 */
+ }
+
+ test();
+#ifdef BASOP_NOGLOB
+ IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl_sat( SWB_tenv[i], sub( 16, exp ) ) ) )
+#else
+ IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl( SWB_tenv[i], sub( 16, exp ) ) ) )
+#endif
+ {
+ *Q_synth = add( *Q_synth, 3 );
+ move16();
+ }
+ ELSE
+ {
+ pit -= shr( L, 2 );
+ tmp_ener = 0;
+ move16();
+ exp = 0;
+ move16();
+
+ IF( Energy_16 != 0 )
+ {
+ exp = norm_s( Energy_16 );
+ tmp_ener = div_s( shl( 1, sub( 14, exp ) ), Energy_16 ); /*Q(29-exp) */
+ }
+
+ L_tmp = Mult_32_16( SWB_tenv[i], tmp_ener ); /*Q(29-exp) */
+ tmp = round_fx( L_tmp ); /*Q(13-exp) */
+
FOR( j = 0; j < L / 4; j++ )
{
#ifdef BASOP_NOGLOB
diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c
index 0535cb1c8398bf0ba28e93651dae605b447cbe7e..1f4fd180198108ce40b1c9d3e3480a79a4808681 100644
--- a/lib_com/swb_bwe_com_lr_fx.c
+++ b/lib_com/swb_bwe_com_lr_fx.c
@@ -208,7 +208,7 @@ Word16 har_est_fx(
Word16 blk_end_LEN;
Word16 *p_blk_peak_pos, *pm1_blk_peak_pos;
- Word16 *p_diff_peak_pos, *pm1_diff_peak_pos;
+ Word16 *pm1_diff_peak_pos;
Word16 blk_peak_max_idx, blk_peak_pos_max_diff, diff_peak_pos_te[30];
Word16 thr1, thr2;
@@ -387,8 +387,6 @@ Word16 har_est_fx(
blk_peak_max_idx = 0;
move16();
-
- p_diff_peak_pos = &diff_peak_pos[1];
pm1_diff_peak_pos = &diff_peak_pos[1 - 1];
FOR( i = 1; i < j; i++ )
{
@@ -410,7 +408,6 @@ Word16 har_est_fx(
temp = add( temp, 1 );
- p_diff_peak_pos++;
pm1_diff_peak_pos++;
}
blk_peak_pos_max_diff = diff_peak_pos[blk_peak_max_idx];
diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c
index 494dbebd5d0262f5d437ec2f3787954d8d4ae2bf..b7c650e9ead853566349430b1541833e026c7fa4 100644
--- a/lib_com/swb_tbe_com_fx.c
+++ b/lib_com/swb_tbe_com_fx.c
@@ -3377,7 +3377,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
/* calculate pow22 */
/* pow22=0.00001f */
tmp = sub( shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ), 31 );
- pow22 = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */
+ Word64 sum = W_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */
FOR( k = 0; k < L_FRAME16k; k++ )
{
/* White_exc16k[k] *= excNoisyEnv[k]; */
@@ -3388,14 +3388,11 @@ void GenShapedSHBExcitation_ivas_enc_fx(
/* i: White_exc16k in Q6 */
/* o: White_exc16k in (Q_bwe_exc-NOISE_QADJ) */
/* pow22 += White_exc16k[k] * White_exc16k[k]; */
-#ifdef BASOP_NOGLOB
- pow22 = L_mac0_sat( pow22, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2-NOISE_QADJ)*/
-#else
- pow22 = L_mac0( pow22, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_bwe_exc-NOISE_QADJ)*/
-#endif
+ sum = W_mac0_16_16( sum, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2-NOISE_QADJ)*/
}
- /*Q_pow22 = sub( shl(*Q_bwe_exc,1), 18 );*/
- Q_pow22 = shl( sub( Q_excTmp2, NOISE_QADJ ), 1 );
+ Q_pow22 = W_norm( sum );
+ pow22 = W_extract_h( W_shl( sum, Q_pow22 ) ); // 2*(Q_excTmp2-NOISE_QADJ)+Q_pow22-32
+ Q_pow22 = sub( add( Q_pow22, shl( sub( Q_excTmp2, NOISE_QADJ ), 1 ) ), 32 );
Scale_sig( White_exc16k, L_FRAME16k, sub( *Q_bwe_exc, Q_excTmp2 ) );
}
diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c
index 64b7defc94efdaa59c549a80bf9b6c86b9d255e1..26e29b10423f8562d2fbc0d8e60a3c66d1302e4d 100644
--- a/lib_com/tcx_utils_fx.c
+++ b/lib_com/tcx_utils_fx.c
@@ -1072,7 +1072,11 @@ void mdct_shaping(
FOR( l = 0; l < k; l++ )
{
+#ifdef BASOP_NOGLOB
+ *x = L_shl_o( Mpy_32_16_r( *x, *gains ), *gains_exp, &Overflow ); /*Qx*/
+#else
*x = L_shl( Mpy_32_16_r( *x, *gains ), *gains_exp ); /*Qx*/
+#endif
move32();
x++;
}
diff --git a/lib_com/tools.c b/lib_com/tools.c
index b358196587026ed5921906b0fbacee2467d69ee6..7810edb94f46fdf91511d68701e6439f91ae67b6 100644
--- a/lib_com/tools.c
+++ b/lib_com/tools.c
@@ -281,13 +281,18 @@ Word32 sum2_32_exp_fx(
Word16 gb /* i : guard bits */
)
{
- Word16 i, s;
+ Word16 i, s, norm;
Word64 W_tmp;
W_tmp = 0;
Word64 var_a = 0;
move64();
move64();
+
+ norm = L_norm_arr( vec, lvec );
+
+ gb = sub( gb, norm );
+
FOR( i = 0; i < lvec; i++ )
{
var_a = W_mult0_32_32( vec[i], vec[i] ); // 2x
@@ -879,15 +884,28 @@ Word16 minimum_s(
Word16 *min_val /* o : minimum value in the input vector */
)
{
+#ifdef FIX_1105_OPT_MINIMUM_SL
+ Word16 i, ind;
+#else
Word16 i, ind, tmp;
+#endif
ind = 0;
move16();
+#ifndef FIX_1105_OPT_MINIMUM_SL
tmp = vec[0];
move16();
+#endif
FOR( i = 1; i < lvec; i++ )
{
+#ifdef FIX_1105_OPT_MINIMUM_SL
+ if ( LT_16( vec[i], vec[ind] ) )
+ {
+ ind = i;
+ move16();
+ }
+#else
IF( LT_16( vec[i], tmp ) )
{
ind = i;
@@ -895,11 +913,16 @@ Word16 minimum_s(
tmp = vec[i];
move16();
}
+#endif
}
if ( min_val != NULL )
{
+#ifdef FIX_1105_OPT_MINIMUM_SL
+ *min_val = vec[ind];
+#else
*min_val = tmp;
+#endif
move16();
}
@@ -920,15 +943,28 @@ Word16 minimum_l(
)
{
Word16 i, ind;
+#ifndef FIX_1105_OPT_MINIMUM_SL
Word32 tmp;
+#endif
ind = 0;
+#ifndef FIX_1105_OPT_MINIMUM_SL
tmp = vec[0];
+#endif
move16();
+#ifndef FIX_1105_OPT_MINIMUM_SL
move32();
+#endif
FOR( i = 1; i < lvec; i++ )
{
+#ifdef FIX_1105_OPT_MINIMUM_SL
+ if ( LT_32( vec[i], vec[ind] ) )
+ {
+ ind = i;
+ move16();
+ }
+#else
IF( LT_32( vec[i], tmp ) )
{
ind = i;
@@ -936,11 +972,16 @@ Word16 minimum_l(
move16();
move32();
}
+#endif
}
if ( min_val != NULL )
{
+#ifdef FIX_1105_OPT_MINIMUM_SL
+ *min_val = vec[ind];
+#else
*min_val = tmp;
+#endif
move32();
}
diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c
index b6cb03469dc17872997098a09c96e659146892cd..746c2564afe5ebebe4c1c343159bf15e6e0cb56a 100644
--- a/lib_com/tools_fx.c
+++ b/lib_com/tools_fx.c
@@ -692,6 +692,15 @@ void set32_fx(
const Word16 N /* i : Lenght of the vector */
)
{
+#ifdef FIX_1106_SIMPLIFY_SET32FX
+ Word16 i;
+
+ FOR( i = 0; i < N; i++ )
+ {
+ y[i] = a;
+ move32();
+ }
+#else
Word16 i, tmp;
tmp = extract_l( a );
IF( EQ_32( L_deposit_l( tmp ), a ) )
@@ -710,6 +719,7 @@ void set32_fx(
move32();
}
}
+#endif
return;
}
@@ -1011,6 +1021,28 @@ void Scale_sig(
}
}
+/*-------------------------------------------------------------------*
+ * scale_sig
+ * Up/down scale a 16 bits vector
+ *-------------------------------------------------------------------*/
+void scale_sig(
+ Word16 x[], /* i/o: signal to scale Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx exp */
+)
+{
+ Word16 i;
+
+ IF( exp0 != 0 )
+ {
+ FOR( i = 0; i < lg; i++ )
+ {
+ x[i] = shl( x[i], exp0 );
+ move16();
+ }
+ }
+}
+
/*---------------------------------------------------------------------*
* mean()
*
@@ -1202,6 +1234,37 @@ Word16 maximum_fx( /* o : index of the maximum value in t
return ind;
}
+Word16 maximum_exp_fx( /* o : index of the maximum value in the input vector */
+ const Word16 *vec_fx, /* i : input vector */
+ const Word16 *exp_vec, /* i : exponents of input vector */
+ const Word16 lvec_fx /* i : length of input vector */
+)
+{
+ Word16 j, ind;
+ Word16 tmp, exp;
+ ind = 0;
+ move16();
+ tmp = vec_fx[0];
+ move16();
+ exp = exp_vec[0];
+ move16();
+
+ FOR( j = 1; j < lvec_fx; j++ )
+ {
+ IF( LT_16( tmp, shr_sat( vec_fx[j], sub( exp, exp_vec[j] ) ) ) )
+ {
+ ind = j;
+ move16();
+ tmp = vec_fx[j];
+ move16();
+ exp = exp_vec[j];
+ move16();
+ }
+ }
+
+ return ind;
+}
+
/*---------------------------------------------------------------------*
* maximum_abs_16_fx()
*
diff --git a/lib_com/vlpc_2st_com_fx.c b/lib_com/vlpc_2st_com_fx.c
index 3f06d35086b2fa85187431a9bd85ebed2f0ab3df..3fcdf144d6b599ec643c6156e59d1475175697f9 100644
--- a/lib_com/vlpc_2st_com_fx.c
+++ b/lib_com/vlpc_2st_com_fx.c
@@ -6,7 +6,6 @@
#include "options.h"
#include "cnst.h"
#include "prot_fx.h"
-#include "control.h"
#include "basop_util.h"
diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c
index 7bc7bde807706e5faf6efff00a9846e8f1e59b0d..d357c03dd7d09ed3721a2fd735b48c26978e6fec 100644
--- a/lib_debug/wmc_auto.c
+++ b/lib_debug/wmc_auto.c
@@ -1,5 +1,5 @@
/*
- * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved.
+ * (C) 2024 copyright VoiceAge Corporation. All Rights Reserved.
*
* This software is protected by copyright law and by international treaties. The source code, and all of its derivations,
* is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file
@@ -18,6 +18,7 @@
#include
#include
#include
+#include
#ifndef _MSC_VER
#include
@@ -29,17 +30,18 @@
#include "options.h"
#include "wmc_auto.h"
-#include "typedef.h"
-#include "count.h"
-
-
#define WMC_TOOL_SKIP /* Skip the instrumentation of this file, if invoked by accident */
+#ifndef WMOPS
+int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_wmops() pairs when WMOPS is not activated */
+#endif
+
#ifdef WMOPS
/*-------------------------------------------------------------------*
* Complexity counting tool
*--------------------------------------------------------------------*/
+
#define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */
#define MAX_PARAMS_LENGTH 200 /* Maximum length of the function parameter string */
#define MAX_NUM_RECORDS 300 /* Initial maximum number of records -> might be increased during runtime, if needed */
@@ -48,6 +50,9 @@
#define DOUBLE_MAX 0x80000000
#define FAC ( FRAMES_PER_SECOND / 1e6 )
+#define FRAMES_PER_SECOND 50.0
+#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */
+
typedef struct
{
char label[MAX_FUNCTION_NAME_LENGTH];
@@ -73,11 +78,10 @@ typedef struct
#endif
} wmops_record;
-double ops_cnt_wmc;
-double prom_cnt_wmc;
+double ops_cnt;
double inst_cnt[NUM_INST];
-static wmops_record* wmops = NULL;
+static wmops_record *wmops = NULL;
static int num_wmops_records, max_num_wmops_records;
static int current_record;
static long update_cnt;
@@ -89,11 +93,73 @@ static long fnum_cnt_wc;
static int *wmops_caller_stack = NULL, wmops_caller_stack_index, max_wmops_caller_stack_index = 0;
static int *heap_allocation_call_tree = NULL, heap_allocation_call_tree_size = 0, heap_allocation_call_tree_max_size = 0;
+static BASIC_OP op_weight = {
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 2, 2, 1,
+ 1, 1, 1, 2, 1,
+
+ 1, 1, 1, 2, 1,
+ 1, 1, 18, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 1,
+
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 2,
+ 1, 2, 2, 2, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 3,
+ 3, 3, 3, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 3, 2,
+ 2, 6, 3, 3, 2,
+
+ 1, 32, 1
+
+/* New complex basops */
+#ifdef COMPLEX_OPERATOR
+ ,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1
+
+ ,
+ 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1
+
+#endif /* #ifdef COMPLEX_OPERATOR */
+
+#ifdef ENH_64_BIT_OPERATOR
+ /* Weights of new 64 bit basops */
+ ,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+#endif /* #ifdef ENH_64_BIT_OPERATOR */
+
+#ifdef ENH_32_BIT_OPERATOR
+ ,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+#endif /* #ifdef ENH_32_BIT_OPERATOR */
+
+#ifdef ENH_U_32_BIT_OPERATOR
+ ,
+ 1, 1, 1, 2, 2, 1, 1
+#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
+
+#ifdef CONTROL_CODE_OPS
+ ,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+#endif /* #ifdef CONTROL_CODE_OPS */
+};
+
+BASIC_OP *multiCounter = NULL;
+unsigned int currCounter = 0;
+long funcid_total_wmops_at_last_call_to_else;
+char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1];
void reset_wmops( void )
{
int i, j;
- //unsigned int *ptr;
num_wmops_records = 0;
max_num_wmops_records = MAX_NUM_RECORDS;
@@ -103,9 +169,9 @@ void reset_wmops( void )
max_cnt = 0.0;
min_cnt = DOUBLE_MAX;
start_cnt = 0.0;
- ops_cnt_wmc = 0.0;
+ ops_cnt = 0.0;
- /* allocate the list of wmops records */
+ /* allocate the list of WMOPS records */
if ( wmops == NULL )
{
wmops = (wmops_record *) malloc( max_num_wmops_records * sizeof( wmops_record ) );
@@ -117,22 +183,20 @@ void reset_wmops( void )
exit( -1 );
}
- /* allocate the BASOP WMOPS counter */
- //if ( multiCounter == NULL )
- //{
- // multiCounter = (BASIC_OP *) malloc( max_num_wmops_records * sizeof( BASIC_OP ) );
- //}
-
- //if ( multiCounter == NULL )
- //{
- // fprintf( stderr, "Error: Unable to Allocate the BASOP WMOPS counter!" );
- // exit( -1 );
- //}
+ /* allocate the list of BASOP WMOPS records */
+ if ( multiCounter == NULL )
+ {
+ multiCounter = (BASIC_OP *) malloc( max_num_wmops_records * sizeof( BASIC_OP ) );
+ }
- BASOP_init
+ if ( multiCounter == NULL )
+ {
+ fprintf( stderr, "Error: Unable to Allocate the BASOP WMOPS counter!" );
+ exit( -1 );
+ }
/* initilize the list of WMOPS records */
- /* initilize the BASOP WMOPS counters */
+ /* initilize BASOP operation counters */
for ( i = 0; i < max_num_wmops_records; i++ )
{
strcpy( &wmops[i].label[0], "\0" );
@@ -159,13 +223,8 @@ void reset_wmops( void )
wmops[i].wc_call_number = -1;
#endif
- /* clear all BASOP operation counters */
- //ptr = (unsigned int *) &multiCounter[i];
- //for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ )
- //{
- // *ptr++ = 0;
- //}
- wmops[i].LastWOper = 0;
+ /* Reset BASOP operation counter */
+ Reset_BASOP_WMOPS_counter( i );
}
/* allocate the list of wmops callers to track the sequence of function calls */
@@ -187,12 +246,6 @@ void reset_wmops( void )
wmops_caller_stack[i] = -1;
}
-#ifndef FIX_1054_IF_ELSE_CMPLX
- /* initialize auxiliary BASOP WMOPS variables */
- //call_occurred = 1;
- //funcId_where_last_call_to_else_occurred = INT_MAX;
-#endif
-
return;
}
@@ -200,7 +253,7 @@ void push_wmops_fct( const char *label, ... )
{
int new_flag;
int i, j, index_record;
- //unsigned int *ptr;
+ long tot;
va_list arg;
char func_name[MAX_FUNCTION_NAME_LENGTH] = "";
@@ -225,7 +278,7 @@ void push_wmops_fct( const char *label, ... )
}
index_record = i;
- /* Create a new record in the list */
+ /* Create a new WMOPS record in the list */
if ( new_flag )
{
if ( num_wmops_records >= max_num_wmops_records )
@@ -233,51 +286,43 @@ void push_wmops_fct( const char *label, ... )
/* There is no room for a new WMOPS record -> reallocate the list */
max_num_wmops_records += MAX_NUM_RECORDS_REALLOC_STEP;
wmops = realloc( wmops, max_num_wmops_records * sizeof( wmops_record ) );
- //multiCounter = realloc( multiCounter, max_num_wmops_records * sizeof( BASIC_OP ) );
+ multiCounter = realloc( multiCounter, max_num_wmops_records * sizeof( BASIC_OP ) );
+ }
- /* initilize newly created WMOPS records */
- for ( i = num_wmops_records; i < max_num_wmops_records; i++ )
- {
- strcpy( &wmops[i].label[0], "\0" );
- wmops[i].call_number = 0;
- wmops[i].update_cnt = 0;
- for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ )
- {
- wmops[i].call_tree[j] = -1;
- }
- wmops[i].start_selfcnt = 0.0;
- wmops[i].current_selfcnt = 0.0;
- wmops[i].max_selfcnt = 0.0;
- wmops[i].min_selfcnt = DOUBLE_MAX;
- wmops[i].tot_selfcnt = 0.0;
- wmops[i].start_cnt = 0.0;
- wmops[i].current_cnt = 0.0;
- wmops[i].max_cnt = 0.0;
- wmops[i].min_cnt = DOUBLE_MAX;
- wmops[i].tot_cnt = 0.0;
+ /* initilize the new WMOPS record */
+ strcpy( &wmops[index_record].label[0], "\0" );
+ wmops[index_record].call_number = 0;
+ wmops[index_record].update_cnt = 0;
+ for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ )
+ {
+ wmops[index_record].call_tree[j] = -1;
+ }
+ wmops[index_record].start_selfcnt = 0.0;
+ wmops[index_record].current_selfcnt = 0.0;
+ wmops[index_record].max_selfcnt = 0.0;
+ wmops[index_record].min_selfcnt = DOUBLE_MAX;
+ wmops[index_record].tot_selfcnt = 0.0;
+ wmops[index_record].start_cnt = 0.0;
+ wmops[index_record].current_cnt = 0.0;
+ wmops[index_record].max_cnt = 0.0;
+ wmops[index_record].min_cnt = DOUBLE_MAX;
+ wmops[index_record].tot_cnt = 0.0;
#ifdef WMOPS_WC_FRAME_ANALYSIS
- wmops[i].wc_cnt = 0.0;
- wmops[i].wc_selfcnt = 0.0;
- wmops[i].current_call_number = 0;
- wmops[i].wc_call_number = -1;
+ wmops[index_record].wc_cnt = 0.0;
+ wmops[index_record].wc_selfcnt = 0.0;
+ wmops[index_record].current_call_number = 0;
+ wmops[index_record].wc_call_number = -1;
#endif
- /* initialize BASOP WMOPS counters */
- //ptr = (unsigned int *) &multiCounter[i];
- //for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ )
- //{
- // *ptr++ = 0;
- //}
- wmops[i].LastWOper = 0;
- }
- }
+ /* Reset BASOP operation counter */
+ Reset_BASOP_WMOPS_counter( index_record );
strcpy( wmops[index_record].label, func_name );
num_wmops_records++;
}
- /* Push the current context info to the new record */
+ /* Update the WMOPS context info of the old record before switching to the new one */
if ( current_record >= 0 )
{
if ( wmops_caller_stack_index >= max_wmops_caller_stack_index )
@@ -288,8 +333,10 @@ void push_wmops_fct( const char *label, ... )
}
wmops_caller_stack[wmops_caller_stack_index++] = current_record;
- /* accumulate op counts */
- wmops[current_record].current_selfcnt += ops_cnt_wmc - wmops[current_record].start_selfcnt;
+ /* add the BASOP complexity to the counter and update the old WMOPS counter */
+ tot = DeltaWeightedOperation( current_record );
+ ops_cnt += tot;
+ wmops[current_record].current_selfcnt += ops_cnt - wmops[current_record].start_selfcnt;
/* update call tree */
for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ )
@@ -306,27 +353,31 @@ void push_wmops_fct( const char *label, ... )
}
}
- /* update the current context info */
+ /* Need to reset the BASOP operation counter of the 0th record in every push_wmops() */
+ /* because currCounter can never be -1 */
+ if ( current_record == -1 && index_record == 0 )
+ {
+ wmops[index_record].LastWOper = TotalWeightedOperation( index_record );
+ }
+
+ /* switch to the new record */
current_record = index_record;
- wmops[index_record].start_selfcnt = ops_cnt_wmc;
- wmops[index_record].start_cnt = ops_cnt_wmc;
+ wmops[index_record].start_selfcnt = ops_cnt;
+ wmops[index_record].start_cnt = ops_cnt;
wmops[index_record].call_number++;
#ifdef WMOPS_WC_FRAME_ANALYSIS
wmops[index_record].current_call_number++;
#endif
- /* set the ID of BASOP functions counters */
- //Set_BASOP_WMOPS_counter( index_record );
-
- BASOP_push_wmops( func_name );
+ /* set the ID of the current BASOP operations counter */
+ currCounter = index_record;
return;
}
-
void pop_wmops( void )
{
- //long tot;
+ long tot;
/* Check for underflow */
if ( current_record < 0 )
@@ -336,28 +387,33 @@ void pop_wmops( void )
}
/* add the BASOP complexity to the counter */
- //tot = DeltaWeightedOperation();
- //ops_cnt_wmc += tot;
+ tot = DeltaWeightedOperation( currCounter );
+ ops_cnt += tot;
/* update count of current record */
- wmops[current_record].current_selfcnt += ops_cnt_wmc - wmops[current_record].start_selfcnt;
- wmops[current_record].current_cnt += ops_cnt_wmc - wmops[current_record].start_cnt;
+ wmops[current_record].current_selfcnt += ops_cnt - wmops[current_record].start_selfcnt;
+ wmops[current_record].current_cnt += ops_cnt - wmops[current_record].start_cnt;
/* Get back previous context from stack */
if ( wmops_caller_stack_index > 0 )
{
current_record = wmops_caller_stack[--wmops_caller_stack_index];
- wmops[current_record].start_selfcnt = ops_cnt_wmc;
-
- /* set the ID of the previous BASOP counter */
- //Set_BASOP_WMOPS_counter( current_record );
+ wmops[current_record].start_selfcnt = ops_cnt;
}
else
{
current_record = -1;
}
- BASOP_pop_wmops();
+ /* set the ID of the previous BASOP operations counter */
+ if ( current_record == -1 )
+ {
+ currCounter = 0; /* Note: currCounter cannot be set to -1 because it's defined as unsigned int ! */
+ }
+ else
+ {
+ currCounter = current_record;
+ }
return;
}
@@ -450,12 +506,11 @@ void update_wmops( void )
wmops[i].current_call_number = 0;
#endif
- /* update the WC of all BASOP counters */
- //Set_BASOP_WMOPS_counter( i );
- //Reset_BASOP_WMOPS_counter();
+ /* reset the BASOP operations counter */
+ Reset_BASOP_WMOPS_counter( i );
}
- current_cnt = ops_cnt_wmc - start_cnt;
+ current_cnt = ops_cnt - start_cnt;
if ( current_cnt > max_cnt )
{
max_cnt = current_cnt;
@@ -478,192 +533,186 @@ void update_wmops( void )
inst_cnt[i] = 0.0;
}
- start_cnt = ops_cnt_wmc;
+ start_cnt = ops_cnt;
/* increment frame counter */
update_cnt++;
- BASOP_frame_update();
-
return;
}
void print_wmops( void )
{
- //int i, label_len, max_label_len;
+ int i, label_len, max_label_len;
- //char *sfmts = "%*s %8s %8s %7s %7s\n";
- //char *dfmts = "%*s %8.2f %8.3f %7.3f %7.3f\n";
- //char *sfmt = "%*s %8s %8s %7s %7s %7s %7s %7s\n";
- //char *dfmt = "%*s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n";
+ char *sfmts = "%*s %8s %8s %7s %7s\n";
+ char *dfmts = "%*s %8.2f %8.3f %7.3f %7.3f\n";
+ char *sfmt = "%*s %8s %8s %7s %7s %7s %7s %7s\n";
+ char *dfmt = "%*s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n";
- WMOPS_output_all_std( 0 );
- WMOPS_destroy();
- return;
+#ifdef WMOPS_WC_FRAME_ANALYSIS
+ int j;
+ char *sfmtt = "%20s %4s %15s\n";
+ char *dfmtt = "%20s %4d ";
+#endif
+
+ /* calculate maximum label length for compact prinout */
+ max_label_len = 0;
+ for ( i = 0; i < num_wmops_records; i++ )
+ {
+ label_len = strlen( wmops[i].label );
+ if ( label_len > max_label_len )
+ {
+ max_label_len = label_len;
+ }
+ }
+ max_label_len += 4;
-//#ifdef WMOPS_WC_FRAME_ANALYSIS
-// int j;
-// char *sfmtt = "%20s %4s %15s\n";
-// char *dfmtt = "%20s %4d ";
-//#endif
-
-// /* calculate maximum label length for compact prinout */
-// max_label_len = 0;
-// for ( i = 0; i < num_wmops_records; i++ )
-// {
-// label_len = strlen( wmops[i].label );
-// if ( label_len > max_label_len )
-// {
-// max_label_len = label_len;
-// }
-// }
-// max_label_len += 4;
-//
-// fprintf( stdout, "\n\n --- Complexity analysis [WMOPS] --- \n\n" );
-//
-// fprintf( stdout, "%*s %33s %23s\n", max_label_len, "", "|------ SELF ------|", "|--- CUMULATIVE ---|" );
-// fprintf( stdout, sfmt, max_label_len, " routine", " calls", " min ", " max ", " avg ", " min ", " max ", " avg " );
-// fprintf( stdout, sfmt, max_label_len, "---------------", "------", "------", "------", "------", "------", "------", "------" );
-//
-// for ( i = 0; i < num_wmops_records; i++ )
-// {
-// fprintf( stdout, dfmt, max_label_len, wmops[i].label, update_cnt == 0 ? 0 : (float) wmops[i].call_number / update_cnt,
-// wmops[i].min_selfcnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_selfcnt,
-// FAC * wmops[i].max_selfcnt,
-// wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_selfcnt / wmops[i].update_cnt,
-// wmops[i].min_cnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_cnt,
-// FAC * wmops[i].max_cnt,
-// wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_cnt / wmops[i].update_cnt );
-// }
-//
-// fprintf( stdout, sfmts, max_label_len, "---------------", "------", "------", "------", "------" );
-// fprintf( stdout, dfmts, max_label_len, "total", (float) update_cnt, update_cnt == 0 ? 0 : FAC * min_cnt, FAC * max_cnt, update_cnt == 0 ? 0 : FAC * ops_cnt_wmc / update_cnt );
-// fprintf( stdout, "\n" );
-//
-//#ifdef WMOPS_WC_FRAME_ANALYSIS
-// fprintf( stdout, "\nComplexity analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc );
-// fprintf( stdout, "%*s %8s %10s %12s\n", max_label_len, " routine", " calls", " SELF", " CUMULATIVE" );
-// fprintf( stdout, "%*s %8s %10s %10s\n", max_label_len, "---------------", "------", "------", "----------" );
-//
-// for ( i = 0; i < num_wmops_records; i++ )
-// {
-// if ( wmops[i].wc_call_number > 0 )
-// {
-// fprintf( stdout, "%*s %8d %10.3f %12.3f\n", max_label_len, wmops[i].label, wmops[i].wc_call_number, FAC * wmops[i].wc_selfcnt, FAC * wmops[i].wc_cnt );
-// }
-// }
-//
-// fprintf( stdout, "\nCall tree for the worst-case frame %ld:\n\n", fnum_cnt_wc );
-// fprintf( stdout, sfmtt, " function", "num", "called by " );
-// fprintf( stdout, sfmtt, "---------------", "---", "--------------" );
-//
-// for ( i = 0; i < num_wmops_records; i++ )
-// {
-// if ( wmops[i].wc_call_number > 0 )
-// {
-// fprintf( stdout, dfmtt, wmops[i].label, i );
-// for ( j = 0; wmops[i].call_tree[j] != -1 && j < MAX_CALL_TREE_DEPTH; j++ )
-// {
-// if ( j != 0 )
-// {
-// fprintf( stdout, ", " );
-// }
-// fprintf( stdout, "%d", wmops[i].call_tree[j] );
-// }
-// fprintf( stdout, "\n" );
-// }
-// }
-//
-// fprintf( stdout, "\n\n" );
-//
-// fprintf( stdout, "\nInstruction type analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc );
-// for ( i = 0; i < NUM_INST; i++ )
-// {
-// switch ( (enum instructions) i )
-// {
-// case _ADD:
-// fprintf( stdout, "\tAdds: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _ABS:
-// fprintf( stdout, "\tAbsolutes: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _MULT:
-// fprintf( stdout, "\tMultiplies: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _MAC:
-// fprintf( stdout, "\tMACs: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _MOVE:
-// fprintf( stdout, "\tMoves: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _STORE:
-// fprintf( stdout, "\tStores: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _LOGIC:
-// fprintf( stdout, "\tLogicals: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _SHIFT:
-// fprintf( stdout, "\tShifts: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _BRANCH:
-// fprintf( stdout, "\tBranches: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _DIV:
-// fprintf( stdout, "\tDivisions: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _SQRT:
-// fprintf( stdout, "\tSquare Root: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _TRANS:
-// fprintf( stdout, "\tTrans: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _FUNC:
-// fprintf( stdout, "\tFunc Call: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _LOOP:
-// fprintf( stdout, "\tLoop Init: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _INDIRECT:
-// fprintf( stdout, "\tIndirect Addr: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _PTR_INIT:
-// fprintf( stdout, "\tPointer Init: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _TEST:
-// fprintf( stdout, "\tExtra condit.: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _POWER:
-// fprintf( stdout, "\tExponential: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _LOG:
-// fprintf( stdout, "\tLogarithm: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// case _MISC:
-// fprintf( stdout, "\tAll other op.: %12.1f\n", inst_cnt_wc[i] );
-// break;
-// default:
-// fprintf( stdout, "\tERROR: Invalid instruction type: %d\n\n", i );
-// }
-// }
-//#endif
-//
-// /* De-allocate the list of wmops record */
-// if ( wmops != NULL )
-// {
-// free( wmops );
-// }
-//
-// /* De-allocate the list of wmops caller functions */
-// if ( wmops_caller_stack != NULL )
-// {
-// free( wmops_caller_stack );
-// }
-//
-// /* De-allocate the BASOP WMOPS counter */
-// //if ( multiCounter != NULL )
-// //{
-// // free( multiCounter );
-// //}
+ fprintf( stdout, "\n\n --- Complexity analysis [WMOPS] --- \n\n" );
+
+ fprintf( stdout, "%*s %33s %23s\n", max_label_len, "", "|------ SELF ------|", "|--- CUMULATIVE ---|" );
+ fprintf( stdout, sfmt, max_label_len, " routine", " calls", " min ", " max ", " avg ", " min ", " max ", " avg " );
+ fprintf( stdout, sfmt, max_label_len, "---------------", "------", "------", "------", "------", "------", "------", "------" );
+
+ for ( i = 0; i < num_wmops_records; i++ )
+ {
+ fprintf( stdout, dfmt, max_label_len, wmops[i].label, update_cnt == 0 ? 0 : (float) wmops[i].call_number / update_cnt,
+ wmops[i].min_selfcnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_selfcnt,
+ FAC * wmops[i].max_selfcnt,
+ wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_selfcnt / wmops[i].update_cnt,
+ wmops[i].min_cnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_cnt,
+ FAC * wmops[i].max_cnt,
+ wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_cnt / wmops[i].update_cnt );
+ }
+
+ fprintf( stdout, sfmts, max_label_len, "---------------", "------", "------", "------", "------" );
+ fprintf( stdout, dfmts, max_label_len, "total", (float) update_cnt, update_cnt == 0 ? 0 : FAC * min_cnt, FAC * max_cnt, update_cnt == 0 ? 0 : FAC * ops_cnt / update_cnt );
+ fprintf( stdout, "\n" );
+
+#ifdef WMOPS_WC_FRAME_ANALYSIS
+ fprintf( stdout, "\nComplexity analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc );
+ fprintf( stdout, "%*s %8s %10s %12s\n", max_label_len, " routine", " calls", " SELF", " CUMULATIVE" );
+ fprintf( stdout, "%*s %8s %10s %10s\n", max_label_len, "---------------", "------", "------", "----------" );
+
+ for ( i = 0; i < num_wmops_records; i++ )
+ {
+ if ( wmops[i].wc_call_number > 0 )
+ {
+ fprintf( stdout, "%*s %8d %10.3f %12.3f\n", max_label_len, wmops[i].label, wmops[i].wc_call_number, FAC * wmops[i].wc_selfcnt, FAC * wmops[i].wc_cnt );
+ }
+ }
+
+ fprintf( stdout, "\nCall tree for the worst-case frame %ld:\n\n", fnum_cnt_wc );
+ fprintf( stdout, sfmtt, " function", "num", "called by " );
+ fprintf( stdout, sfmtt, "---------------", "---", "--------------" );
+
+ for ( i = 0; i < num_wmops_records; i++ )
+ {
+ if ( wmops[i].wc_call_number > 0 )
+ {
+ fprintf( stdout, dfmtt, wmops[i].label, i );
+ for ( j = 0; wmops[i].call_tree[j] != -1 && j < MAX_CALL_TREE_DEPTH; j++ )
+ {
+ if ( j != 0 )
+ {
+ fprintf( stdout, ", " );
+ }
+ fprintf( stdout, "%d", wmops[i].call_tree[j] );
+ }
+ fprintf( stdout, "\n" );
+ }
+ }
+
+ fprintf( stdout, "\n\n" );
+
+ fprintf( stdout, "\nInstruction type analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc );
+ for ( i = 0; i < NUM_INST; i++ )
+ {
+ switch ( (enum instructions) i )
+ {
+ case _ADD:
+ fprintf( stdout, "\tAdds: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _ABS:
+ fprintf( stdout, "\tAbsolutes: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _MULT:
+ fprintf( stdout, "\tMultiplies: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _MAC:
+ fprintf( stdout, "\tMACs: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _MOVE:
+ fprintf( stdout, "\tMoves: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _STORE:
+ fprintf( stdout, "\tStores: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _LOGIC:
+ fprintf( stdout, "\tLogicals: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _SHIFT:
+ fprintf( stdout, "\tShifts: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _BRANCH:
+ fprintf( stdout, "\tBranches: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _DIV:
+ fprintf( stdout, "\tDivisions: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _SQRT:
+ fprintf( stdout, "\tSquare Root: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _TRANS:
+ fprintf( stdout, "\tTrans: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _FUNC:
+ fprintf( stdout, "\tFunc Call: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _LOOP:
+ fprintf( stdout, "\tLoop Init: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _INDIRECT:
+ fprintf( stdout, "\tIndirect Addr: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _PTR_INIT:
+ fprintf( stdout, "\tPointer Init: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _TEST:
+ fprintf( stdout, "\tExtra condit.: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _POWER:
+ fprintf( stdout, "\tExponential: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _LOG:
+ fprintf( stdout, "\tLogarithm: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ case _MISC:
+ fprintf( stdout, "\tAll other op.: %12.1f\n", inst_cnt_wc[i] );
+ break;
+ default:
+ fprintf( stdout, "\tERROR: Invalid instruction type: %d\n\n", i );
+ }
+ }
+#endif
+
+ /* De-allocate the list of wmops record */
+ if ( wmops != NULL )
+ {
+ free( wmops );
+ }
+
+ /* De-allocate the list of wmops caller functions */
+ if ( wmops_caller_stack != NULL )
+ {
+ free( wmops_caller_stack );
+ }
+
+ /* De-allocate the BASOP WMOPS counter */
+ if ( multiCounter != NULL )
+ {
+ free( multiCounter );
+ }
return;
}
@@ -703,8 +752,8 @@ void print_wmops( void )
#define MAGIC_VALUE_OOB 0x12A534F0 /* Signature value which is inserted before and after each allocated memory block, used to detect out-of-bound access */
#define MAGIC_VALUE_USED ( ~MAGIC_VALUE_OOB ) /* Value used to pre-fill allocated memory blocks, used to calculate actual memory usage */
-#define OOB_START 0x1 /* Flag indicating out-of-bounds access before memory block */
-#define OOB_END 0x2 /* Flag indicating out-of-bounds access after memory block */
+#define OOB_START 0x1 /* int indicating out-of-bounds access before memory block */
+#define OOB_END 0x2 /* int indicating out-of-bounds access after memory block */
#define ROUND_BLOCK_SIZE( n ) ( ( ( n ) + BLOCK_ROUNDING - 1 ) & ~( BLOCK_ROUNDING - 1 ) )
#define IS_CALLOC( str ) ( str[0] == 'c' )
@@ -2129,7 +2178,339 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] )
#endif /* WMOPS */
+#ifdef CONTROL_CODE_OPS
+
+int LT_16( short var1, short var2 )
+{
+ int F_ret = 0;
+
+ if ( var1 < var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].LT_16++;
+#endif
+ return F_ret;
+}
+
+int GT_16( short var1, short var2 )
+{
+ int F_ret = 0;
+
+ if ( var1 > var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].GT_16++;
+#endif
+ return F_ret;
+}
+
+int LE_16( short var1, short var2 )
+{
+ int F_ret = 0;
+
+ if ( var1 <= var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].LE_16++;
+#endif
+ return F_ret;
+}
+
+int GE_16( short var1, short var2 )
+{
+ int F_ret = 0;
+
+ if ( var1 >= var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].GE_16++;
+#endif
+ return F_ret;
+}
+
+int EQ_16( short var1, short var2 )
+{
+ int F_ret = 0;
+
+ if ( var1 == var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].EQ_16++;
+#endif
+ return F_ret;
+}
+
+int NE_16( short var1, short var2 )
+{
+ int F_ret = 0;
+
+ if ( var1 != var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].NE_16++;
+#endif
+ return F_ret;
+}
+
+int LT_32( int L_var1, int L_var2 )
+{
+ int F_ret = 0;
+
+ if ( L_var1 < L_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].LT_32++;
+#endif
+ return F_ret;
+}
+
+int GT_32( int L_var1, int L_var2 )
+{
+ int F_ret = 0;
+
+ if ( L_var1 > L_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].GT_32++;
+#endif
+ return F_ret;
+}
+
+int LE_32( int L_var1, int L_var2 )
+{
+ int F_ret = 0;
+
+ if ( L_var1 <= L_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].LE_32++;
+#endif
+ return F_ret;
+}
+
+int GE_32( int L_var1, int L_var2 )
+{
+ int F_ret = 0;
+
+ if ( L_var1 >= L_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].GE_32++;
+#endif
+ return F_ret;
+}
+
+int EQ_32( int L_var1, int L_var2 )
+{
+ int F_ret = 0;
+
+ if ( L_var1 == L_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].EQ_32++;
+#endif
+ return F_ret;
+}
+
+int NE_32( int L_var1, int L_var2 )
+{
+ int F_ret = 0;
+
+ if ( L_var1 != L_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].NE_32++;
+#endif
+ return F_ret;
+}
+
+int LT_64( long long int L64_var1, long long int L64_var2 )
+{
+ int F_ret = 0;
+
+ if ( L64_var1 < L64_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].LT_64++;
+#endif
+ return F_ret;
+}
+
+int GT_64( long long int L64_var1, long long int L64_var2 )
+{
+ int F_ret = 0;
+
+ if ( L64_var1 > L64_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].GT_64++;
+#endif
+ return F_ret;
+}
+
+int LE_64( long long int L64_var1, long long int L64_var2 )
+{
+ int F_ret = 0;
+
+ if ( L64_var1 <= L64_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].LE_64++;
+#endif
+ return F_ret;
+}
+int GE_64( long long int L64_var1, long long int L64_var2 )
+{
+ int F_ret = 0;
+
+ if ( L64_var1 >= L64_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].GE_64++;
+#endif
+ return F_ret;
+}
+
+int EQ_64( long long int L64_var1, long long int L64_var2 )
+{
+ int F_ret = 0;
+
+ if ( L64_var1 == L64_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].EQ_64++;
+#endif
+ return F_ret;
+}
+int NE_64( long long int L64_var1, long long int L64_var2 )
+{
+ int F_ret = 0;
+
+ if ( L64_var1 != L64_var2 )
+ {
+ F_ret = 1;
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].NE_64++;
+#endif
+ return F_ret;
+}
+
+#endif /* #ifdef CONTROL_CODE_OPS */
+
+#ifdef WMOPS
+
+void incrIf( const char *func_name )
+{
+ /* Technical note: If the "IF" operator comes just after an "ELSE", its counter must not be incremented */
+ /* The following auxiliary variables are used to check if the "IF" operator doesn't immediately follow an "ELSE" operator */
+ if ( ( strncmp( func_name, func_name_where_last_call_to_else_occurred, MAX_FUNCTION_NAME_LENGTH ) != 0 ) || ( TotalWeightedOperation( currCounter ) != funcid_total_wmops_at_last_call_to_else ) )
+ {
+
+ multiCounter[currCounter].If++;
+ }
+
+ func_name_where_last_call_to_else_occurred[0] = '\0';
+}
+
+void incrElse( const char *func_name )
+{
+ multiCounter[currCounter].If++;
+
+ /* Save the BASOP comeplxity in the last call of the ELSE() statement */
+ funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation( currCounter );
+
+ /* We keep track of the name of the last calling function when the ELSE macro was called */
+ strncpy( func_name_where_last_call_to_else_occurred, func_name, MAX_FUNCTION_NAME_LENGTH );
+ func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH] = '\0';
+}
+
+long TotalWeightedOperation( unsigned int CounterId )
+{
+ int i;
+ unsigned int *ptr, *ptr2;
+ long tot;
+
+ tot = 0;
+ ptr = (unsigned int *) &multiCounter[CounterId];
+ ptr2 = (unsigned int *) &op_weight;
+
+ for ( i = 0; i < (int) ( sizeof( multiCounter[CounterId] ) / sizeof( unsigned int ) ); i++ )
+ {
+ if ( *ptr == UINT_MAX )
+ {
+ printf( "\nError in BASOP complexity counters: multiCounter[%d][%d] = %d !!!\n", CounterId, i, *ptr );
+ exit( -1 );
+ }
+
+ tot += ( ( *ptr++ ) * ( *ptr2++ ) );
+ }
+
+ return ( tot );
+}
+
+long DeltaWeightedOperation( unsigned int CounterId )
+{
+ long NewWOper, delta;
+
+ NewWOper = TotalWeightedOperation( CounterId );
+
+ delta = NewWOper - wmops[CounterId].LastWOper;
+ wmops[CounterId].LastWOper = NewWOper;
+
+ return ( delta );
+}
+
+/* Resets BASOP operation counter */
+void Reset_BASOP_WMOPS_counter( unsigned int counterId )
+{
+ int i;
+ unsigned int *ptr;
+
+ /* reset the current BASOP operation counter */
+ ptr = (unsigned int *) &multiCounter[counterId];
+ for ( i = 0; i < (int) (sizeof(BASIC_OP) / sizeof(unsigned int)); i++ )
+ {
+ *ptr++ = 0;
+ }
+
+ wmops[counterId].LastWOper = 0;
+
+ return;
+}
-#ifndef WMOPS
-int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_wmops() pairs when WMOPS is not activated */
#endif
diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h
index 5f5d6d9753f98612762f47dca560f63c7b22ddd6..59bbc5bbf72f54a9ab64216be94d3c5f4ce57800 100644
--- a/lib_debug/wmc_auto.h
+++ b/lib_debug/wmc_auto.h
@@ -1,5 +1,5 @@
/*
- * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved.
+ * (C) 2024 copyright VoiceAge Corporation. All Rights Reserved.
*
* This software is protected by copyright law and by international treaties. The source code, and all of its derivations,
* is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file
@@ -30,8 +30,12 @@
#pragma GCC system_header
#endif
-#define FRAMES_PER_SECOND 50.0
-#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */
+#define ENH_32_BIT_OPERATOR
+#define ENH_64_BIT_OPERATOR
+#define ENH_U_32_BIT_OPERATOR
+#define COMPLEX_OPERATOR
+#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */
+#define WMOPS_DISABLE_FCN_CALL_PENALIZATION /* do not count the complexity of function calls */
#ifdef WMOPS
enum instructions
@@ -59,6 +63,30 @@ enum instructions
NUM_INST
};
+extern double ops_cnt;
+extern double inst_cnt[NUM_INST];
+
+/******************************************************************/
+/* NOTES: */
+/* The 'wmc_flag_' flag is global to avoid declaration in every */
+/* function and 'static' to avoid clashing with other modules */
+/* that include this header file. */
+/* */
+/* The declarations of 'wmc_flag_' and 'wops_' in this header */
+/* file prevent the addition of a 'C' file to the Project. */
+/******************************************************************/
+
+/* General Purpose Global int */
+static int wmc_flag_ = 0;
+
+#define push_wmops( ... ) push_wmops_fct( __VA_ARGS__, NULL )
+void push_wmops_fct( const char *label, ... );
+void pop_wmops( void );
+void reset_wmops( void );
+void print_wmops( void );
+void update_wmops( void );
+void update_mem( void );
+
#define _ADD_C 1
#define _ABS_C 1
#define _MULT_C 1
@@ -80,492 +108,157 @@ enum instructions
#define _LOG_C 25
#define _MISC_C 1
-#define _ADD_P 1
-#define _ABS_P 1
-#define _MULT_P 1
-#define _MAC_P 1
-#define _MOVE_P 1
-#define _STORE_P 0
-#define _LOGIC_P 1
-#define _SHIFT_P 1
-#define _BRANCH_P 2
-#define _DIV_P 2
-#define _SQRT_P 2
-#define _TRANS_P 2
-#define _FUNC_P 2 /* need to add number of arguments */
-#define _LOOP_P 1
-#define _INDIRECT_P 2
-#define _PTR_INIT_P 1
-#define _TEST_P 1
-#define _POWER_P 2
-#define _LOG_P 2
-#define _MISC_P 1
-
-#define ADD( x ) \
- { \
- { \
- ops_cnt_wmc += ( _ADD_C * ( x ) ); \
- inst_cnt[_ADD] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _ADD_P * ( x ) ); \
- } \
- } \
- } \
+#define ADD( x ) \
+ { \
+ ops_cnt += ( _ADD_C * ( x ) ); \
+ inst_cnt[_ADD] += ( x ); \
}
-#define ABS( x ) \
- { \
- { \
- ops_cnt_wmc += ( _ABS_C * ( x ) ); \
- inst_cnt[_ABS] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _ABS_P * ( x ) ); \
- } \
- } \
- } \
+#define ABS( x ) \
+ { \
+ ops_cnt += ( _ABS_C * ( x ) ); \
+ inst_cnt[_ABS] += ( x ); \
}
-#define MULT( x ) \
- { \
- { \
- ops_cnt_wmc += ( _MULT_C * ( x ) ); \
- inst_cnt[_MULT] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _MULT_P * ( x ) ); \
- } \
- } \
- } \
+#define MULT( x ) \
+ { \
+ ops_cnt += ( _MULT_C * ( x ) ); \
+ inst_cnt[_MULT] += ( x ); \
}
-#define MAC( x ) \
- { \
- { \
- ops_cnt_wmc += ( _MAC_C * ( x ) ); \
- inst_cnt[_MAC] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _MAC_P * ( x ) ); \
- } \
- } \
- } \
+#define MAC( x ) \
+ { \
+ ops_cnt += ( _MAC_C * ( x ) ); \
+ inst_cnt[_MAC] += ( x ); \
}
-#define MOVE( x ) \
- { \
- { \
- ops_cnt_wmc += ( _MOVE_C * ( x ) ); \
- inst_cnt[_MOVE] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _MOVE_P * ( x ) ); \
- } \
- } \
- } \
+#define MOVE( x ) \
+ { \
+ ops_cnt += ( _MOVE_C * ( x ) ); \
+ inst_cnt[_MOVE] += ( x ); \
}
-#define STORE( x ) \
- { \
- { \
- ops_cnt_wmc += ( _STORE_C * ( x ) ); \
- inst_cnt[_STORE] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _STORE_P * ( x ) ); \
- } \
- } \
- } \
+#define STORE( x ) \
+ { \
+ ops_cnt += ( _STORE_C * ( x ) ); \
+ inst_cnt[_STORE] += ( x ); \
}
-#define LOGIC( x ) \
- { \
- { \
- ops_cnt_wmc += ( _LOGIC_C * ( x ) ); \
- inst_cnt[_LOGIC] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _LOGIC_P * ( x ) ); \
- } \
- } \
- } \
+#define LOGIC( x ) \
+ { \
+ ops_cnt += ( _LOGIC_C * ( x ) ); \
+ inst_cnt[_LOGIC] += ( x ); \
}
-#define SHIFT( x ) \
- { \
- { \
- ops_cnt_wmc += ( _SHIFT_C * ( x ) ); \
- inst_cnt[_SHIFT] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _SHIFT_P * ( x ) ); \
- } \
- } \
- } \
+#define SHIFT( x ) \
+ { \
+ ops_cnt += ( _SHIFT_C * ( x ) ); \
+ inst_cnt[_SHIFT] += ( x ); \
}
-#define BRANCH( x ) \
- { \
- { \
- ops_cnt_wmc += ( _BRANCH_C * ( x ) ); \
- inst_cnt[_BRANCH] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _BRANCH_P * ( x ) ); \
- } \
- } \
- } \
+#define BRANCH( x ) \
+ { \
+ ops_cnt += ( _BRANCH_C * ( x ) ); \
+ inst_cnt[_BRANCH] += ( x ); \
}
-#define DIV( x ) \
- { \
- { \
- ops_cnt_wmc += ( _DIV_C * ( x ) ); \
- inst_cnt[_DIV] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _DIV_P * ( x ) ); \
- } \
- } \
- } \
+#define DIV( x ) \
+ { \
+ ops_cnt += ( _DIV_C * ( x ) ); \
+ inst_cnt[_DIV] += ( x ); \
}
-#define SQRT( x ) \
- { \
- { \
- ops_cnt_wmc += ( _SQRT_C * ( x ) ); \
- inst_cnt[_SQRT] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _SQRT_P * ( x ) ); \
- } \
- } \
- } \
+#define SQRT( x ) \
+ { \
+ ops_cnt += ( _SQRT_C * ( x ) ); \
+ inst_cnt[_SQRT] += ( x ); \
}
-#define TRANS( x ) \
- { \
- { \
- ops_cnt_wmc += ( _TRANS_C * ( x ) ); \
- inst_cnt[_TRANS] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _TRANS_P * ( x ) ); \
- } \
- } \
- } \
+#define TRANS( x ) \
+ { \
+ ops_cnt += ( _TRANS_C * ( x ) ); \
+ inst_cnt[_TRANS] += ( x ); \
}
-#define LOOP( x ) \
- { \
- { \
- ops_cnt_wmc += ( _LOOP_C * ( x ) ); \
- inst_cnt[_LOOP] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _LOOP_P * ( x ) ); \
- } \
- } \
- } \
+#define LOOP( x ) \
+ { \
+ ops_cnt += ( _LOOP_C * ( x ) ); \
+ inst_cnt[_LOOP] += ( x ); \
}
-#define INDIRECT( x ) \
- { \
- { \
- ops_cnt_wmc += ( _INDIRECT_C * ( x ) ); \
- inst_cnt[_INDIRECT] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _INDIRECT_P * ( x ) ); \
- } \
- } \
- } \
+#define INDIRECT( x ) \
+ { \
+ ops_cnt += ( _INDIRECT_C * ( x ) ); \
+ inst_cnt[_INDIRECT] += ( x ); \
}
-#define PTR_INIT( x ) \
- { \
- { \
- ops_cnt_wmc += ( _PTR_INIT_C * ( x ) ); \
- inst_cnt[_PTR_INIT] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _PTR_INIT_P * ( x ) ); \
- } \
- } \
- } \
+#define PTR_INIT( x ) \
+ { \
+ ops_cnt += ( _PTR_INIT_C * ( x ) ); \
+ inst_cnt[_PTR_INIT] += ( x ); \
}
-#define TEST( x ) \
- { \
- { \
- ops_cnt_wmc += ( _TEST_C * ( x ) ); \
- inst_cnt[_TEST] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _TEST_P * ( x ) ); \
- } \
- } \
- } \
+#define TEST( x ) \
+ { \
+ ops_cnt += ( _TEST_C * ( x ) ); \
+ inst_cnt[_TEST] += ( x ); \
}
-#define POWER( x ) \
- { \
- { \
- ops_cnt_wmc += ( _POWER_C * ( x ) ); \
- inst_cnt[_POWER] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _POWER_P * ( x ) ); \
- } \
- } \
- } \
+#define POWER( x ) \
+ { \
+ ops_cnt += ( _POWER_C * ( x ) ); \
+ inst_cnt[_POWER] += ( x ); \
}
-#define LOG( x ) \
- { \
- { \
- ops_cnt_wmc += ( _LOG_C * ( x ) ); \
- inst_cnt[_LOG] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _LOG_P * ( x ) ); \
- } \
- } \
- } \
+#define LOG( x ) \
+ { \
+ ops_cnt += ( _LOG_C * ( x ) ); \
+ inst_cnt[_LOG] += ( x ); \
}
-#define MISC( x ) \
- { \
- { \
- ops_cnt_wmc += ( _MISC_C * ( x ) ); \
- inst_cnt[_MISC] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _MISC_P * ( x ) ); \
- } \
- } \
- } \
+#define MISC( x ) \
+ { \
+ ops_cnt += ( _MISC_C * ( x ) ); \
+ inst_cnt[_MISC] += ( x ); \
}
-
-#define FUNC( x ) \
- { \
- { \
- ops_cnt_wmc += ( _FUNC_C + _MOVE_C * ( x ) ); \
- inst_cnt[_FUNC]++; \
- inst_cnt[_MOVE] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _FUNC_P + _MOVE_P * ( x ) ); \
- } \
- } \
- } \
- }
-
-#define DADD( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _ADD_C * ( x ) ); \
- inst_cnt[_ADD] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _ADD_P * ( x ) ); \
- } \
- } \
- } \
+#define FUNC( x ) \
+ { \
+ ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \
+ inst_cnt[_FUNC]++; \
+ inst_cnt[_MOVE] += ( x ); \
}
-#define DMULT( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _MULT_C * ( x ) ); \
- inst_cnt[_MULT] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _MULT_P * ( x ) ); \
- } \
- } \
- } \
+#define DADD( x ) \
+ { \
+ ops_cnt += ( 2 * _ADD_C * ( x ) ); \
+ inst_cnt[_ADD] += ( x ); \
}
-#define DMAC( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _MAC_C * ( x ) ); \
- inst_cnt[_MAC] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _MAC_P * ( x ) ); \
- } \
- } \
- } \
+#define DMULT( x ) \
+ { \
+ ops_cnt += ( 2 * _MULT_C * ( x ) ); \
+ inst_cnt[_MULT] += ( x ); \
}
-#define DMOVE( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _MOVE_C * ( x ) ); \
- inst_cnt[_MOVE] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _MOVE_P * ( x ) ); \
- } \
- } \
- } \
+#define DMAC( x ) \
+ { \
+ ops_cnt += ( 2 * _MAC_C * ( x ) ); \
+ inst_cnt[_MAC] += ( x ); \
}
-#define DSTORE( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _STORE_C * ( x ) ); \
- inst_cnt[_STORE] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _STORE_P * ( x ) ); \
- } \
- } \
- } \
+#define DMOVE( x ) \
+ { \
+ ops_cnt += ( 2 * _MOVE_C * ( x ) ); \
+ inst_cnt[_MOVE] += ( x ); \
}
-#define DLOGIC( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _LOGIC_C * ( x ) ); \
- inst_cnt[_LOGIC] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _LOGIC_P * ( x ) ); \
- } \
- } \
- } \
+#define DSTORE( x ) \
+ { \
+ ops_cnt += ( 2 * _STORE_C * ( x ) ); \
+ inst_cnt[_STORE] += ( x ); \
}
-#define DSHIFT( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _SHIFT_C * ( x ) ); \
- inst_cnt[_SHIFT] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _SHIFT_P * ( x ) ); \
- } \
- } \
- } \
+#define DLOGIC( x ) \
+ { \
+ ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \
+ inst_cnt[_LOGIC] += ( x ); \
}
-#define DDIV( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _DIV_C * ( x ) ); \
- inst_cnt[_DIV] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _DIV_P * ( x ) ); \
- } \
- } \
- } \
+#define DSHIFT( x ) \
+ { \
+ ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \
+ inst_cnt[_SHIFT] += ( x ); \
}
-#define DSQRT( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _SQRT_C * ( x ) ); \
- inst_cnt[_SQRT] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _SQRT_P * ( x ) ); \
- } \
- } \
- } \
+#define DDIV( x ) \
+ { \
+ ops_cnt += ( 2 * _DIV_C * ( x ) ); \
+ inst_cnt[_DIV] += ( x ); \
}
-#define DTRANS( x ) \
- { \
- { \
- ops_cnt_wmc += ( 2 * _TRANS_C * ( x ) ); \
- inst_cnt[_TRANS] += ( x ); \
- { \
- static int pcnt; \
- if ( !pcnt ) \
- { \
- pcnt = 1; \
- prom_cnt_wmc += ( _TRANS_P * ( x ) ); \
- } \
- } \
- } \
+#define DSQRT( x ) \
+ { \
+ ops_cnt += ( 2 * _SQRT_C * ( x ) ); \
+ inst_cnt[_SQRT] += ( x ); \
}
-
-extern double ops_cnt_wmc;
-extern double prom_cnt_wmc;
-extern double inst_cnt[NUM_INST];
-
-#define push_wmops( ... ) push_wmops_fct( __VA_ARGS__, NULL )
-void push_wmops_fct( const char *label, ... );
-void pop_wmops( void );
-void reset_wmops( void );
-void print_wmops( void );
-void update_wmops( void );
-void update_mem( void );
+#define DTRANS( x ) \
+ { \
+ ops_cnt += ( 2 * _TRANS_C * ( x ) ); \
+ inst_cnt[_TRANS] += ( x ); \
+ }
#else
@@ -611,14 +304,6 @@ extern int cntr_push_pop;
#endif
-/* mac & msu (Non Instrumented Versions) */
-#ifndef mac
-#define mac( a, b, c ) ( ( a ) + ( b ) * ( c ) )
-#endif
-#ifndef msu
-#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) )
-#endif
-
#ifndef WMOPS
/* DESACTIVATE the Counting Mechanism */
#define OP_COUNT_( op, n )
@@ -634,24 +319,8 @@ extern int cntr_push_pop;
#else
-/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt_wmc' may be undefined" with Cygwin gcc Compiler */
-static double *ops_cnt_ptr = &ops_cnt_wmc;
-#define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) )
-
-/******************************************************************/
-/* NOTES: */
-/* The 'wmc_flag_' flag is global to avoid declaration in every */
-/* function and 'static' to avoid clashing with other modules */
-/* that include this header file. */
-/* */
-/* The declarations of 'wmc_flag_' and 'wops_' in this header */
-/* file prevent the addition of a 'C' file to the Project. */
-/******************************************************************/
-
-/* General Purpose Global Flag */
-static int wmc_flag_ = 0;
-
/* Operation Counter Wrappers */
+#define OP_COUNT_( op, x ) ( ops_cnt += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) )
#define OP_COUNT_WRAPPER1_( op, val ) ( op, val )
#define OP_COUNT_WRAPPER2_( expr ) \
if ( expr, 0 ) \
@@ -683,7 +352,11 @@ static int wmc_flag_ = 0;
#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) )
#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) )
#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) )
+#ifdef WMOPS_DISABLE_FCN_CALL_PENALIZATION
+#define FUNC_( x ) ( x )
+#else
#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) )
+#endif
#define MISC_( x ) ABS_( x )
/* Math Operations */
@@ -801,7 +474,6 @@ static int wmc_flag_ = 0;
#define return_ \
OP_COUNT_WRAPPER2_( ( wmc_flag_ = stack_tree_level_, STACK_DEPTH_FCT_RETURN ) ) \
return
-
#define switch_ \
OP_COUNT_WRAPPER2_( ( BRANCH_( 1 ), wmc_flag_ = 1 ) ) \
switch
@@ -917,7 +589,6 @@ st:
/* This Shouldn't Happen */
/* These are Used to Avoid: "warning: 'name' defined but not used" with Cygwin gcc Compiler */
wmc_flag_ = wmc_flag_;
- ops_cnt_ptr = ops_cnt_ptr;
fct( "" );
error:
default:
@@ -995,18 +666,6 @@ typedef enum
USE_32BITS = 2
} Counting_Size;
-#if ( defined( _WIN32 ) && ( _MSC_VER <= 1800 ) && ( _MSC_VER >= 1300 ) )
-#define __func__ __FUNCTION__
-#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ < 199901L
-#if ( __GNUC__ >= 2 )
-#define __func__ __FUNCTION__
-#else
-#define __func__ ""
-#endif
-#elif defined( __GNUC__ )
-#define __func__ __extension__ __FUNCTION__
-#endif
-
#ifdef WMOPS
@@ -1024,11 +683,11 @@ int push_stack( const char *filename, const char *fctname );
int pop_stack( const char *filename, const char *fctname );
#ifdef WMOPS_DETAIL
-#define STACK_DEPTH_FCT_CALL ( push_wmops( __FUNCTION__ ), push_stack( __FILE__, __FUNCTION__ ) ) /* add push_wmops() in all function calls */
-#define STACK_DEPTH_FCT_RETURN ( pop_wmops(), pop_stack( __FILE__, __FUNCTION__ ) ) /* add pop_wmops() in all function returns */
+#define STACK_DEPTH_FCT_CALL ( push_wmops( __func__, "[WMC_AUTO]" ), push_stack( __FILE__, __func__ ) ) /* add push_wmops() in all function calls */
+#define STACK_DEPTH_FCT_RETURN ( pop_wmops(), pop_stack( __FILE__, __func__ ) ) /* add pop_wmops() in all function returns */
#else
-#define STACK_DEPTH_FCT_CALL push_stack( __FILE__, __FUNCTION__ )
-#define STACK_DEPTH_FCT_RETURN pop_stack( __FILE__, __FUNCTION__ )
+#define STACK_DEPTH_FCT_CALL push_stack( __FILE__, __func__ )
+#define STACK_DEPTH_FCT_RETURN pop_stack( __FILE__, __func__ )
#endif
void reset_stack( void );
@@ -1048,4 +707,531 @@ void reset_stack( void );
#endif
+/* Global counter variable for calculation of complexity weight */
+typedef struct
+{
+ unsigned int add; /* Complexity Weight of 1 */
+ unsigned int sub; /* Complexity Weight of 1 */
+ unsigned int abs_s; /* Complexity Weight of 1 */
+ unsigned int shl; /* Complexity Weight of 1 */
+ unsigned int shr; /* Complexity Weight of 1 */
+
+ unsigned int extract_h; /* Complexity Weight of 1 */
+ unsigned int extract_l; /* Complexity Weight of 1 */
+ unsigned int mult; /* Complexity Weight of 1 */
+ unsigned int L_mult; /* Complexity Weight of 1 */
+ unsigned int negate; /* Complexity Weight of 1 */
+
+ unsigned int round; /* Complexity Weight of 1 */
+ unsigned int L_mac; /* Complexity Weight of 1 */
+ unsigned int L_msu; /* Complexity Weight of 1 */
+ unsigned int L_macNs; /* Complexity Weight of 1 */
+ unsigned int L_msuNs; /* Complexity Weight of 1 */
+
+ unsigned int L_add; /* Complexity Weight of 1 */
+ unsigned int L_sub; /* Complexity Weight of 1 */
+ unsigned int L_add_c; /* Complexity Weight of 2 */
+ unsigned int L_sub_c; /* Complexity Weight of 2 */
+ unsigned int L_negate; /* Complexity Weight of 1 */
+
+ unsigned int L_shl; /* Complexity Weight of 1 */
+ unsigned int L_shr; /* Complexity Weight of 1 */
+ unsigned int mult_r; /* Complexity Weight of 1 */
+ unsigned int shr_r; /* Complexity Weight of 3 */
+ unsigned int mac_r; /* Complexity Weight of 1 */
+
+ unsigned int msu_r; /* Complexity Weight of 1 */
+ unsigned int L_deposit_h; /* Complexity Weight of 1 */
+ unsigned int L_deposit_l; /* Complexity Weight of 1 */
+ unsigned int L_shr_r; /* Complexity Weight of 3 */
+ unsigned int L_abs; /* Complexity Weight of 1 */
+
+ unsigned int L_sat; /* Complexity Weight of 4 */
+ unsigned int norm_s; /* Complexity Weight of 1 */
+ unsigned int div_s; /* Complexity Weight of 18 */
+ unsigned int norm_l; /* Complexity Weight of 1 */
+ unsigned int move16; /* Complexity Weight of 1 */
+
+ unsigned int move32; /* Complexity Weight of 2 */
+ unsigned int Logic16; /* Complexity Weight of 1 */
+ unsigned int Logic32; /* Complexity Weight of 2 */
+ unsigned int Test; /* Complexity Weight of 2 */
+ unsigned int s_max; /* Complexity Weight of 1 */
+
+ unsigned int s_min; /* Complexity Weight of 1 */
+ unsigned int L_max; /* Complexity Weight of 1 */
+ unsigned int L_min; /* Complexity Weight of 1 */
+ unsigned int L40_max; /* Complexity Weight of 1 */
+ unsigned int L40_min; /* Complexity Weight of 1 */
+
+ unsigned int shl_r; /* Complexity Weight of 2 */
+ unsigned int L_shl_r; /* Complexity Weight of 2 */
+ unsigned int L40_shr_r; /* Complexity Weight of 2 */
+ unsigned int L40_shl_r; /* Complexity Weight of 2 */
+ unsigned int norm_L40; /* Complexity Weight of 1 */
+
+ unsigned int L40_shl; /* Complexity Weight of 1 */
+ unsigned int L40_shr; /* Complexity Weight of 1 */
+ unsigned int L40_negate; /* Complexity Weight of 1 */
+ unsigned int L40_add; /* Complexity Weight of 1 */
+ unsigned int L40_sub; /* Complexity Weight of 1 */
+
+ unsigned int L40_abs; /* Complexity Weight of 1 */
+ unsigned int L40_mult; /* Complexity Weight of 1 */
+ unsigned int L40_mac; /* Complexity Weight of 1 */
+ unsigned int mac_r40; /* Complexity Weight of 2 */
+
+ unsigned int L40_msu; /* Complexity Weight of 1 */
+ unsigned int msu_r40; /* Complexity Weight of 2 */
+ unsigned int Mpy_32_16_ss; /* Complexity Weight of 2 */
+ unsigned int Mpy_32_32_ss; /* Complexity Weight of 2 */
+ unsigned int L_mult0; /* Complexity Weight of 1 */
+
+ unsigned int L_mac0; /* Complexity Weight of 1 */
+ unsigned int L_msu0; /* Complexity Weight of 1 */
+ unsigned int lshl; /* Complexity Weight of 1 */
+ unsigned int lshr; /* Complexity Weight of 1 */
+ unsigned int L_lshl; /* Complexity Weight of 1 */
+
+ unsigned int L_lshr; /* Complexity Weight of 1 */
+ unsigned int L40_lshl; /* Complexity Weight of 1 */
+ unsigned int L40_lshr; /* Complexity Weight of 1 */
+ unsigned int s_and; /* Complexity Weight of 1 */
+ unsigned int s_or; /* Complexity Weight of 1 */
+
+ unsigned int s_xor; /* Complexity Weight of 1 */
+ unsigned int L_and; /* Complexity Weight of 1 */
+ unsigned int L_or; /* Complexity Weight of 1 */
+ unsigned int L_xor; /* Complexity Weight of 1 */
+ unsigned int rotl; /* Complexity Weight of 3 */
+
+ unsigned int rotr; /* Complexity Weight of 3 */
+ unsigned int L_rotl; /* Complexity Weight of 3 */
+ unsigned int L_rotr; /* Complexity Weight of 3 */
+ unsigned int L40_set; /* Complexity Weight of 1 */
+ unsigned int L40_deposit_h; /* Complexity Weight of 1 */
+
+ unsigned int L40_deposit_l; /* Complexity Weight of 1 */
+ unsigned int L40_deposit32; /* Complexity Weight of 1 */
+ unsigned int Extract40_H; /* Complexity Weight of 1 */
+ unsigned int Extract40_L; /* Complexity Weight of 1 */
+ unsigned int L_Extract40; /* Complexity Weight of 1 */
+
+ unsigned int L40_round; /* Complexity Weight of 1 */
+ unsigned int L_saturate40; /* Complexity Weight of 1 */
+ unsigned int round40; /* Complexity Weight of 1 */
+ unsigned int If; /* Complexity Weight of 3 */
+ unsigned int Goto; /* Complexity Weight of 2 */
+
+ unsigned int Break; /* Complexity Weight of 2 */
+ unsigned int Switch; /* Complexity Weight of 6 */
+ unsigned int For; /* Complexity Weight of 3 */
+ unsigned int While; /* Complexity Weight of 3 */
+ unsigned int Continue; /* Complexity Weight of 2 */
+
+ unsigned int L_mls; /* Complexity Weight of 1 */
+ unsigned int div_l; /* Complexity Weight of 32 */
+ unsigned int i_mult; /* Complexity Weight of 1 */
+
+/* New complex basic operators */
+#ifdef COMPLEX_OPERATOR
+ unsigned int CL_shr; /* Complexity Weight of 1 */
+ unsigned int CL_shl; /* Complexity Weight of 1 */
+ unsigned int CL_add; /* Complexity Weight of 1 */
+ unsigned int CL_sub; /* Complexity Weight of 1 */
+ unsigned int CL_scale; /* Complexity Weight of 1 */
+ unsigned int CL_dscale; /* Complexity Weight of 1 */
+ unsigned int CL_msu_j; /* Complexity Weight of 1 */
+ unsigned int CL_mac_j; /* Complexity Weight of 1 */
+ unsigned int CL_move; /* Complexity Weight of 1 */
+ unsigned int CL_Extract_real; /* Complexity Weight of 1 */
+ unsigned int CL_Extract_imag; /* Complexity Weight of 1 */
+ unsigned int CL_form; /* Complexity Weight of 1 */
+ unsigned int CL_multr_32x16; /* Complexity Weight of 2 */
+ unsigned int CL_negate; /* Complexity Weight of 1 */
+ unsigned int CL_conjugate; /* Complexity Weight of 1 */
+ unsigned int CL_mul_j; /* Complexity Weight of 1 */
+ unsigned int CL_swap_real_imag; /* Complexity Weight of 1 */
+ unsigned int C_add; /* Complexity Weight of 1 */
+ unsigned int C_sub; /* Complexity Weight of 1 */
+ unsigned int C_mul_j; /* Complexity Weight of 1 */
+ unsigned int C_multr; /* Complexity Weight of 2 */
+ unsigned int C_form; /* Complexity Weight of 1 */
+
+ unsigned int C_scale; /* Complexity Weight of 1 */
+ unsigned int CL_round32_16; /* Complexity Weight of 1 */
+ unsigned int CL_scale_32; /* Complexity Weight of 1 */
+ unsigned int CL_dscale_32; /* Complexity Weight of 1 */
+ unsigned int CL_multr_32x32; /* Complexity Weight of 2 */
+ unsigned int C_mac_r; /* Complexity Weight of 2 */
+ unsigned int C_msu_r; /* Complexity Weight of 2 */
+ unsigned int C_Extract_real; /* Complexity Weight of 1 */
+ unsigned int C_Extract_imag; /* Complexity Weight of 1 */
+ unsigned int C_negate; /* Complexity Weight of 1 */
+ unsigned int C_conjugate; /* Complexity Weight of 1 */
+ unsigned int C_shr; /* Complexity Weight of 1 */
+ unsigned int C_shl; /* Complexity Weight of 1 */
+
+#endif /* #ifdef COMPLEX_OPERATOR */
+
+/* New 64 bit basops */
+#ifdef ENH_64_BIT_OPERATOR
+ unsigned int move64; /* Complexity Weight of 1 */
+ unsigned int W_add_nosat; /* Complexity Weight of 1 */
+ unsigned int W_sub_nosat; /* Complexity Weight of 1 */
+ unsigned int W_shl; /* Complexity Weight of 1 */
+ unsigned int W_shr; /* Complexity Weight of 1 */
+ unsigned int W_shl_nosat; /* Complexity Weight of 1 */
+ unsigned int W_shr_nosat; /* Complexity Weight of 1 */
+ unsigned int W_mac_32_16; /* Complexity Weight of 1 */
+ unsigned int W_msu_32_16; /* Complexity Weight of 1 */
+ unsigned int W_mult_32_16; /* Complexity Weight of 1 */
+ unsigned int W_mult0_16_16; /* Complexity Weight of 1 */
+ unsigned int W_mac0_16_16; /* Complexity Weight of 1 */
+ unsigned int W_msu0_16_16; /* Complexity Weight of 1 */
+ unsigned int W_mult_16_16; /* Complexity Weight of 1 */
+ unsigned int W_mac_16_16; /* Complexity Weight of 1 */
+ unsigned int W_msu_16_16; /* Complexity Weight of 1 */
+ unsigned int W_shl_sat_l; /* Complexity Weight of 1 */
+ unsigned int W_sat_l; /* Complexity Weight of 1 */
+ unsigned int W_sat_m; /* Complexity Weight of 1 */
+ unsigned int W_deposit32_l; /* Complexity Weight of 1 */
+ unsigned int W_deposit32_h; /* Complexity Weight of 1 */
+ unsigned int W_extract_l; /* Complexity Weight of 1 */
+ unsigned int W_extract_h; /* Complexity Weight of 1 */
+ unsigned int W_round48_L; /* Complexity Weight of 1 */
+ unsigned int W_round32_s; /* Complexity Weight of 1 */
+ unsigned int W_norm; /* Complexity Weight of 1 */
+
+ unsigned int W_add; /* Complexity Weight of 1 */
+ unsigned int W_sub; /* Complexity Weight of 1 */
+ unsigned int W_neg; /* Complexity Weight of 1 */
+ unsigned int W_abs; /* Complexity Weight of 1 */
+ unsigned int W_mult_32_32; /* Complexity Weight of 1 */
+ unsigned int W_mult0_32_32; /* Complexity Weight of 1 */
+ unsigned int W_lshl; /* Complexity Weight of 1 */
+ unsigned int W_lshr; /* Complexity Weight of 1 */
+ unsigned int W_round64_L; /* Complexity Weight of 1 */
+
+#endif /* #ifdef ENH_64_BIT_OPERATOR */
+
+#ifdef ENH_32_BIT_OPERATOR
+ unsigned int Mpy_32_16_1; /* Complexity Weight of 1 */
+ unsigned int Mpy_32_16_r; /* Complexity Weight of 1 */
+ unsigned int Mpy_32_32; /* Complexity Weight of 1 */
+ unsigned int Mpy_32_32_r; /* Complexity Weight of 1 */
+ unsigned int Madd_32_16; /* Complexity Weight of 1 */
+ unsigned int Madd_32_16_r; /* Complexity Weight of 1 */
+ unsigned int Msub_32_16; /* Complexity Weight of 1 */
+ unsigned int Msub_32_16_r; /* Complexity Weight of 1 */
+ unsigned int Madd_32_32; /* Complexity Weight of 1 */
+ unsigned int Madd_32_32_r; /* Complexity Weight of 1 */
+ unsigned int Msub_32_32; /* Complexity Weight of 1 */
+ unsigned int Msub_32_32_r; /* Complexity Weight of 1 */
+#endif /* #ifdef ENH_32_BIT_OPERATOR */
+
+#ifdef ENH_U_32_BIT_OPERATOR
+ unsigned int UL_addNs; /* Complexity Weight of 1 */
+ unsigned int UL_subNs; /* Complexity Weight of 1 */
+ unsigned int UL_Mpy_32_32; /* Complexity Weight of 1 */
+ unsigned int Mpy_32_32_uu; /* Complexity Weight of 2 */
+ unsigned int Mpy_32_16_uu; /* Complexity Weight of 2 */
+ unsigned int norm_ul_float; /* Complexity Weight of 1 */
+ unsigned int UL_deposit_l; /* Complexity Weight of 1 */
+#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
+
+#ifdef CONTROL_CODE_OPS
+ unsigned int LT_16; /* Complexity Weight of 1 */
+ unsigned int GT_16; /* Complexity Weight of 1 */
+ unsigned int LE_16; /* Complexity Weight of 1 */
+ unsigned int GE_16; /* Complexity Weight of 1 */
+ unsigned int EQ_16; /* Complexity Weight of 1 */
+ unsigned int NE_16; /* Complexity Weight of 1 */
+ unsigned int LT_32; /* Complexity Weight of 1 */
+ unsigned int GT_32; /* Complexity Weight of 1 */
+ unsigned int LE_32; /* Complexity Weight of 1 */
+ unsigned int GE_32; /* Complexity Weight of 1 */
+ unsigned int EQ_32; /* Complexity Weight of 1 */
+ unsigned int NE_32; /* Complexity Weight of 1 */
+ unsigned int LT_64; /* Complexity Weight of 1 */
+ unsigned int GT_64; /* Complexity Weight of 1 */
+ unsigned int LE_64; /* Complexity Weight of 1 */
+ unsigned int GE_64; /* Complexity Weight of 1 */
+ unsigned int EQ_64; /* Complexity Weight of 1 */
+ unsigned int NE_64; /* Complexity Weight of 1 */
+
+#endif /* #ifdef CONTROL_CODE_OPS */
+} BASIC_OP;
+
+#ifdef WMOPS
+extern BASIC_OP *multiCounter;
+extern unsigned int currCounter;
+extern long funcid_total_wmops_at_last_call_to_else;
+extern char func_name_where_last_call_to_else_occurred[];
+
+long TotalWeightedOperation( unsigned int counterId );
+long DeltaWeightedOperation( unsigned int counterId );
+void Reset_BASOP_WMOPS_counter( unsigned int counterId );
+
+#endif
+
+/*****************************************************************************
+ *
+ * Function Name : FOR
+ *
+ * Purpose :
+ *
+ * The macro FOR should be used instead of the 'for' C statement.
+ * The complexity is independent of the number of loop iterations that are
+ * performed.
+ *
+ * Complexity weight : 3 (regardless of number of iterations).
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define FOR( a ) for ( a )
+
+#else /* ifndef WMOPS */
+#define FOR( a ) \
+ if ( incrFor(), 0 ) \
+ ; \
+ else \
+ for ( a )
+
+static __inline void incrFor( void )
+{
+ multiCounter[currCounter].For++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : WHILE
+ *
+ * Purpose :
+ *
+ * The macro WHILE should be used instead of the 'while' C statement.
+ * The complexity is proportional to the number of loop iterations that
+ * are performed.
+ *
+ * Complexity weight : 4 x 'number of loop iterations'.
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define WHILE( a ) while ( a )
+
+#else /* ifndef WMOPS */
+#define WHILE( a ) while ( incrWhile(), a )
+
+static __inline void incrWhile( void )
+{
+ multiCounter[currCounter].While++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : DO
+ *
+ * Purpose :
+ *
+ * The macro DO should be used instead of the 'do' C statement.
+ *
+ * Complexity weight : 0 (complexity counted by WHILE macro).
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define DO do
+
+#else /* ifndef WMOPS */
+#define DO do
+
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : IF
+ *
+ * Purpose :
+ *
+ * The macro IF should :
+ *
+ * - not be used when :
+ * - the 'if' structure does not have any 'else if' nor 'else' statement
+ * - and it conditions only one DSP basic operations.
+ *
+ * - be used instead of the 'if' C statement in every other case :
+ * - when there is an 'else' or 'else if' statement,
+ * - or when the 'if' conditions several DSP basic operations,
+ * - or when the 'if' conditions a function call.
+ *
+ * Complexity weight : 3
+ *
+ *****************************************************************************/
+
+#ifndef WMOPS
+#define IF( a ) if ( a )
+#else /* ifndef WMOPS */
+#define IF( a ) if ( incrIf( __func__ ), a )
+void incrIf( const char *func_name );
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : ELSE
+ *
+ * Purpose :
+ *
+ * The macro ELSE should be used instead of the 'else' C statement.
+ *
+ * Complexity weight : 3
+ *
+ *****************************************************************************/
+
+#ifndef WMOPS
+#define ELSE else
+#else /* ifndef WMOPS */
+#define ELSE else if ( incrElse( __func__ ), 0 ); else
+void incrElse( const char *func_name );
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : SWITCH
+ *
+ * Purpose :
+ *
+ * The macro SWITCH should be used instead of the 'switch' C statement.
+ *
+ * Complexity weight : 6
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define SWITCH( a ) switch ( a )
+
+#else /* ifndef WMOPS */
+#define SWITCH( a ) switch ( incrSwitch(), a )
+
+static __inline void incrSwitch( void )
+{
+ multiCounter[currCounter].Switch++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : CONTINUE
+ *
+ * Purpose :
+ *
+ * The macro CONTINUE should be used instead of the 'continue' C statement.
+ *
+ * Complexity weight : 2
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define CONTINUE continue
+
+#else /* ifndef WMOPS */
+#define CONTINUE \
+ if ( incrContinue(), 0 ) \
+ ; \
+ else \
+ continue
+
+static __inline void incrContinue( void )
+{
+ multiCounter[currCounter].Continue++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : BREAK
+ *
+ * Purpose :
+ *
+ * The macro BREAK should be used instead of the 'break' C statement.
+ *
+ * Complexity weight : 2
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define BREAK break
+
+#else /* ifndef WMOPS */
+#define BREAK \
+ if ( incrBreak(), 0 ) \
+ ; \
+ else \
+ break
+
+static __inline void incrBreak( void )
+{
+ multiCounter[currCounter].Break++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : GOTO
+ *
+ * Purpose :
+ *
+ * The macro GOTO should be used instead of the 'goto' C statement.
+ *
+ * Complexity weight : 2
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define GOTO goto
+
+#else /* ifndef WMOPS */
+#define GOTO \
+ if ( incrGoto(), 0 ) \
+ ; \
+ else \
+ goto
+
+static __inline void incrGoto( void )
+{
+ multiCounter[currCounter].Goto++;
+}
+#endif /* ifndef WMOPS */
+
+
+#ifdef CONTROL_CODE_OPS
+
+extern int LT_16( short var1, short var2 );
+extern int GT_16( short var1, short var2 );
+extern int LE_16( short var1, short var2 );
+extern int GE_16( short var1, short var2 );
+extern int EQ_16( short var1, short var2 );
+extern int NE_16( short var1, short var2 );
+
+extern int LT_32( int L_var1, int L_var2 );
+extern int GT_32( int L_var1, int L_var2 );
+extern int LE_32( int L_var1, int L_var2 );
+extern int GE_32( int L_var1, int L_var2 );
+extern int EQ_32( int L_var1, int L_var2 );
+extern int NE_32( int L_var1, int L_var2 );
+
+extern int LT_64( long long int L64_var1, long long int L64_var2 );
+extern int GT_64( long long int L64_var1, long long int L64_var2 );
+extern int LE_64( long long int L64_var1, long long int L64_var2 );
+extern int GE_64( long long int L64_var1, long long int L64_var2 );
+extern int EQ_64( long long int L64_var1, long long int L64_var2 );
+extern int NE_64( long long int L64_var1, long long int L64_var2 );
+
+#endif /* #ifdef CONTROL_CODE_OPS */
+
+
#endif /* WMOPS_H */
diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c
index 4d3a91a935fad78f3a04bed14693b6d6884e2adb..49b3297836a70ff42e2b69e68ed4471fea852703 100644
--- a/lib_dec/acelp_core_dec_ivas_fx.c
+++ b/lib_dec/acelp_core_dec_ivas_fx.c
@@ -628,12 +628,14 @@ ivas_error acelp_core_dec_ivas_fx(
IF( st->cng_type == LP_CNG )
{
CNG_dec_ivas_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
+#ifndef FIX_1100_REMOVE_LPC_RESCALING
FOR( Word32 nsf = 0; nsf < NB_SUBFR16k; nsf++ )
{
Scale_sig( Aq_fx + imult3216( nsf, ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[nsf * ( M + 1 )] ), Q2 ) );
Aq_fx[nsf * ( M + 1 )] = ONE_IN_Q12;
move16();
}
+#endif
Copy( Aq_fx, st->Aq_cng, add( M, 1 ) );
/* comfort noise generation */
@@ -761,7 +763,9 @@ ivas_error acelp_core_dec_ivas_fx(
/* synthesis at 12.8kHz sampling rate */
+#ifndef FIX_1100_REMOVE_LPC_RESCALING
Aq_fx[0] = ONE_IN_Q12;
+#endif
move16();
syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn );
@@ -909,6 +913,7 @@ ivas_error acelp_core_dec_ivas_fx(
st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame );
move16();
}
+#ifndef FIX_1100_REMOVE_LPC_RESCALING
#ifndef MSAN_FIX
for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ )
#else
@@ -919,6 +924,7 @@ ivas_error acelp_core_dec_ivas_fx(
Aq_fx[nsf * ( M + 1 )] = ONE_IN_Q12;
move16();
}
+#endif
test();
IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
{
@@ -1254,6 +1260,7 @@ ivas_error acelp_core_dec_ivas_fx(
lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth );
FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
+#ifndef FIX_1100_REMOVE_LPC_RESCALING
#ifndef MSAN_FIX
for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ )
#else
@@ -1264,6 +1271,7 @@ ivas_error acelp_core_dec_ivas_fx(
Aq_fx[nsf * ( M + 1 )] = ONE_IN_Q12;
move16();
}
+#endif
IF( EQ_16( st->nelp_mode_dec, 1 ) )
{
/* SC-VBR */
@@ -2191,11 +2199,13 @@ ivas_error acelp_core_dec_ivas_fx(
#else
Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 );
#endif
+#ifndef FIX_1100_REMOVE_LPC_RESCALING
if ( st->hFdCngDec )
{
st->hFdCngDec->hFdCngCom->A_cng[0] = ONE_IN_Q12;
move16();
}
+#endif
}
pop_wmops();
diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c
index a13678a97124b2c8af8361358a98b4035db7c57a..3bf7e3eb62ff897d2028a462d3e8f30c33ead199 100644
--- a/lib_dec/avq_dec_fx.c
+++ b/lib_dec/avq_dec_fx.c
@@ -184,7 +184,7 @@ void AVQ_demuxdec_fx(
move16();
FOR( j = i; j < Nsv - 1; j++ )
{
- if ( ( nq[svOrder[j]] == 0 ) )
+ if ( nq[svOrder[j]] == 0 )
{
nullVec = add( nullVec, 1 );
}
@@ -271,12 +271,7 @@ void AVQ_demuxdec_fx(
/*Compute AVQ code book number from unused Bits */
tmp = (Word16) ( sub( bits, add( add( shl( add( unusedbitsFlag, unused_bits_idx ), 2 ), unusedbitsFlag ), unused_bits_idx ) ) );
nq_est = idiv1616( tmp, 5 );
- IF( ( ( tmp % 5 ) == 0 ) )
- {
- nq_est = nq_est;
- move16();
- }
- ELSE
+ IF( ( ( tmp % 5 ) != 0 ) )
{
nq_est = add( nq_est, 1 );
}
diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c
index c0a83460a51adaf9b87906158817144fc14a3ff0..671dbfd2ca520671ad8ab10abb004f32f8b055f2 100644
--- a/lib_dec/core_dec_init_fx.c
+++ b/lib_dec/core_dec_init_fx.c
@@ -1287,7 +1287,7 @@ void open_decoder_LPD_ivas_fx(
move16();
st->output_frame_fx = st->hTcxDec->L_frameTCX; /* Q0 */
move16();
- if ( ( st->ini_frame == 0 ) )
+ if ( st->ini_frame == 0 )
{
st->L_frameTCX_past = st->hTcxDec->L_frameTCX;
move16();
@@ -1360,7 +1360,7 @@ void open_decoder_LPD_ivas_fx(
}
}
- if ( ( st->ini_frame == 0 ) )
+ if ( st->ini_frame == 0 )
{
st->pit_res_max_past = st->pit_res_max;
move16();
diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c
index 9c2e014b4f5848aeaabee3343f09e6198aab4b0f..f3443349a1a542e0ff66f85b2ba1650107e1c2f8 100644
--- a/lib_dec/dec_LPD_fx.c
+++ b/lib_dec/dec_LPD_fx.c
@@ -448,7 +448,7 @@ void decoder_LPD_fx(
IF( st->enablePlcWaveadjust )
{
- if ( ( st->core == ACELP_CORE ) )
+ if ( st->core == ACELP_CORE )
{
st->tonality_flag = 0;
move16();
diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c
index cf2b3f7114ad7ccd86faae0d401a5f78e3184776..20f7d297d739e3030ff5c8bdb468b1b7c12a6097 100644
--- a/lib_dec/dec_tcx_fx.c
+++ b/lib_dec/dec_tcx_fx.c
@@ -13,6 +13,7 @@
#include "math.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
+#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_com_fx.h"
extern const Word16 T_DIV_L_Frame[]; /*0Q15 * 2^-7 */
diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c
index cad6ae2bf9aec929e4e3b419f4ba071fa2597922..8996f087d79a860e574d6b23a6fa30623b42bb68 100644
--- a/lib_dec/ivas_agc_dec_fx.c
+++ b/lib_dec/ivas_agc_dec_fx.c
@@ -31,14 +31,14 @@
*******************************************************************************************************/
#include
+#include
+#include
#include "options.h"
-
#include "prot.h"
#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
-#include
-#include
+#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c
index 1075cb682118036ab350e3e79dccd1a7341604fd..35844b5e53d3dd214665bfcf932501ccb765daaf 100644
--- a/lib_dec/ivas_init_dec.c
+++ b/lib_dec/ivas_init_dec.c
@@ -30,16 +30,17 @@
*******************************************************************************************************/
+#include
+#include
+#include
#include "options.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
+#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_stat_enc.h"
#include "prot.h"
-#include
-#include
-#include
#include "wmc_auto.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c
index e118a3d1544ff13632a12b2cba9245c5effea926..9514e5e2a13cf92647264eae718bfc698d9789ff 100644
--- a/lib_dec/ivas_ism_param_dec.c
+++ b/lib_dec/ivas_ism_param_dec.c
@@ -37,6 +37,7 @@
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "prot.h"
+#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
#include "wmc_auto.h"
diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c
index 999eae9aa2f384b455d36744108c35867dc5ae23..983eb33095e6d03432387deede2d78b3c3a9270b 100644
--- a/lib_dec/ivas_masa_dec.c
+++ b/lib_dec/ivas_masa_dec.c
@@ -31,16 +31,17 @@
*******************************************************************************************************/
#include
-#include "options.h"
#include
+#include
+#include "options.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
+#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_stat_dec.h"
#include "prot.h"
#include "prot_fx.h"
-#include
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com_fx.h"
@@ -2325,15 +2326,11 @@ void ivas_spar_param_to_masa_param_mapping_fx(
move16();
res_q = 0;
move16();
- IF( E_fx > 0 )
- {
- E_fx = E_fx;
- }
- ELSE
+ IF( E_fx <= 0 )
{
E_fx = 1;
+ move32();
}
- move32();
ratio_float_fx = BASOP_Util_Divide3232_Scale( I_fx, E_fx, &res_q );
res_q = sub( res_q, sub( num_q, denom_q ) );
ratio_fx = L_shl_sat( ratio_float_fx, add( Q15, res_q ) ); // Q(15 + res_q)
diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c
index fc158ca89d75cd413ffdeb4b76b0b6efe2f31fa2..4175d15def0080ebd3dd76978dc5135a43141db3 100644
--- a/lib_dec/ivas_mc_param_dec.c
+++ b/lib_dec/ivas_mc_param_dec.c
@@ -1968,10 +1968,13 @@ void ivas_param_mc_dec_render_fx(
slot_idx_start_cldfb_synth = 0;
move16();
+#ifndef FIX_1009_OPT_PARAMMC_RENDER
Flag is_zero = 1;
move32();
+#endif
FOR( j = 0; j < st_ivas->hParamMC->hMetadataPMC->nbands_coded; j++ )
{
+#ifndef FIX_1009_OPT_PARAMMC_RENDER
is_zero = 1;
move16();
FOR( i = 0; i < hParamMC->h_output_synthesis_cov_state.mixing_matrix_len; i++ )
@@ -1989,8 +1992,19 @@ void ivas_param_mc_dec_render_fx(
}
is_zero = 1;
move16();
+#else
+ Flag is_zero = is_zero_arr( hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[j], hParamMC->h_output_synthesis_cov_state.mixing_matrix_len );
+ {
+ if ( is_zero != 0 )
+ {
+ hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[j] = 0;
+ move16();
+ }
+ }
+#endif
IF( LT_16( st_ivas->hParamMC->band_grouping[j], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) )
{
+#ifndef FIX_1009_OPT_PARAMMC_RENDER
FOR( i = 0; i < hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len; i++ )
{
IF( NE_32( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[j][i], 0 ) )
@@ -2000,6 +2014,10 @@ void ivas_param_mc_dec_render_fx(
}
}
IF( is_zero )
+#else
+ is_zero = is_zero_arr( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[j], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len );
+ if ( is_zero != 0 )
+#endif
{
hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[j] = 0;
move16();
@@ -2019,7 +2037,6 @@ void ivas_param_mc_dec_render_fx(
&hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands],
hParamMC->proto_frame_f_fx, hParamMC->diff_proto_info,
hParamMC->num_freq_bands );
- Scale_sig32( hParamMC->proto_frame_f_fx, shl( imult1616( hParamMC->diff_proto_info->num_protos_diff, hParamMC->num_freq_bands ), 1 ), Q11 - Q5 );
/*-----------------------------------------------------------------*
* frequency domain decorrelation
*-----------------------------------------------------------------*/
@@ -2031,7 +2048,7 @@ void ivas_param_mc_dec_render_fx(
DIRAC_SYNTHESIS_COV_MC_LS,
nchan_transport,
hParamMC->proto_frame_f_fx,
- 11,
+ Q5,
hParamMC->diff_proto_info->num_protos_diff,
hParamMC->diff_proto_info->proto_index_diff,
hParamMC->proto_frame_dec_f_fx, // output
diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c
index 86bcc71f9fbefb480aaf6f368af2d2a68ce10ebc..c1bf455a5f60063f955fff29a969e716e2b9aba9 100644
--- a/lib_dec/ivas_mc_paramupmix_dec.c
+++ b/lib_dec/ivas_mc_paramupmix_dec.c
@@ -31,8 +31,8 @@
*******************************************************************************************************/
#include
-#include "options.h"
#include
+#include "options.h"
#include "cnst.h"
#include "prot.h"
#include "prot_fx.h"
@@ -40,6 +40,7 @@
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "ivas_cnst.h"
+#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
#include "math.h"
diff --git a/lib_dec/ivas_mct_dec_mct_fx.c b/lib_dec/ivas_mct_dec_mct_fx.c
index 1f8954e67becaab0ac7ab24194d00a4852b8b982..3ed0998d1642fd8e96aca435a0dfe720550df64f 100644
--- a/lib_dec/ivas_mct_dec_mct_fx.c
+++ b/lib_dec/ivas_mct_dec_mct_fx.c
@@ -315,6 +315,7 @@ void mctStereoIGF_dec_fx(
test();
IF( NE_16( hMCT->hBlockData[b]->hStereoMdct->IGFStereoMode[k], SMDCT_DUAL_MONO ) || NE_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[k], SMDCT_DUAL_MONO ) )
{
+#ifndef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
tmp = BASOP_Util_Divide1616_Scale( sts[0]->hTcxCfg->tcx_coded_lines, nSubframes, &tmp_e );
L_spec[0] = shr( tmp, add( 15, negate( tmp_e ) ) );
move16();
@@ -324,6 +325,18 @@ void mctStereoIGF_dec_fx(
tmp = BASOP_Util_Divide1616_Scale( sts[0]->hTcxDec->L_frameTCX, nSubframes, &tmp_e );
L_frameTCX_nSubframe = shr( tmp, add( 15, negate( tmp_e ) ) );
+#else
+ Word16 shr_div, shr_k;
+
+ assert( nSubframes == 1 || nSubframes == 2 );
+ /* Note: nSubframes is in limited range [1, 2] for this function */
+
+ shr_div = sub( nSubframes, 1 ); /* 2 -> 1, 1 -> 0 */
+ L_spec[0] = shr( sts[0]->hTcxCfg->tcx_coded_lines, shr_div );
+ move16();
+ L_frame_nSubframe = shr( sts[0]->L_frame, shr_div );
+ L_frameTCX_nSubframe = shr( sts[0]->hTcxDec->L_frameTCX, shr_div );
+#endif
init_tcx_info_fx( sts[0], L_frame_nSubframe, L_frameTCX_nSubframe, k, bfi, &tcx_offset[0], &tcx_offsetFB[0], &L_frame[0], &L_frameTCX[0], &left_rect[0], &L_spec[0] );
@@ -333,14 +346,28 @@ void mctStereoIGF_dec_fx(
decoder_tcx_IGF_stereo_fx( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, p_x_e, p_x_len, L_frame[0], left_rect[0], k, bfi, 1 /* MCT_flag */ );
// Shifting output with variable exponent back to Q12
+#ifdef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
+ shr_k = sub( 31 - Q12, p_x_e[0][k] );
+#endif
FOR( Word16 i = 0; i < p_x_len[0][k]; i++ )
{
+#ifndef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
p_x[0][k][i] = L_shr( p_x[0][k][i], sub( 31 - Q12, p_x_e[0][k] ) );
+#else
+ p_x[0][k][i] = L_shr( p_x[0][k][i], shr_k );
+#endif
move32();
}
+#ifdef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
+ shr_k = sub( 31 - Q12, p_x_e[1][k] );
+#endif
FOR( Word16 i = 0; i < p_x_len[1][k]; i++ )
{
+#ifndef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
p_x[1][k][i] = L_shr( p_x[1][k][i], sub( 31 - Q12, p_x_e[1][k] ) );
+#else
+ p_x[1][k][i] = L_shr( p_x[1][k][i], shr_k );
+#endif
move32();
}
}
diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c
index 96f15b91d5b7fbaeec4e2106fff0554f2a9fcead..b80bff932e923b09a077d4bad722d61314b63c07 100644
--- a/lib_dec/ivas_mdct_core_dec.c
+++ b/lib_dec/ivas_mdct_core_dec.c
@@ -1168,7 +1168,12 @@ void ivas_mdct_core_reconstruct_fx(
}
synth_fx = synth_buf_fx + st->hTcxDec->old_synth_len;
synthFB_fx = synth_bufFB_fx + st->hTcxDec->old_synth_lenFB;
-
+ test();
+ if ( is_zero_arr16( st->hTcxDec->old_synth, st->hTcxDec->old_synth_len ) && is_zero_arr16( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB ) )
+ {
+ st->hTcxDec->q_old_synth = 0;
+ move16();
+ }
Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth
Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth
q_syn = st->hTcxDec->q_old_synth;
diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c
index fbbe2a6fe6e5e536e704f74d781635cc64d7780a..59a560f3318c21af5da8ad9b7f2a3d90fb84e8c7 100644
--- a/lib_dec/ivas_out_setup_conversion.c
+++ b/lib_dec/ivas_out_setup_conversion.c
@@ -50,11 +50,9 @@
*----------------------------------------------------------------------------------*/
-#define LS_OUT_CONV_SMOOTHING_FACTOR_Q31 93415539
-#define LS_OUT_CONV_CLIP_FACTOR_MAX_Q29 1073741824
-#define LS_OUT_CONV_CLIP_FACTOR_MAX_SQ_Q28 1073741824
-#define LS_OUT_CONV_CLIP_FACTOR_MIN_Q29 161061274
-#define LS_OUT_CONV_CLIP_FACTOR_MIN_SQ_Q28 24159191
+#define LS_OUT_CONV_SMOOTHING_FACTOR_Q31 93415539
+#define LS_OUT_CONV_CLIP_FACTOR_MAX_Q30 2147483647
+#define LS_OUT_CONV_CLIP_FACTOR_MIN_Q30 322122547
/*----------------------------------------------------------------------------------*
@@ -62,24 +60,12 @@
*----------------------------------------------------------------------------------*/
static void ivas_lssetupconversion_computeEQFactor_fx(
- Word32 *outputEnergy, // Q0
- Word32 *inputEnergy, // Q0
+ Word32 *outputEnergy,
+ Word16 output_exp,
+ Word32 *inputEnergy,
+ Word16 input_exp,
Word32 *EQ )
{
-
- IF( GE_32( L_shr( *outputEnergy, 3 ), Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MAX_SQ_Q28, *inputEnergy ) ) )
- {
- *EQ = L_shl_sat( LS_OUT_CONV_CLIP_FACTOR_MAX_Q29, 1 ); // Q30
- move32();
- return;
- }
- IF( LE_32( L_shr( *outputEnergy, 3 ), Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MIN_SQ_Q28, *inputEnergy ) ) )
- {
- *EQ = L_shl_sat( LS_OUT_CONV_CLIP_FACTOR_MIN_Q29, 1 ); // Q30
- move32();
- return;
- }
-
test();
IF( ( *outputEnergy == 0 ) && ( *inputEnergy == 0 ) )
{
@@ -90,9 +76,16 @@ static void ivas_lssetupconversion_computeEQFactor_fx(
/* Compute the Equalization Gain */
Word16 tmp_e;
Word16 tmp = BASOP_Util_Divide3232_Scale( *outputEnergy, L_add( EPSILON_FX, *inputEnergy ), &tmp_e );
- Word32 tmp_32 = L_shl( (Word32) tmp, 16 );
+ tmp_e = add( tmp_e, sub( output_exp, input_exp ) );
+ Word32 tmp_32 = L_deposit_h( tmp );
tmp_32 = Sqrt32( tmp_32, &tmp_e );
- *EQ = L_shr( tmp_32, 1 - tmp_e );
+ *EQ = L_shr_sat( tmp_32, sub( 1, tmp_e ) ); // range of EQ in float 0.3 - 2.0
+ move32();
+
+ *EQ = L_min( *EQ, LS_OUT_CONV_CLIP_FACTOR_MAX_Q30 );
+ *EQ = L_max( *EQ, LS_OUT_CONV_CLIP_FACTOR_MIN_Q30 );
+ move32();
+ move32();
return;
}
@@ -437,10 +430,10 @@ ivas_error ivas_ls_setup_conversion_open_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) );
}
set32_fx( hLsSetUpConversion->targetEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt );
- hLsSetUpConversion->te_prev_exp = 0;
+ hLsSetUpConversion->te_prev_exp[chIdx] = 0;
move16();
set32_fx( hLsSetUpConversion->dmxEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt );
- hLsSetUpConversion->dmx_prev_exp = 0;
+ hLsSetUpConversion->dmx_prev_exp[chIdx] = 0;
move16();
}
FOR( ; chIdx < MAX_CICP_CHANNELS; chIdx++ )
@@ -487,6 +480,13 @@ ivas_error ivas_ls_setup_conversion_open_fx(
}
set32_fx( hLsSetUpConversion->targetEnergyPrev_fx[0], 0, MAX_SFB + 2 );
set32_fx( hLsSetUpConversion->dmxEnergyPrev_fx[0], 0, MAX_SFB + 2 );
+
+#ifdef MSAN_FIX
+ hLsSetUpConversion->te_prev_exp[0] = 0;
+ hLsSetUpConversion->dmx_prev_exp[0] = 0;
+ move16();
+ move16();
+#endif
}
/* Initialize the DMX conversion matrix */
@@ -857,22 +857,32 @@ void ivas_ls_setup_conversion_process_mdct_fx(
} /* end of out channel loop */
/* Step 3: Peform energy smoothing */
+
+ Word16 te_scale = getScaleFactor32( hLsSetUpConversion->targetEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt );
+ scale_sig32( hLsSetUpConversion->targetEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt, te_scale );
+ Word16 dmx_sacle = getScaleFactor32( hLsSetUpConversion->dmxEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt );
+ scale_sig32( hLsSetUpConversion->dmxEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt, dmx_sacle );
+
+ Word16 te_max_e = s_max( sub( 40, shl( q_output, 1 ) ), sub( hLsSetUpConversion->te_prev_exp[0], te_scale ) );
+ Word16 dmx_max_e = s_max( sub( 40, shl( q_output, 1 ) ), sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) );
+
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
- targetEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy[bandIdx] ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] ) );
+ targetEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( targetEnergy[bandIdx], sub( te_max_e, sub( 40, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], sub( te_max_e, sub( hLsSetUpConversion->te_prev_exp[0], te_scale ) ) ) ) );
move32();
- dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy[bandIdx] ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] ) );
+ dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( dmxEnergy[bandIdx], sub( dmx_max_e, sub( 40, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( dmx_max_e, sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) ) ) ) );
move32();
- hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy[bandIdx]; // exp( hLsSetUpConversion->te_prev_exp) (Q0 here)
+ hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy[bandIdx]; /* te_prev_exp = 40 - 2*q_output */
move32();
- hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy[bandIdx]; // exp( hLsSetUpConversion->dmx_prev_exp) (Q0)
+ hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy[bandIdx]; /* dmx_prev_exp = 40 - 2*q_output */
move32();
- hLsSetUpConversion->te_prev_exp = 31;
- move16();
- hLsSetUpConversion->dmx_prev_exp = 31;
- move16();
}
+ hLsSetUpConversion->te_prev_exp[0] = te_max_e; /* te_prev_exp = 40 - 2*q_output */
+ move16();
+ hLsSetUpConversion->dmx_prev_exp[0] = dmx_max_e; /* dmx_prev_exp = 40 - 2*q_output */
+ move16();
+
FOR( i = 0; i < inChannels; ++i )
{
FOR( j = 0; j < L_FRAME48k; ++j )
@@ -901,7 +911,7 @@ void ivas_ls_setup_conversion_process_mdct_fx(
move16();
/* Compute Eq gains */
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain ); // Q(eqGain) = 30
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain ); // Q(eqGain) = 30
FOR( binIdx = start; binIdx < stop; binIdx++ )
{
x[chInIdx][0][binIdx] = Mpy_32_32( L_shl( x[chInIdx][0][binIdx], 1 ), eqGain ); // Q - 1
@@ -921,7 +931,7 @@ void ivas_ls_setup_conversion_process_mdct_fx(
move16();
/* Compute Eq gains */
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain );
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain );
FOR( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
{
@@ -1261,18 +1271,18 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
/* Step 3: Peform energy smoothing */
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
- targetEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], add( output_exp, sub( 2, hLsSetUpConversion->te_prev_exp ) ) ) ) ); /*output_exp + 2*/
+ targetEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], add( output_exp, sub( 2, hLsSetUpConversion->te_prev_exp[0] ) ) ) ) ); /*output_exp + 2*/
move32();
- dmxEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( shl( add( max_e, 2 ), 1 ), hLsSetUpConversion->dmx_prev_exp ) ) ) ); /*2 * (max_e + 2)*/
+ dmxEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( shl( add( max_e, 2 ), 1 ), hLsSetUpConversion->dmx_prev_exp[0] ) ) ) ); /*2 * (max_e + 2)*/
move32();
hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy_fx[bandIdx];
move32();
hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy_fx[bandIdx];
move32();
}
- hLsSetUpConversion->te_prev_exp = add( output_exp, 2 );
+ hLsSetUpConversion->te_prev_exp[0] = add( output_exp, 2 );
move16();
- hLsSetUpConversion->dmx_prev_exp = shl( add( max_e, 2 ), 1 );
+ hLsSetUpConversion->dmx_prev_exp[0] = shl( add( max_e, 2 ), 1 );
move16();
/* Step 4: Perform equalization */
FOR( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ )
@@ -1290,7 +1300,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
move16();
/*Compute Eq gains */
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], &dmxEnergy_fx[bandIdx], &eqGain_fx );
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy_fx[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain_fx );
FOR( binIdx = start; binIdx < stop; binIdx++ )
{
@@ -1308,7 +1318,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
stop = shr( hLsSetUpConversion->sfbOffset[bandIdx + 1], 1 );
/*Compute Eq gains */
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], &dmxEnergy_fx[bandIdx], &eqGain_fx );
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy_fx[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain_fx );
FOR( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
@@ -1481,21 +1491,30 @@ void ivas_lssetupconversion_process_param_mc_fx(
{
IF( channel_active[chOutIdx] )
{
+ Word16 te_scale = getScaleFactor32( hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt );
+ scale_sig32( hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt, te_scale );
+ Word16 dmx_sacle = getScaleFactor32( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt );
+ scale_sig32( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt, dmx_sacle );
+
+ Word16 te_max_e = s_max( sub( 50, shl( q_output, 1 ) ), sub( hLsSetUpConversion->te_prev_exp[chOutIdx], te_scale ) );
+ Word16 dmx_max_e = s_max( sub( 50, shl( q_output, 1 ) ), sub( hLsSetUpConversion->dmx_prev_exp[chOutIdx], dmx_sacle ) );
+
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
- targetEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy[chOutIdx][bandIdx] ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx][bandIdx] ) );
+ targetEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( targetEnergy[chOutIdx][bandIdx], sub( te_max_e, sub( 50, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx][bandIdx], sub( te_max_e, sub( hLsSetUpConversion->te_prev_exp[chOutIdx], te_scale ) ) ) ) );
move32();
- dmxEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy[chOutIdx][bandIdx] ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx] ) );
+ dmxEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( dmxEnergy[chOutIdx][bandIdx], sub( dmx_max_e, sub( 50, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx], sub( dmx_max_e, sub( hLsSetUpConversion->dmx_prev_exp[chOutIdx], dmx_sacle ) ) ) ) );
move32();
hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx][bandIdx] = targetEnergy[chOutIdx][bandIdx]; // Q0
move32();
hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx] = dmxEnergy[chOutIdx][bandIdx]; // Q0
move32();
- hLsSetUpConversion->te_prev_exp = 31;
- move16();
- hLsSetUpConversion->dmx_prev_exp = 31;
- move16();
}
+
+ hLsSetUpConversion->te_prev_exp[chOutIdx] = te_max_e; /* te_prev_exp = 50 - 2*q_output */
+ move16();
+ hLsSetUpConversion->dmx_prev_exp[chOutIdx] = dmx_max_e; /* dmx_prev_exp = 50 - 2*q_output */
+ move16();
}
}
@@ -1517,7 +1536,7 @@ void ivas_lssetupconversion_process_param_mc_fx(
{
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[chOutIdx][bandIdx], &dmxEnergy[chOutIdx][bandIdx], &EQ ); // Q(EQ) = Q30
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[chOutIdx][bandIdx], hLsSetUpConversion->te_prev_exp[chOutIdx], &dmxEnergy[chOutIdx][bandIdx], hLsSetUpConversion->dmx_prev_exp[chOutIdx], &EQ ); // Q(EQ) = Q30
Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] = Mpy_32_32( L_shl( Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx], 1 ), EQ );
move32();
Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] = Mpy_32_32( L_shl( Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx], 1 ), EQ );
diff --git a/lib_dec/ivas_range_uni_dec.c b/lib_dec/ivas_range_uni_dec.c
index 785d5e9f5fab45c3341e2200eddf200ac93839fc..3da244dd875ca003fc9ffdfedf8c716b23b3241f 100644
--- a/lib_dec/ivas_range_uni_dec.c
+++ b/lib_dec/ivas_range_uni_dec.c
@@ -397,7 +397,7 @@ UWord16 rc_uni_dec_read_bits(
FOR( tmp = range; tmp <= low; tmp += range )
{
- val = add( val, 1 );
+ val = UL_addNsD( val, 1 );
}
/* in case of bitstream errors it is possible that val >= (1 << bits) */
diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c
index 09bec559913c3bceeb66ddf44617b6596a56ca86..e27bc063809994fe3b4b035f7e2632c97890831d 100644
--- a/lib_dec/ivas_sba_dec.c
+++ b/lib_dec/ivas_sba_dec.c
@@ -38,6 +38,7 @@
#include "prot.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
+#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
#include
diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
index 75e0156d87bd87a83df6ac10911b30da12f95da7..216888fbe0a87dbe439801dfacb57441400b2bad 100644
--- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
+++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
@@ -37,6 +37,7 @@
#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
+#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_com_fx.h"
#include "ivas_rom_dec.h"
diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c
index 8d8df9e867bc2203b97d475fe3132e0e027d09c6..fdace42d822ae5e85b084285873d70df63bad336 100644
--- a/lib_dec/ivas_spar_decoder.c
+++ b/lib_dec/ivas_spar_decoder.c
@@ -39,6 +39,7 @@
#include "string.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
+#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
#include "ivas_stat_com.h"
diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c
index 11185330c8df8d75f8253ac6a6a74f98cf725ee3..3ee0f8e8c7a041648d0ade0266b758032e78a0d1 100644
--- a/lib_dec/ivas_stereo_dft_dec_fx.c
+++ b/lib_dec/ivas_stereo_dft_dec_fx.c
@@ -448,9 +448,9 @@ static void stereo_dft_dequantize_res_gains_fx(
FOR( i = 0; i < N; i++ )
{
/* Ensure the indices are within range -- may go out of range due to frame loss */
- ind1[i] = check_bounds_s( ind1[i], 0, 30 ); /* Q0 */
+ ind1[i] = check_bounds_s_fx( ind1[i], 0, 30 ); /* Q0 */
move16();
- ind2[i] = check_bounds_s( ind2[i], 0, 7 ); /* Q0 */
+ ind2[i] = check_bounds_s_fx( ind2[i], 0, 7 ); /* Q0 */
move16();
IF( LE_16( ind1[i], 15 ) )
{
diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c
index a65f36f41ebc6115e4234c268e6c532a210377aa..44dcda09b00bfe421e5ea67b352ccd6dec1363d3 100644
--- a/lib_dec/ivas_stereo_mdct_stereo_dec.c
+++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c
@@ -32,11 +32,12 @@
#include
#include
-#include "options.h"
#include
+#include "options.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "prot.h"
+#include "rom_com.h"
#include "wmc_auto.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
@@ -719,20 +720,7 @@ static void update_exp(
}
return;
}
-static Word16 norm_arr(
- Word16 *arr,
- Word32 size /* Q0 */
-)
-{
- Word16 q = 15;
- move16();
- FOR( Word32 i = 0; i < size; i++ )
- IF( arr[i] != 0 )
- {
- q = s_min( q, norm_s( arr[i] ) );
- }
- return q;
-}
+
void updateBuffersForDmxMdctStereo_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */
const Word16 output_frame, /* i : output frame length Q0*/
diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.c b/lib_dec/jbm_pcmdsp_similarityestimation.c
index a6c56837d8790f86fa896513c25938584c11bf30..b6eeaf0e1856fe28e137b3ae6a02871179854dca 100644
--- a/lib_dec/jbm_pcmdsp_similarityestimation.c
+++ b/lib_dec/jbm_pcmdsp_similarityestimation.c
@@ -40,6 +40,7 @@
#include
#include
#include
+#include
#include "options.h"
#include "wmc_auto.h"
#include "basop_util.h"
diff --git a/lib_dec/jbm_pcmdsp_window.c b/lib_dec/jbm_pcmdsp_window.c
index d3820ddddcdc850ea9ae27855cb8d1f6c1002f9f..ea15ab7a1f62ff8357cc4eae0284c88a7cd45632 100644
--- a/lib_dec/jbm_pcmdsp_window.c
+++ b/lib_dec/jbm_pcmdsp_window.c
@@ -40,6 +40,7 @@
#include "options.h"
#include "jbm_pcmdsp_window.h"
#include "cnst.h"
+#include "basop_util.h"
#include "wmc_auto.h"
/*-----------------------------------------------------------------------*
diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c
index 3dccb3c87db0eb2e1d7c10006fa60e730c271984..b63668b3874d3c812333b36f1af70fcba5691a06 100644
--- a/lib_dec/lib_dec_fx.c
+++ b/lib_dec/lib_dec_fx.c
@@ -29,22 +29,25 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
+
#include "lib_dec.h"
+#include
+#include
+#include
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "prot.h"
#include "ivas_prot_fx.h"
#include "prot_fx.h"
+
#include "jbm_jb4sb.h"
#include "jbm_pcmdsp_apa.h"
#include "jbm_pcmdsp_fifo.h"
-#include
-#include
-#include
#include "wmc_auto.h"
#define INV_1000_Q31 2147484 /*1/1000 IN Q31*/
+
/*---------------------------------------------------------------------*
* Local structs
*---------------------------------------------------------------------*/
diff --git a/lib_dec/rom_dec.c b/lib_dec/rom_dec.c
index 6e33e724f8acec1d42667e93307ac026b0d8184a..787966f729af56f474673502dad9aecaff4fbaf1 100644
--- a/lib_dec/rom_dec.c
+++ b/lib_dec/rom_dec.c
@@ -37,6 +37,7 @@
#include
#include "options.h"
#include "cnst.h"
+#include "typedef.h"
#include "wmc_auto.h"
/* clang-format off */
diff --git a/lib_dec/rom_dec.h b/lib_dec/rom_dec.h
index f6d35b43f51d94084bd279c3259d5f4f13f30093..f057b804a6080d3830eee5c671cab44a4453aa66 100644
--- a/lib_dec/rom_dec.h
+++ b/lib_dec/rom_dec.h
@@ -40,6 +40,7 @@
#include
#include "options.h"
#include "cnst.h"
+#include "typedef.h"
extern const Word16 h_low_fx[5]; // Q15
extern const Word16 inv_sqi[15]; // Q15
diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c
index 1dcc5c111603f6ac4fbb50eeb0838ddcfc83d865..0f9863bdfc2bc874bbb7f9618a01d84365d71819 100644
--- a/lib_dec/swb_bwe_dec.c
+++ b/lib_dec/swb_bwe_dec.c
@@ -579,7 +579,8 @@ Word16 swb_bwe_dec_fx32(
}
/* time envelope shaping when the current frame is TRANSIENT frame */
- time_envelop_shaping_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb );
+ time_envelop_shaping_ivas_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb );
+
Q_syn_hb = sub( Q_syn_hb, 3 );
hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3];
diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c
index d73f17fd7540630ac9a00ca2a2793f460c766bbb..8c2387e53497fe35ad9061d5a68c03210e98c75d 100644
--- a/lib_dec/swb_tbe_dec.c
+++ b/lib_dec/swb_tbe_dec.c
@@ -1239,10 +1239,12 @@ void ivas_swb_tbe_dec_fx(
tmp = i_mult( j, ( LPC_SHB_ORDER + 1 ) );
/* convert LSPs to LP coefficients */
E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER );
+#ifndef FIX_1100_REMOVE_LPC_RESCALING
/* Bring the LPCs to Q12 */
Copy_Scale_sig( lpc_shb_sf_fx + tmp, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_sf_fx[tmp] ), 2 ) );
lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )] = ONE_IN_Q12; // recheck this
move16();
+#endif
}
}
diff --git a/lib_enc/ACcontextMapping_enc.c b/lib_enc/ACcontextMapping_enc.c
deleted file mode 100644
index 250bfcf1ba83a538bcbe37c040e151911684b936..0000000000000000000000000000000000000000
--- a/lib_enc/ACcontextMapping_enc.c
+++ /dev/null
@@ -1,712 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "ivas_prot.h" /* Range coder header file */
-#include "ivas_rom_com.h"
-#include "ivas_rom_enc.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-
-/*-------------------------------------------------------------------*
- * ACcontextMapping_encode2_no_mem_s17_LC()
- *
- * Arithmetic encoder
- *-------------------------------------------------------------------*/
-/*-------------------------------------------------------------------*
- * find_last_nz_pair()
- *
- *
- *-------------------------------------------------------------------*/
-
-static Word16 find_last_nz_pair(
- const Word16 x[],
- const Word16 length,
- const CONTEXT_HM_CONFIG *hm_cfg )
-{
- Word16 last_nz, i;
- const Word16 *tmp;
-
- last_nz = 2;
- move16();
-
- IF( hm_cfg )
- {
- /* mapped kernel */
- tmp = hm_cfg->indexBuffer;
-
- FOR( i = length; i >= 4; i -= 2 )
- {
- test();
- IF( x[tmp[i - 2]] || x[tmp[i - 1]] )
- {
- last_nz = i;
- move16();
- BREAK;
- }
- }
- }
- ELSE
- {
- /* unmapped kernel */
-
- FOR( i = length; i >= 4; i -= 2 )
- {
- test();
- IF( x[i - 2] || x[i - 1] )
- {
- last_nz = i;
- move16();
- BREAK;
- }
- }
- }
-
- return last_nz;
-}
-
-
-/*-------------------------------------------------------------------*
- * ACcontextMapping_encode2_estimate_no_mem_s17_LC()
- *
- *
- *-------------------------------------------------------------------*/
-/*-------------------------------------------------------------------*
- * RCcontextMapping_encode2_estimate_no_mem_s17_LCS()
- *
- * Range coder bit-estimation
- *-------------------------------------------------------------------*/
-
-Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
- Word16 *x, /* Spectral coefficients */
- const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) */
- Word16 *lastnz_out,
- Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */
- const Word16 target, /* Target bits */
- Word16 *stop,
- Word16 mode,
- CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
-)
-{
- /* Common variables */
- Word16 a1, b1;
- Word16 k, pki, lev1;
- UWord16 t;
- Word16 lastnz, lastnz2;
- Word16 rateFlag;
- Word32 bit_estimate_fx;
- Word16 bit_estimate_e;
- Word16 symbol;
- const UWord8 *lookup;
- Word32 nbits2_fx; // Q23
- Word16 nbits2_e; // Q23
-
- /* Initialization */
- bit_estimate_fx = 2 * ONE_IN_Q29;
- bit_estimate_e = 2;
- move32();
- nbits2_fx = 0;
- nbits2_e = 0;
- move32();
-
- /* bits to encode lastnz */
- k = 1;
- move16();
-
- WHILE( LT_16( k, nt / 2 ) )
- {
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ONE_IN_Q30, 1, &bit_estimate_e );
- k = k << 1;
- /* check while condition */
- }
-
- nbits2_fx = bit_estimate_fx;
- nbits2_e = bit_estimate_e;
-
- IF( hm_cfg )
- {
- Word16 a1_i, b1_i;
- Word16 stop2;
- Word16 total_output_bits;
- Word16 nt_half;
- Word32 c[2], *ctx;
- Word32 p1, p2;
- Word16 ii[2];
- Word16 idx1, idx2, idx;
- Word16 numPeakIndicesOrig = 0, numHoleIndices = 0; /* only to avoid compiler warning */
- move16();
- move16();
-
- /* Rate flag */
- IF( GT_16( target, 400 ) )
- {
- rateFlag = 2 << NBITS_CONTEXT; /* Select context-A for higher bitrates */
- move16();
- }
- ELSE
- {
- rateFlag = 0; /* Select context-B for lower bitrates */
- move16();
- }
-
- nt_half = shr( nt, 1 );
- move16();
- stop2 = 0;
- move16();
- c[0] = c[1] = 0;
- move32();
- move32();
-
- /* Find last non-zero tuple in the mapped domain signal */
- lastnz = find_last_nz_pair( x, nt, hm_cfg );
-
- lastnz2 = 2;
- move16();
-
- /* mapped domain */
- numPeakIndicesOrig = hm_cfg->numPeakIndices;
- move16();
- hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz );
- move16();
- numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices );
-
- /* Mark hole indices beyond lastnz as pruned */
- FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
- {
- hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt );
- move16();
- }
-
- ii[0] = numPeakIndicesOrig;
- move16();
- ii[1] = 0;
- move16();
-
- p1 = p2 = 0; /* to avoid compilation warnings */
- move32();
- move32();
-
- /* Main Loop through the 2-tuples */
- FOR( k = 0; k < lastnz; k += 2 )
- {
- a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg );
- b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg );
-
- idx = s_min( idx1, idx2 );
-
- /* Get context */
- ctx = &c[L_or( p1, p2 )];
-
- t = (UWord16) L_add( *ctx, rateFlag );
- IF( LT_16( nt_half, idx ) )
- {
- t = add( t, ( 1 << NBITS_CONTEXT ) );
- }
-
- /* Init current 2-tuple encoding */
- a1 = (Word16) abs( x[a1_i] );
- b1 = (Word16) abs( x[b1_i] );
- lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e );
-
- /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
- lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* check while condition */
- /* MSBs coding */
- WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
- {
- pki = lookup[lev1]; /* ESC symbol */
-
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane */
-
- ( a1 ) = shr( a1, 1 );
- ( b1 ) = shr( b1, 1 );
-
- lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* check while condition */
- }
-
- pki = lookup[lev1];
-
- symbol = add( a1, i_mult( A_THRES, b1 ) );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e );
-
- /* Should we truncate? */
- IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) )
- {
- stop2 = 1;
- move16();
-
- IF( *stop )
- {
- BREAK;
- }
- }
- ELSE
- {
- lastnz2 = add( b1_i, 1 );
- nbits2_fx = bit_estimate_fx;
- move32();
- nbits2_e = bit_estimate_e;
- move16();
- }
-
- /* Update context for next 2-tuple */
- IF( EQ_32( p1, p2 ) ) /* peak-peak or hole-hole context */
- {
- lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
-
- IF( lev1 <= 0 )
- {
- t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) );
- }
- ELSE
- {
- t = add( 13, lev1 );
- }
-
- *ctx = L_add( imult3216( L_and( *ctx, 0xf ), 16 ), t );
- move32();
- }
- ELSE
- {
- /* mixed context */
-
- IF( s_and( idx1, 1 ) )
- {
- /* update first context */
- c[p1] = update_mixed_context_ivas_fx( c[p1], (Word16) abs( x[a1_i] ) );
- move32();
- }
-
- IF( s_and( idx2, 1 ) )
- {
- /* update second context */
- c[p2] = update_mixed_context_ivas_fx( c[p2], (Word16) abs( x[b1_i] ) );
- move32();
- }
- }
-
- } /*end of the 2-tuples loop*/
-
- total_output_bits = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) );
-
- IF( *stop )
- {
- total_output_bits = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) );
- }
-
- IF( stop2 )
- {
- stop2 = total_output_bits;
- move16();
- }
-
- *nEncoded = lastnz2;
- move16();
- *stop = stop2; /* If zero, it means no overflow occured during bit-estimation */
- move16();
- *lastnz_out = lastnz;
- move16();
-
- /* Restore hole indices beyond lastnz */
- FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
- {
- hm_cfg->holeIndices[k] = sub( hm_cfg->holeIndices[k], nt );
- move16();
- }
- hm_cfg->numPeakIndices = numPeakIndicesOrig;
- move16();
-
- return round_fx( L_add( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ), ONE_IN_Q14 ) );
- }
- ELSE /* if (!hm_cfg) */
- {
- Word16 esc_nb, cp, rateQ;
- UWord16 s;
- Word16 tot_bits2;
- Word16 overflow_flag = 0;
-
- /* Rate flag */
- IF( GT_16( target, 400 ) )
- {
- rateFlag = 2;
- move16();
- }
- ELSE
- {
- rateFlag = 0; /* Select context-B for lower bitrates */
- move16();
- }
-
- t = 0;
- move16();
- s = 0;
- move16();
- cp = 0;
- move16();
- lastnz = 1;
- move16();
- lastnz2 = 0;
- move16();
- tot_bits2 = 0;
- move16();
-
- /* Find last non-zero tuple in the mapped domain signal */
- FOR( lastnz = sub( nt, 2 ); lastnz >= 0; lastnz -= 2 )
- {
- test();
- IF( ( x[lastnz] != 0 ) || ( x[lastnz + 1] != 0 ) )
- {
- BREAK;
- }
- }
- lastnz = add( lastnz, 2 );
- IF( LT_16( lastnz, 2 ) )
- {
- lastnz = 2; /* At least one tuple is coded */
- move16();
- }
-
- lastnz2 = 2;
- move16();
-
- /* Main Loop through the 2-tuples */
- FOR( k = 0; k < lastnz; k += 2 )
- {
- /* Init current 2-tuple encoding */
- a1 = abs_s( x[k] );
- b1 = abs_s( x[k + 1] );
- lev1 = 0;
- move16();
- esc_nb = 0;
- move16();
- rateQ = add( rateFlag, (Word16) GT_16( k, shr( nt, 1 ) ) );
-
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e );
-
- /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
- lookup = &ari_lookup_s17_LC[t + shl( rateQ, NBITS_CONTEXT )];
-
- /* check while condition */
- /* MSBs coding */
- WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
- {
- pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
-
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane */
-
- ( a1 ) = shr( a1, 1 );
- ( b1 ) = shr( b1, 1 );
-
- lev1 = add( lev1, 1 );
- esc_nb = s_min( lev1, 3 );
-
- /* check while condition */
- }
-
- pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
-
- symbol = add( a1, i_mult( A_THRES, b1 ) );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e );
-
- /* Should we truncate? */
- IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) ) /* Overflow occured */
- {
- overflow_flag = 1;
- move16();
- }
- ELSE
- {
- IF( abs_s( x[k] ) || abs_s( x[k + 1] ) ) /* No overflow & non-zero tuple */
- {
- nbits2_fx = bit_estimate_fx;
- nbits2_e = bit_estimate_e;
- move32();
- lastnz2 = add( k, 2 );
- }
- }
-
- /* Update context for next 2-tuple */
- IF( LT_16( esc_nb, 2 ) )
- {
- cp = add( 1, i_mult( add( a1, b1 ), add( esc_nb, 1 ) ) );
- }
- ELSE
- {
- cp = add( 12, esc_nb );
- }
- /*shift old bits and replace last 4 bits*/
- s = ( s << 4 ) + cp;
- t = ( s & 0xFF );
-
- } /*end of the 2-tuples loop*/
-
- tot_bits2 = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) );
- IF( lastnz2 < lastnz ) /* Overflow occured because unable to code all tuples */
- {
- overflow_flag = 1;
- move16();
- }
- IF( EQ_16( mode, -1 ) )
- {
- tot_bits2 = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) );
- }
- IF( overflow_flag == 0 ) /* No overflow */
- {
- *stop = 0;
- move16();
- }
- ELSE /* Overflow */
- {
- IF( *stop ){
- *stop = tot_bits2;
- move16();
- }
- ELSE
- {
- *stop = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) );
- move16();
- }
-}
-
-*lastnz_out = lastnz;
-move16();
-*nEncoded = lastnz2;
-move16();
-/* Safety mechanism to avoid overflow */
-test();
-IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) )
-{
- FOR( k = 0; k < lastnz2; k++ )
- {
- x[k] = 0;
- move16();
- }
-}
-
-return tot_bits2;
-}
-}
-
-/*-------------------------------------------------------------------*
- * RCcontextMapping_encode2_estimate_bandWise_start()
- *
- * Range coder - start bandwise bit-estimation
- *-------------------------------------------------------------------*/
-
-Word16 RCcontextMapping_encode2_estimate_bandWise_start(
- Word16 *x,
- const Word16 nt,
- const Word16 target,
- HANDLE_RC_CONTEXT_MEM hContextMem )
-{
- Word16 i, k;
-
- /* Rate flag */
- IF( GT_16( target, 400 ) )
- {
- hContextMem->rateFlag = 2 << NBITS_CONTEXT;
- move16();
- }
- ELSE
- {
- hContextMem->rateFlag = 0;
- move16();
- }
-
- hContextMem->bit_estimate_fx = 2;
- move32();
- hContextMem->bit_estimate_e = Q31;
- move16();
-
-
- /* Init */
- hContextMem->nt_half = shr( nt, 1 );
- move16();
-
- /* bits to encode lastnz */
- k = 1;
- move16();
-
- WHILE( LT_16( k, hContextMem->nt_half ) )
- {
- hContextMem->bit_estimate_fx = L_add( hContextMem->bit_estimate_fx, 1 );
- move32();
-
- k = shl( k, 1 );
- /* check while condition */
- }
-
- /* bits to encode lastnz */
- hContextMem->nbits_old = extract_l( hContextMem->bit_estimate_fx );
- move16();
-
- hContextMem->ctx = 0;
- move16();
- hContextMem->lastnz = 2;
- move16();
-
- /* Find last non-zero tuple */
-
- FOR( i = nt; i >= 4; i -= 2 )
- {
- test();
- IF( x[i - 2] != 0 || x[i - 1] != 0 )
- {
- hContextMem->lastnz = i;
- move16();
- break;
- }
- }
- Word16 tmp2 = extract_l( hContextMem->bit_estimate_fx );
- Word16 tmp = norm_l( hContextMem->bit_estimate_fx );
- hContextMem->bit_estimate_e = sub( Q31, tmp );
- move16();
- hContextMem->bit_estimate_fx = L_shl( hContextMem->bit_estimate_fx, tmp );
- move32();
-
- return tmp2;
-}
-
-/*-------------------------------------------------------------------*
- * RCcontextMapping_encode2_estimate_bandWise()
- *
- * Range coder - bandwise bit-estimation
- *-------------------------------------------------------------------*/
-
-Word16 RCcontextMapping_encode2_estimate_bandWise(
- Word16 *x,
- const Word16 start_line,
- const Word16 end_line,
- HANDLE_RC_CONTEXT_MEM hContextMem )
-{
- Word16 a1, b1, a1_i, b1_i;
- Word16 k, pki, lev1;
- UWord16 t;
- Word16 bandBits = 0;
- move16();
- Word16 total_output_bits; /* No. of bits after finalization */
- Word16 symbol;
- const UWord8 *lookup;
- Word16 idx;
-
- /* Main Loop through the 2-tuples */
- /*hContextMem->nt_half = end_line >> 1;*/
- FOR( k = start_line; k < min( hContextMem->lastnz, end_line ); k += 2 )
- {
- a1_i = k;
- move16();
- b1_i = add( k, 1 );
-
- idx = k;
- move16();
-
- /* Get context */
- t = add( hContextMem->ctx, hContextMem->rateFlag );
- t = add( t, GE_16( hContextMem->nt_half, idx ) ? 0 : ( 1 << NBITS_CONTEXT ) );
-
- /* Init current 2-tuple encoding */
- a1 = abs_s( x[a1_i] );
- b1 = abs_s( x[b1_i] );
- lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* Signs Bits */
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, Q1, &hContextMem->bit_estimate_e );
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, Q1, &hContextMem->bit_estimate_e );
-
- /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
- lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* check while condition */
- /* MSBs coding */
- WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
- {
- pki = lookup[lev1];
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], Q8, &hContextMem->bit_estimate_e );
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, 2 * ONE_IN_Q29, Q2, &hContextMem->bit_estimate_e ); /* Add the 2 LSB bits that were shifted out */
- // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC];
- // hContextMem->bit_estimate += 2; /* Add the 2 LSB bits that were shifted out */
-
- ( a1 ) = shr( a1, 1 );
- ( b1 ) = shr( b1, 1 );
-
- lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
- /* check while condition */
- }
-
- pki = lookup[lev1];
- symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol */
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], Q8, &hContextMem->bit_estimate_e );
- // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol];
-
- /* Update context */
- lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
-
- IF( lev1 <= 0 )
- {
- t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) );
- }
- ELSE
- {
- t = add( 13, lev1 );
- }
-
- hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t );
-
- } /*end of the 2-tuples loop*/
- total_output_bits = round_fx( L_shr( hContextMem->bit_estimate_fx, sub( Q15, hContextMem->bit_estimate_e ) ) );
- // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f );
-
- bandBits = sub( total_output_bits, hContextMem->nbits_old );
- hContextMem->nbits_old = total_output_bits;
- move16();
-
- return bandBits;
-}
diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c
index 21089de9fd00cfbd08cbc87a2f430cc26fd55f69..bae26790190447ebef64e2a6b592056991fff8d6 100644
--- a/lib_enc/ACcontextMapping_enc_fx.c
+++ b/lib_enc/ACcontextMapping_enc_fx.c
@@ -7,11 +7,14 @@
#include "options.h"
#include "basop_util.h"
#include "cnst.h"
+#include "prot.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
+#include "ivas_rom_enc.h"
#include "prot_fx_enc.h"
+#include "ivas_prot.h" /* Range coder header file */
/*-------------------------------------------------------------------*
* ACcontextMapping_encode2_no_mem_s17_LC_fx()
@@ -29,11 +32,11 @@
*/
void ACcontextMapping_encode2_no_mem_s17_LC_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word16 *x,
- Word16 nt,
- Word16 lastnz,
- Word16 nbbits,
- Word16 resQMaxBits,
+ Word16 *x, /* Q0 */
+ Word16 nt, /* Q0 */
+ Word16 lastnz, /* Q0 */
+ Word16 nbbits, /* Q0 */
+ Word16 resQMaxBits, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg )
{
Word16 ptr[BITBUFSIZE];
@@ -57,7 +60,8 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
a1 = 0; /* to avoid compilation warnings */
b1 = 0; /* to avoid compilation warnings */
-
+ move16();
+ move16();
/* Rate flag */
rateFlag = 0;
@@ -75,41 +79,41 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
/* Bits for encoding the number of encoded tuples */
- nbbits_ntuples = sub( 14, norm_s( negate( nt ) ) );
+ nbbits_ntuples = sub( 14, norm_s( negate( nt ) ) ); /* Q0 */
t = 0;
move16();
- bp = nbbits_ntuples;
+ bp = nbbits_ntuples; /* Q0 */
move16();
nbbits_signs = 0;
move16();
nbbits_lsbs = 0;
move16();
- nbbits_m2 = sub( nbbits, 2 );
+ nbbits_m2 = sub( nbbits, 2 ); /* Q0 */
flag_overflow = 0;
move16();
IF( hm_cfg ) /* mapped domain */
{
- numPeakIndicesOrig = hm_cfg->numPeakIndices;
+ numPeakIndicesOrig = hm_cfg->numPeakIndices; /* Q0 */
move16();
- hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz );
+ hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); /* Q0 */
move16();
- numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices );
+ numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); /* Q0 */
/* Mark hole indices beyond lastnz as pruned */
FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
{
- hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt );
+ hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt ); /* Q0 */
move16();
}
- ii[0] = numPeakIndicesOrig;
+ ii[0] = numPeakIndicesOrig; /* Q0 */
move16();
ii[1] = 0;
move16();
- get_next_coeff = get_next_coeff_mapped;
+ get_next_coeff = get_next_coeff_mapped; /* Q0 */
move16();
}
ELSE /* unmapped domain */
@@ -121,7 +125,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
move16();
- get_next_coeff = get_next_coeff_unmapped;
+ get_next_coeff = get_next_coeff_unmapped; /* Q0 */
move16();
/* Find last non-zero tuple */
@@ -133,7 +137,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
WHILE( s_or( x[lastnz - 1], x[lastnz - 2] ) == 0 )
{
- lastnz = sub( lastnz, 2 );
+ lastnz = sub( lastnz, 2 ); /* Q0 */
}
x[0] = a1;
move16();
@@ -150,21 +154,20 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
FOR( k = 0; k < lastnz; k += 2 )
{
/* First coefficient */
- a1_i = get_next_coeff( ii, &p1, &idx1, hm_cfg );
+ a1_i = get_next_coeff( ii, &p1, &idx1, hm_cfg ); /* Q0 */
/* Second coefficient */
- b1_i = get_next_coeff( ii, &p2, &idx2, hm_cfg );
+ b1_i = get_next_coeff( ii, &p2, &idx2, hm_cfg ); /* Q0 */
- idx = s_min( idx1, idx2 );
+ idx = s_min( idx1, idx2 ); /* Q0 */
/* Get context */
- ctx = &c[s_or( p1, p2 )];
- move16();
+ ctx = &c[s_or( p1, p2 )]; /* Q0 */
/* _DIFF_FLOAT_FIX_ float is using t as UWord16 */
- t = add( *ctx, rateFlag );
+ t = add( *ctx, rateFlag ); /* Q0 */
if ( GT_16( idx, nt_half ) )
{
- t = add( t, 1 << NBITS_CONTEXT );
+ t = add( t, 1 << NBITS_CONTEXT ); /* Q0 */
}
/* Init current 2-tuple encoding */
@@ -179,43 +182,43 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
}
- a1 = abs_s( x[a1_i] );
- b1 = abs_s( x[b1_i] );
+ a1 = abs_s( x[a1_i] ); /* Q0 */
+ b1 = abs_s( x[b1_i] ); /* Q0 */
lev1 = -1;
move16();
/*Copy states*/
ari_copy_states_fx( &as, &as_overflow );
- bp_overflow = bp;
+ bp_overflow = bp; /* Q0 */
move16();
- nbbits_signs_overflow = nbbits_signs;
+ nbbits_signs_overflow = nbbits_signs; /* Q0 */
move16();
- nbbits_lsbs_overflow = nbbits_lsbs;
+ nbbits_lsbs_overflow = nbbits_lsbs; /* Q0 */
move16();
/*Signs encoding*/
- signs[nbbits_signs] = lshr( x[a1_i], 15 );
+ signs[nbbits_signs] = lshr( x[a1_i], 15 ); /* Q0 */
move16();
if ( a1 > 0 )
{
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
- signs[nbbits_signs] = lshr( x[b1_i], 15 );
+ signs[nbbits_signs] = lshr( x[b1_i], 15 ); /* Q0 */
move16();
if ( b1 > 0 )
{
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
/* MSBs coding */
WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
{
- tmp = add( t, Tab_esc_nb[lev1 + 1] );
+ tmp = add( t, Tab_esc_nb[lev1 + 1] ); /* Q0 */
assert( tmp >= 0 && tmp < 4096 );
- pki = ari_lookup_s17_LC[tmp];
+ pki = ari_lookup_s17_LC[tmp]; /* Q0 */
move16();
- bp = ari_encode_14bits_ext_fx( ptr, bp, &as, VAL_ESC, ari_pk_s17_LC_ext[pki] );
+ bp = ari_encode_14bits_ext_fx( ptr, bp, &as, VAL_ESC, ari_pk_s17_LC_ext[pki] ); /* Q0 */
*lsbs_bits2-- = s_and( a1, 1 );
move16();
@@ -223,32 +226,32 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
/* LSBs bit counting */
- nbbits_lsbs = add( nbbits_lsbs, 2 );
+ nbbits_lsbs = add( nbbits_lsbs, 2 ); /* Q0 */
a1 = shr( a1, 1 );
b1 = shr( b1, 1 );
- lev1 = s_min( add( lev1, 1 ), 2 );
+ lev1 = s_min( add( lev1, 1 ), 2 ); /* Q0 */
}
- tmp = add( t, Tab_esc_nb[lev1 + 1] );
+ tmp = add( t, Tab_esc_nb[lev1 + 1] ); /* Q0 */
assert( tmp >= 0 && tmp < 4096 );
- pki = ari_lookup_s17_LC[tmp];
+ pki = ari_lookup_s17_LC[tmp]; /* Q0 */
move16();
- bp = ari_encode_14bits_ext_fx( ptr, bp, &as, add( a1, shl( b1, A_THRES_SHIFT ) ), ari_pk_s17_LC_ext[pki] );
+ bp = ari_encode_14bits_ext_fx( ptr, bp, &as, add( a1, shl( b1, A_THRES_SHIFT ) ), ari_pk_s17_LC_ext[pki] ); /* Q0 */
/* Check bit budget */
IF( GT_16( add( add( add( bp, extract_l( as.value ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
{
ari_copy_states_fx( &as_overflow, &as );
- bp = bp_overflow;
+ bp = bp_overflow; /* Q0 */
move16();
IF( flag_overflow == 0 )
{
- nbbits_signs = nbbits_signs_overflow;
+ nbbits_signs = nbbits_signs_overflow; /* Q0 */
move16();
- nbbits_lsbs = nbbits_lsbs_overflow;
+ nbbits_lsbs = nbbits_lsbs_overflow; /* Q0 */
move16();
IF( hm_cfg )
{
@@ -264,14 +267,14 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
assert( t >= 0 && t < 4096 );
- pki = ari_lookup_s17_LC[t];
+ pki = ari_lookup_s17_LC[t]; /* Q0 */
move16();
- bp = ari_encode_14bits_ext_fx( ptr, bp, &as, 0, ari_pk_s17_LC_ext[pki] );
+ bp = ari_encode_14bits_ext_fx( ptr, bp, &as, 0, ari_pk_s17_LC_ext[pki] ); /* Q0 */
IF( GT_16( add( add( add( bp, extract_l( as.value ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
{
ari_copy_states_fx( &as_overflow, &as );
- bp = bp_overflow;
+ bp = bp_overflow; /* Q0 */
move16();
BREAK;
}
@@ -297,27 +300,27 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
if ( lev1 == 0 )
t = add( t, t );
- *ctx = add( shl( s_and( *ctx, 0xf ), 4 ), add( t, 1 ) );
+ *ctx = add( shl( s_and( *ctx, 0xf ), 4 ), add( t, 1 ) ); /* Q0 */
move16();
}
ELSE /* mixed context */
{
IF( s_and( idx1, 1 ) ) /* update first context */
{
- c[p1] = update_mixed_context( c[p1], abs_s( x[a1_i] ) );
+ c[p1] = update_mixed_context( c[p1], abs_s( x[a1_i] ) ); /* Q0 */
move16();
}
IF( s_and( idx2, 1 ) ) /* update second context */
{
- c[p2] = update_mixed_context( c[p2], abs_s( x[b1_i] ) );
+ c[p2] = update_mixed_context( c[p2], abs_s( x[b1_i] ) ); /* Q0 */
move16();
}
}
} /*end of the 2-tuples loop*/
/* End arithmetic coder, overflow management */
- bp = ari_done_encoding_14bits_fx( ptr, bp, &as );
+ bp = ari_done_encoding_14bits_fx( ptr, bp, &as ); /* Q0 */
/* Overflow is detected */
IF( NE_16( k, lastnz ) )
@@ -325,20 +328,20 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
IF( hm_cfg )
{
/* Fill with zero to be sure that the decoder finishes the MSB decoding at the same position */
- tmp = sub( nbbits, add( nbbits_signs, nbbits_lsbs ) );
+ tmp = sub( nbbits, add( nbbits_signs, nbbits_lsbs ) ); /* Q0 */
set16_fx( &ptr[bp], 0, sub( tmp, bp ) );
bp = tmp;
move16();
}
if ( !hm_cfg )
{
- lastnz = k;
+ lastnz = k; /* Q0 */
move16();
}
}
/* Push number of encoded tuples */
- value = sub( shr( lastnz, 1 ), 1 );
+ value = sub( shr( lastnz, 1 ), 1 ); /* Q0 */
push_next_indice_fx( hBstr, value, nbbits_ntuples );
/* Push arithmetic coded bits */
@@ -346,17 +349,17 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
/* Push sign bits */
push_next_bits_fx( hBstr, signs, nbbits_signs );
- bp = add( bp, nbbits_signs );
+ bp = add( bp, nbbits_signs ); /* Q0 */
/*write residual Quantization bits*/
- tmp = s_min( sub( sub( nbbits, bp ), nbbits_lsbs ), resQMaxBits );
+ tmp = s_min( sub( sub( nbbits, bp ), nbbits_lsbs ), resQMaxBits ); /* Q0 */
FOR( k = 0; k < tmp; k++ )
{
- ptr[nbbits - 1 - nbbits_lsbs - k] = x[nt + k];
+ ptr[nbbits - 1 - nbbits_lsbs - k] = x[nt + k]; /* Q0 */
move16();
}
/* Write filler bits */
- tmp = sub( nbbits, add( bp, nbbits_lsbs ) );
+ tmp = sub( nbbits, add( bp, nbbits_lsbs ) ); /* Q0 */
FOR( ; k < tmp; ++k )
{
ptr[nbbits - 1 - nbbits_lsbs - k] = 0;
@@ -378,7 +381,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
*
*-------------------------------------------------------------------*/
static Word16 find_last_nz_pair(
- const Word16 x[],
+ const Word16 x[], /* Q0 */
Word16 length,
const CONTEXT_HM_CONFIG *hm_cfg )
{
@@ -387,7 +390,7 @@ static Word16 find_last_nz_pair(
if ( hm_cfg )
{
- tmp = hm_cfg->indexBuffer;
+ tmp = hm_cfg->indexBuffer; /* Q0 */
move16();
}
@@ -395,9 +398,9 @@ static Word16 find_last_nz_pair(
move16();
lobs[1] = shr( length, 1 ); /* length/2 */
move16();
- lobs[2] = add( lobs[1], shr( length, 2 ) );
+ lobs[2] = add( lobs[1], shr( length, 2 ) ); /* Q0 */
move16();
- lobs[3] = add( lobs[2], shr( length, 3 ) );
+ lobs[3] = add( lobs[2], shr( length, 3 ) ); /* Q0 */
move16();
last_nz = 0;
@@ -412,11 +415,11 @@ static Word16 find_last_nz_pair(
{
if ( x[tmp[i - 2]] != 0 )
{
- last_nz = s_max( last_nz, i );
+ last_nz = s_max( last_nz, i ); /* Q0 */
}
if ( x[tmp[i - 1]] != 0 )
{
- last_nz = s_max( last_nz, i );
+ last_nz = s_max( last_nz, i ); /* Q0 */
}
}
}
@@ -426,11 +429,11 @@ static Word16 find_last_nz_pair(
{
if ( x[i - 2] != 0 )
{
- last_nz = s_max( last_nz, i );
+ last_nz = s_max( last_nz, i ); /* Q0 */
}
if ( x[i - 1] != 0 )
{
- last_nz = s_max( last_nz, i );
+ last_nz = s_max( last_nz, i ); /* Q0 */
}
}
}
@@ -448,12 +451,12 @@ static Word16 find_last_nz_pair(
*
*-------------------------------------------------------------------*/
Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
- const Word16 *x,
- Word16 nt,
- Word16 *lastnz_out,
- Word16 *nEncoded,
- Word16 target,
- Word16 *stop,
+ const Word16 *x, /* Q0 */
+ Word16 nt, /* Q0 */
+ Word16 *lastnz_out, /* Q0 */
+ Word16 *nEncoded, /* Q0 */
+ Word16 target, /* Q0 */
+ Word16 *stop, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg )
{
Word16 a1, b1, a1_i, b1_i;
@@ -473,6 +476,8 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
Word16 p1, p2;
Word16 ii[2], idx1, idx2, idx;
Word16 numPeakIndicesOrig = 0, numHoleIndices = 0; /* initialize just to avoid compiler warning */
+ move16();
+ move16();
get_next_coeff_function get_next_coeff;
@@ -481,12 +486,12 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
move16();
if ( GT_16( target, 400 ) )
{
- rateFlag = 2 << NBITS_CONTEXT;
+ rateFlag = 2 << NBITS_CONTEXT; /* Q0 */
move16();
}
/* proba coded on 14bits -> proba=1 */
- proba = L_deposit_l( 16384 );
+ proba = L_deposit_l( 16384 ); /* Q0 */
/* Init */
nt_half = shr( nt, 1 );
@@ -497,13 +502,13 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
move16();
/* bits to encode lastnz + 2 bits headroom */
- nbits = sub( 2 + 14, norm_s( sub( nt, 1 ) ) );
- nbits_old = nbits;
+ nbits = sub( 2 + 14, norm_s( sub( nt, 1 ) ) ); /* Q0 */
+ nbits_old = nbits; /* Q0 */
move16();
- nbits = sub( nbits, target );
+ nbits = sub( nbits, target ); /* Q0 */
/* Find last non-zero tuple in the mapped domain signal */
- lastnz = find_last_nz_pair( x, nt, hm_cfg );
+ lastnz = find_last_nz_pair( x, nt, hm_cfg ); /* Q0 */
/* At least one tuple is coded */
lastnz2 = 2;
@@ -511,25 +516,25 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
IF( hm_cfg ) /* mapped domain */
{
- numPeakIndicesOrig = hm_cfg->numPeakIndices;
+ numPeakIndicesOrig = hm_cfg->numPeakIndices; /* Q0 */
move16();
- hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz );
+ hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); /* Q0 */
move16();
- numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices );
+ numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); /* Q0 */
/* Mark hole indices beyond lastnz as pruned */
FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
{
- hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt );
+ hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt ); /* Q0 */
move16();
}
- ii[0] = numPeakIndicesOrig;
+ ii[0] = numPeakIndicesOrig; /* Q0 */
move16();
ii[1] = 0;
move16();
- get_next_coeff = get_next_coeff_mapped;
+ get_next_coeff = get_next_coeff_mapped; /* Q0 */
move16();
}
ELSE /* unmapped domain */
@@ -541,7 +546,7 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
move16();
move16();
- get_next_coeff = get_next_coeff_unmapped;
+ get_next_coeff = get_next_coeff_unmapped; /* Q0 */
move16();
}
@@ -549,38 +554,37 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
FOR( k = 0; k < lastnz; k += 2 )
{
/* First coefficient */
- a1_i = get_next_coeff( ii, &p1, &idx1, hm_cfg );
+ a1_i = get_next_coeff( ii, &p1, &idx1, hm_cfg ); /* Q0 */
/* Second coefficient */
- b1_i = get_next_coeff( ii, &p2, &idx2, hm_cfg );
+ b1_i = get_next_coeff( ii, &p2, &idx2, hm_cfg ); /* Q0 */
- idx = s_min( idx1, idx2 );
+ idx = s_min( idx1, idx2 ); /* Q0 */
/* Get context */
- ctx = &c[s_or( p1, p2 )];
- move16();
+ ctx = &c[s_or( p1, p2 )]; /* Q0 */
- t = add( *ctx, rateFlag );
+ t = add( *ctx, rateFlag ); /* Q0 */
if ( GT_16( idx, nt_half ) )
{
- t = add( t, 1 << NBITS_CONTEXT );
+ t = add( t, 1 << NBITS_CONTEXT ); /* Q0 */
}
/* Init current 2-tuple encoding */
- a1 = abs_s( x[a1_i] );
- b1 = abs_s( x[b1_i] );
+ a1 = abs_s( x[a1_i] ); /* Q0 */
+ b1 = abs_s( x[b1_i] ); /* Q0 */
lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
move16();
/* Signs Bits */
if ( a1 > 0 )
{
- nbits = add( nbits, 1 );
+ nbits = add( nbits, 1 ); /* Q0 */
}
if ( b1 > 0 )
{
- nbits = add( nbits, 1 );
+ nbits = add( nbits, 1 ); /* Q0 */
}
/* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
@@ -599,38 +603,38 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
cum_freq_norm_e = norm_s( cum_freq[0] );
cum_freq_norm = shl( cum_freq[0], cum_freq_norm_e );
proba = Mpy_32_16_1( proba, cum_freq_norm );
- proba = L_shl( proba, sub( 14, cum_freq_norm_e ) );
+ proba = L_shl( proba, sub( 14, cum_freq_norm_e ) ); /* Q14 + cum_freq_norm_e */
/*Number of leading zero computed in one cycle=norm_l() in BASOP*/
nlz = sub( norm_l( proba ), 2 );
- proba = L_shl( proba, sub( nlz, 15 ) );
+ proba = L_shl( proba, sub( nlz, 15 ) ); /* cum_freq_norm_e */
- nbits = add( nbits, nlz );
+ nbits = add( nbits, nlz ); /* Q0 */
/*addition added as shift not done in norm_l(): real shift = 14-nlz*/
/*proba is rounded down on 14 bits ->automatic over-estimation of bit consumption*/
a1 = shr( a1, 1 );
b1 = shr( b1, 1 );
- lev1 = s_min( add( lev1, 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+ lev1 = s_min( add( lev1, 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */
}
- pki = lookup[lev1];
+ pki = lookup[lev1]; /* Q0 */
move16();
- symbol = add( a1, shl( b1, A_THRES_SHIFT ) );
- cum_freq = ari_pk_s17_LC_ext[pki] + symbol; /* address calculation not counted */
+ symbol = add( a1, shl( b1, A_THRES_SHIFT ) ); /* Q0 */
+ cum_freq = ari_pk_s17_LC_ext[pki] + symbol; /* address calculation not counted */
/*p1*p2=proba on 28 bits: p=0.5->power(2,27)*/
cum_freq_norm = sub( cum_freq[0], cum_freq[1] );
cum_freq_norm_e = norm_s( cum_freq_norm );
cum_freq_norm = shl( cum_freq_norm, cum_freq_norm_e );
proba = Mpy_32_16_1( proba, cum_freq_norm );
- proba = L_shl( proba, sub( 15, cum_freq_norm_e ) );
+ proba = L_shl( proba, sub( 15, cum_freq_norm_e ) ); /* Q15 + cum_freq_norm_e */
/*Number of leading zero computed in one cycle=norm_l() in BASOP*/
nlz = sub( norm_l( proba ), 3 );
- proba = L_shl( proba, sub( nlz, 14 ) );
+ proba = L_shl( proba, sub( nlz, 14 ) ); /* cum_freq_norm_e */
- nbits = add( nbits, nlz );
+ nbits = add( nbits, nlz ); /* Q0 */
/*addition added as shift not done in norm_l(): real shift = 14-nlz*/
/*proba is rounded down on 14 bits ->automatic over-estimation of bit consumption*/
@@ -652,15 +656,15 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
test();
IF( hm_cfg || k == 0 || s_or( x[a1_i], x[b1_i] ) )
{
- nbits_old = add( nbits, target );
- lastnz2 = add( b1_i, 1 );
+ nbits_old = add( nbits, target ); /* Q0 */
+ lastnz2 = add( b1_i, 1 ); /* Q0 */
}
}
/* Update context for next 2-tuple */
IF( EQ_16( p1, p2 ) ) /* peak-peak or hole-hole context */
{
- lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
+ lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ ); /* Q0 */
if ( lev1 > 0 )
t = add( 12, lev1 );
if ( lev1 <= 0 )
@@ -668,46 +672,46 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
if ( lev1 == 0 )
t = add( t, t );
- *ctx = add( shl( s_and( *ctx, 0xf ), 4 ), add( t, 1 ) );
+ *ctx = add( shl( s_and( *ctx, 0xf ), 4 ), add( t, 1 ) ); /* Q0 */
move16();
}
ELSE /* mixed context */
{
IF( s_and( idx1, 1 ) ) /* update first context */
{
- c[p1] = update_mixed_context( c[p1], abs_s( x[a1_i] ) );
+ c[p1] = update_mixed_context( c[p1], abs_s( x[a1_i] ) ); /* Q0 */
move16();
}
IF( s_and( idx2, 1 ) ) /* update second context */
{
- c[p2] = update_mixed_context( c[p2], abs_s( x[b1_i] ) );
+ c[p2] = update_mixed_context( c[p2], abs_s( x[b1_i] ) ); /* Q0 */
move16();
}
}
} /* end of the 2-tuples loop */
- nbits = add( nbits, target );
+ nbits = add( nbits, target ); /* Q0 */
/* Output */
if ( *stop )
{
- nbits = nbits_old;
+ nbits = nbits_old; /* Q0 */
move16();
}
if ( stop2 )
{
- stop2 = nbits;
+ stop2 = nbits; /* Q0 */
move16();
}
- *nEncoded = lastnz2;
+ *nEncoded = lastnz2; /* Q0 */
move16();
- *stop = stop2;
+ *stop = stop2; /* Q0 */
move16();
if ( lastnz_out )
{
- *lastnz_out = lastnz;
+ *lastnz_out = lastnz; /* Q0 */
move16();
}
@@ -716,10 +720,10 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
/* Restore hole indices beyond lastnz */
FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
{
- hm_cfg->holeIndices[k] = sub( hm_cfg->holeIndices[k], nt );
+ hm_cfg->holeIndices[k] = sub( hm_cfg->holeIndices[k], nt ); /* Q0 */
move16();
}
- hm_cfg->numPeakIndices = numPeakIndicesOrig;
+ hm_cfg->numPeakIndices = numPeakIndicesOrig; /* Q0 */
move16();
}
@@ -736,12 +740,12 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
*-------------------------------------------------------------------*/
void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word16 *x,
- const Word16 nt,
- Word16 lastnz,
- const Word16 nbbits,
- const Word16 resQMaxBits,
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ Word16 *x, /* Q0 */
+ const Word16 nt, /* Q0 */
+ Word16 lastnz, /* Q0 */
+ const Word16 nbbits, /* Q0 */
+ const Word16 resQMaxBits, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg )
{
Word16 ptr[BITBUFSIZE];
@@ -760,6 +764,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
a1 = 0; /* to avoid compilation warnings */
b1 = 0; /* to avoid compilation warnings */
+ move16();
+ move16();
/* Init */
nt_half = shr( nt, 1 );
@@ -772,7 +778,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
WHILE( LT_16( k, shr( nt, 1 ) ) )
{
- nbbits_ntuples = add( nbbits_ntuples, 1 );
+ nbbits_ntuples = add( nbbits_ntuples, 1 ); /* Q0 */
k = shl( k, 1 );
}
@@ -809,20 +815,20 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
move32();
/* mapped domain */
- numPeakIndicesOrig = hm_cfg->numPeakIndices;
- hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz );
- numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices );
+ numPeakIndicesOrig = hm_cfg->numPeakIndices; /* Q0 */
+ hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); /* Q0 */
+ numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); /* Q0 */
move16();
move16();
/* Mark hole indices beyond lastnz as pruned */
FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
{
- hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt );
+ hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt ); /* Q0 */
move16();
}
- ii[0] = numPeakIndicesOrig;
+ ii[0] = numPeakIndicesOrig; /* Q0 */
ii[1] = 0;
move16();
move16();
@@ -843,15 +849,15 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
FOR( k = 0; k < lastnz; k += 2 )
{
- a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg );
- b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg );
+ a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg ); /* Q0 */
+ b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg ); /* Q0 */
- idx = s_min( idx1, idx2 );
+ idx = s_min( idx1, idx2 ); /* Q0 */
/* Get context */
- ctx = &c[L_or( p1, p2 )];
+ ctx = &c[L_or( p1, p2 )]; /* Q0 */
- t = (UWord16) L_add( *ctx, rateFlag );
+ t = (UWord16) L_add( *ctx, rateFlag ); /* Q0 */
// t += ( nt_half >= idx ) ? 0 : ( 1 << NBITS_CONTEXT );
IF( LT_16( nt_half, idx ) )
{
@@ -859,8 +865,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
}
/* Init current 2-tuple encoding */
- a1 = abs_s( x[a1_i] );
- b1 = abs_s( x[b1_i] );
+ a1 = abs_s( x[a1_i] ); /* Q0 */
+ b1 = abs_s( x[b1_i] ); /* Q0 */
lev1 = -1;
move16();
@@ -879,7 +885,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
signs[nbbits_signs] = 1;
move16();
}
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
IF( b1 > 0 )
@@ -895,13 +901,13 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
signs[nbbits_signs] = 1;
move16();
}
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
/* MSBs coding */
WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
{
- pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
+ pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
move16();
rc_uni_enc_encode_symbol_fastS( &rc_st_enc, VAL_ESC, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode ESC symbol */
@@ -911,15 +917,15 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
move16();
/* LSBs bit counting */
- nbbits_lsbs = add( nbbits_lsbs, 2 );
+ nbbits_lsbs = add( nbbits_lsbs, 2 ); /* Q0 */
a1 = shr( a1, 1 );
b1 = shr( b1, 1 );
- lev1 = s_min( add( lev1, 1 ), 2 );
+ lev1 = s_min( add( lev1, 1 ), 2 ); /* Q0 */
}
- pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
+ pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
move16();
rc_uni_enc_encode_symbol_fastS( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */
@@ -932,14 +938,14 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
IF( lev1 <= 0 )
{
- t = (UWord16) L_add( 1, L_mult0( add( a1, b1 ), add( lev1, 2 ) ) );
+ t = (UWord16) L_add( 1, L_mult0( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */
}
ELSE
{
- t = (UWord16) L_add( 13, lev1 );
+ t = (UWord16) L_add( 13, lev1 ); /* Q0 */
}
- *ctx = L_add( L_shl( L_and( *ctx, 0xf ), 4 ), t );
+ *ctx = L_add( L_shl( L_and( *ctx, 0xf ), 4 ), t ); /* Q0 */
move32();
}
ELSE
@@ -949,14 +955,14 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
IF( s_and( idx1, 1 ) )
{
/* update first context */
- c[p1] = update_mixed_context_ivas_fx( c[p1], abs_s( x[a1_i] ) );
+ c[p1] = update_mixed_context_ivas_fx( c[p1], abs_s( x[a1_i] ) ); /* Q0 */
move32();
}
IF( s_and( idx2, 1 ) )
{
/* update second context */
- c[p2] = update_mixed_context_ivas_fx( c[p2], abs_s( x[b1_i] ) );
+ c[p2] = update_mixed_context_ivas_fx( c[p2], abs_s( x[b1_i] ) ); /* Q0 */
move32();
}
}
@@ -994,7 +1000,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
WHILE( x[lastnz - 1] == 0 && x[lastnz - 2] == 0 )
{
test();
- lastnz = sub( lastnz, 2 );
+ lastnz = sub( lastnz, 2 ); /* Q0 */
}
x[0] = a1;
move16();
@@ -1010,8 +1016,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
{
/* Init current 2-tuple encoding */
- a1 = abs_s( x[k + 0] );
- b1 = abs_s( x[k + 1] );
+ a1 = abs_s( x[k + 0] ); /* Q0 */
+ b1 = abs_s( x[k + 1] ); /* Q0 */
lev1 = 0;
esc_nb = 0;
@@ -1032,7 +1038,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
signs[nbbits_signs] = 1;
move16();
}
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
IF( b1 > 0 )
@@ -1048,10 +1054,10 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
signs[nbbits_signs] = 1;
move16();
}
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
- rateQ = add( rateFlag, (Word16) GT_16( k, shr( nt, 1 ) ) );
+ rateQ = add( rateFlag, extract_l( GT_16( k, shr( nt, 1 ) ) ) );
/* MSBs coding */
WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
@@ -1066,17 +1072,17 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
move16();
/* LSBs bit counting */
- nbbits_lsbs = add( nbbits_lsbs, 2 );
+ nbbits_lsbs = add( nbbits_lsbs, 2 ); /* Q0 */
a1 = shr( a1, 1 );
b1 = shr( b1, 1 );
- lev1 = add( lev1, 1 );
- esc_nb = s_min( lev1, 3 );
+ lev1 = add( lev1, 1 ); /* Q0 */
+ esc_nb = s_min( lev1, 3 ); /* Q0 */
}
move16();
- pki = ari_lookup_s17_LC[t + ( ( rateQ ) << NBITS_CONTEXT ) + ( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
+ pki = ari_lookup_s17_LC[t + ( ( rateQ ) << NBITS_CONTEXT ) + ( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
rc_uni_enc_encode_symbol_fastS( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */
/*Confirm that there is no overflow, i.e. bit-budget has not exceeded */
@@ -1084,11 +1090,11 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
/* Update context for next 2-tuple */
IF( LT_16( esc_nb, 2 ) )
{
- cp = add( 1, imult1616( add( a1, b1 ), add( esc_nb, 1 ) ) );
+ cp = add( 1, imult1616( add( a1, b1 ), add( esc_nb, 1 ) ) ); /* Q0 */
}
ELSE
{
- cp = add( 12, esc_nb );
+ cp = add( 12, esc_nb ); /* Q0 */
}
/*Shift old 4 bits, replace last 4 bits*/
@@ -1099,13 +1105,13 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
}
/* Finish range encoder */
- rc_tot_bits = rc_uni_enc_finish( &rc_st_enc ); /* No. of bits consumed by range coder */
- bp = add( rc_tot_bits, nbbits_ntuples ); /* Update bitstream pointer */
+ rc_tot_bits = rc_uni_enc_finish( &rc_st_enc ); /* No. of bits consumed by range coder Q0*/
+ bp = add( rc_tot_bits, nbbits_ntuples ); /* Update bitstream pointer Q0*/
/* Cross-check that there is no overflow */
/* Push number of encoded tuples */
- value = sub( shr( lastnz, 1 ), 1 );
+ value = sub( shr( lastnz, 1 ), 1 ); /* Q0 */
push_next_indice( hBstr, value, nbbits_ntuples );
/* Push range coded bits from byte_buffer to bitstream */
@@ -1122,13 +1128,13 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
/* Push sign bits */
push_next_bits( hBstr, (UWord16 *) signs, nbbits_signs );
- bp = add( bp, nbbits_signs );
+ bp = add( bp, nbbits_signs ); /* Q0 */
/*write residual Quantization bits*/
FOR( k = 0; k < s_min( nbbits - bp - nbbits_lsbs, resQMaxBits ); k++ )
{
- ptr[nbbits - 1 - nbbits_lsbs - k] = x[nt + k];
+ ptr[nbbits - 1 - nbbits_lsbs - k] = x[nt + k]; /* Q0 */
move16();
}
/* Write filler bits */
@@ -1148,6 +1154,692 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
return;
}
+/*-------------------------------------------------------------------*
+ * find_last_nz_pair_fx()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
+static Word16 find_last_nz_pair_fx(
+ const Word16 x[], /* Q0 */
+ const Word16 length,
+ const CONTEXT_HM_CONFIG *hm_cfg )
+{
+ Word16 last_nz, i;
+ const Word16 *tmp;
+
+ last_nz = 2;
+ move16();
+
+ IF( hm_cfg )
+ {
+ /* mapped kernel */
+ tmp = hm_cfg->indexBuffer;
+
+ FOR( i = length; i >= 4; i -= 2 )
+ {
+ test();
+ IF( x[tmp[i - 2]] || x[tmp[i - 1]] )
+ {
+ last_nz = i; /* Q0 */
+ move16();
+ BREAK;
+ }
+ }
+ }
+ ELSE
+ {
+ /* unmapped kernel */
+
+ FOR( i = length; i >= 4; i -= 2 )
+ {
+ test();
+ IF( x[i - 2] || x[i - 1] )
+ {
+ last_nz = i; /* Q0 */
+ move16();
+ BREAK;
+ }
+ }
+ }
+
+ return last_nz;
+}
+
+
+/*-------------------------------------------------------------------*
+ * RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx()
+ *
+ * Range coder bit-estimation
+ *-------------------------------------------------------------------*/
+
+Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
+ Word16 *x, /* Spectral coefficients Q0*/
+ const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/
+ Word16 *lastnz_out, /* Q0 */
+ Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/
+ const Word16 target, /* Target bits Q0*/
+ Word16 *stop, /* Q0 */
+ Word16 mode, /* Q0 */
+ CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
+)
+{
+ /* Common variables */
+ Word16 a1, b1;
+ Word16 k, pki, lev1;
+ UWord16 t;
+ Word16 lastnz, lastnz2;
+ Word16 rateFlag;
+ Word32 bit_estimate_fx;
+ Word16 bit_estimate_e;
+ Word16 symbol;
+ const UWord8 *lookup;
+ Word32 nbits2_fx; // Q23
+ Word16 nbits2_e;
+
+ /* Initialization */
+ bit_estimate_fx = 2 * ONE_IN_Q29;
+ bit_estimate_e = 2;
+ move32();
+ move16();
+
+ nbits2_fx = 0;
+ nbits2_e = 0;
+ move32();
+ move16();
+
+ /* bits to encode lastnz */
+ k = 1;
+ move16();
+
+ WHILE( LT_16( k, nt / 2 ) )
+ {
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ONE_IN_Q30, 1, &bit_estimate_e );
+ k = k << 1;
+ /* check while condition */
+ }
+
+ nbits2_fx = bit_estimate_fx; /* exp(bit_estimate_e) */
+ nbits2_e = bit_estimate_e;
+ move32();
+ move16();
+
+ IF( hm_cfg )
+ {
+ Word16 a1_i, b1_i;
+ Word16 stop2;
+ Word16 total_output_bits;
+ Word16 nt_half;
+ Word32 c[2], *ctx;
+ Word32 p1, p2;
+ Word16 ii[2];
+ Word16 idx1, idx2, idx;
+ Word16 numPeakIndicesOrig = 0, numHoleIndices = 0; /* only to avoid compiler warning */
+ move16();
+ move16();
+
+ /* Rate flag */
+ IF( GT_16( target, 400 ) )
+ {
+ rateFlag = 2 << NBITS_CONTEXT; /* Select context-A for higher bitrates */
+ move16();
+ }
+ ELSE
+ {
+ rateFlag = 0; /* Select context-B for lower bitrates */
+ move16();
+ }
+
+ nt_half = shr( nt, 1 );
+ move16();
+ stop2 = 0;
+ move16();
+ c[0] = c[1] = 0;
+ move32();
+ move32();
+
+ /* Find last non-zero tuple in the mapped domain signal */
+ lastnz = find_last_nz_pair_fx( x, nt, hm_cfg );
+
+ lastnz2 = 2;
+ move16();
+
+ /* mapped domain */
+ numPeakIndicesOrig = hm_cfg->numPeakIndices; /* Q0 */
+ move16();
+ hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); /* Q0 */
+ move16();
+ numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); /* Q0 */
+
+ /* Mark hole indices beyond lastnz as pruned */
+ FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
+ {
+ hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt ); /* Q0 */
+ move16();
+ }
+
+ ii[0] = numPeakIndicesOrig; /* Q0 */
+ move16();
+ ii[1] = 0;
+ move16();
+
+ p1 = p2 = 0; /* to avoid compilation warnings */
+ move32();
+ move32();
+
+ /* Main Loop through the 2-tuples */
+ FOR( k = 0; k < lastnz; k += 2 )
+ {
+ a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg ); /* Q0 */
+ b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg ); /* Q0 */
+
+ idx = s_min( idx1, idx2 );
+
+ /* Get context */
+ ctx = &c[L_or( p1, p2 )];
+
+ t = (UWord16) L_add( *ctx, rateFlag );
+ IF( LT_16( nt_half, idx ) )
+ {
+ t = add( t, ( 1 << NBITS_CONTEXT ) );
+ }
+
+ /* Init current 2-tuple encoding */
+ a1 = (Word16) abs( x[a1_i] );
+ b1 = (Word16) abs( x[b1_i] );
+ lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */
+
+ /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
+ lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+
+ /* check while condition */
+ /* MSBs coding */
+ WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
+ {
+ pki = lookup[lev1]; /* ESC symbol */
+
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane exp(bit_estimate_e) */
+
+ a1 = shr( a1, 1 );
+ b1 = shr( b1, 1 );
+
+ lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+
+ /* check while condition */
+ }
+
+ pki = lookup[lev1];
+
+ symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */
+
+ /* Should we truncate? */
+ IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) )
+ {
+ stop2 = 1;
+ move16();
+
+ IF( *stop )
+ {
+ BREAK;
+ }
+ }
+ ELSE
+ {
+ lastnz2 = add( b1_i, 1 );
+ nbits2_fx = bit_estimate_fx;
+ move32();
+ nbits2_e = bit_estimate_e;
+ move16();
+ }
+
+ /* Update context for next 2-tuple */
+ IF( EQ_32( p1, p2 ) ) /* peak-peak or hole-hole context */
+ {
+ lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
+
+ IF( lev1 <= 0 )
+ {
+ t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) );
+ }
+ ELSE
+ {
+ t = add( 13, lev1 );
+ }
+
+ *ctx = L_add( imult3216( L_and( *ctx, 0xf ), 16 ), t );
+ move32();
+ }
+ ELSE
+ {
+ /* mixed context */
+
+ IF( s_and( idx1, 1 ) )
+ {
+ /* update first context */
+ c[p1] = update_mixed_context_ivas_fx( c[p1], abs_s( x[a1_i] ) ); /* Q0 */
+ move32();
+ }
+
+ IF( s_and( idx2, 1 ) )
+ {
+ /* update second context */
+ c[p2] = update_mixed_context_ivas_fx( c[p2], abs_s( x[b1_i] ) ); /* Q0 */
+ move32();
+ }
+ }
+
+ } /*end of the 2-tuples loop*/
+
+ total_output_bits = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */
+
+ IF( *stop )
+ {
+ total_output_bits = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) ); /* Q0 */
+ }
+
+ IF( stop2 )
+ {
+ stop2 = total_output_bits; /* Q0 */
+ move16();
+ }
+
+ *nEncoded = lastnz2; /* Q0 */
+ move16();
+ *stop = stop2; /* If zero, it means no overflow occured during bit-estimation Q0*/
+ move16();
+ *lastnz_out = lastnz; /* Q0 */
+ move16();
+
+ /* Restore hole indices beyond lastnz */
+ FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
+ {
+ hm_cfg->holeIndices[k] = sub( hm_cfg->holeIndices[k], nt ); /* Q0 */
+ move16();
+ }
+ hm_cfg->numPeakIndices = numPeakIndicesOrig; /* Q0 */
+ move16();
+
+ return round_fx( L_add( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ), ONE_IN_Q14 ) ); /* Q0 */
+ }
+ ELSE /* if (!hm_cfg) */
+ {
+ Word16 esc_nb, cp, rateQ;
+ UWord16 s;
+ Word16 tot_bits2;
+ Word16 overflow_flag = 0;
+ move16();
+
+ /* Rate flag */
+ IF( GT_16( target, 400 ) )
+ {
+ rateFlag = 2; /* Q0 */
+ move16();
+ }
+ ELSE
+ {
+ rateFlag = 0; /* Select context-B for lower bitrates */
+ move16();
+ }
+
+ t = 0;
+ move16();
+ s = 0;
+ move16();
+ cp = 0;
+ move16();
+ lastnz = 1;
+ move16();
+ lastnz2 = 0;
+ move16();
+ tot_bits2 = 0;
+ move16();
+
+ /* Find last non-zero tuple in the mapped domain signal */
+ FOR( lastnz = sub( nt, 2 ); lastnz >= 0; lastnz -= 2 )
+ {
+ test();
+ IF( ( x[lastnz] != 0 ) || ( x[lastnz + 1] != 0 ) )
+ {
+ BREAK;
+ }
+ }
+ lastnz = add( lastnz, 2 ); /* Q0 */
+ IF( LT_16( lastnz, 2 ) )
+ {
+ lastnz = 2; /* At least one tuple is coded Q0*/
+ move16();
+ }
+
+ lastnz2 = 2;
+ move16();
+
+ /* Main Loop through the 2-tuples */
+ FOR( k = 0; k < lastnz; k += 2 )
+ {
+ /* Init current 2-tuple encoding */
+ a1 = abs_s( x[k] ); /* Q0 */
+ b1 = abs_s( x[k + 1] ); /* Q0 */
+ lev1 = 0;
+ move16();
+ esc_nb = 0;
+ move16();
+ rateQ = add( rateFlag, extract_l( GT_16( k, shr( nt, 1 ) ) ) ); /* Q0 */
+
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */
+
+ /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
+ lookup = &ari_lookup_s17_LC[t + shl( rateQ, NBITS_CONTEXT )]; /* Q0 */
+
+ /* check while condition */
+ /* MSBs coding */
+ WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
+ {
+ pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
+ move16();
+
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane exp(bit_estimate_e) */
+
+ a1 = shr( a1, 1 );
+ b1 = shr( b1, 1 );
+
+ lev1 = add( lev1, 1 );
+ esc_nb = s_min( lev1, 3 );
+
+ /* check while condition */
+ }
+
+ pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
+ move16();
+
+ symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */
+
+ /* Should we truncate? */
+ IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) ) /* Overflow occured */
+ {
+ overflow_flag = 1;
+ move16();
+ }
+ ELSE
+ {
+ IF( abs_s( x[k] ) || abs_s( x[k + 1] ) ) /* No overflow & non-zero tuple */
+ {
+ nbits2_fx = bit_estimate_fx; /* exp(bit_estimate_e) */
+ nbits2_e = bit_estimate_e;
+ move32();
+ move16();
+ lastnz2 = add( k, 2 );
+ }
+ }
+
+ /* Update context for next 2-tuple */
+ IF( LT_16( esc_nb, 2 ) )
+ {
+ cp = add( 1, i_mult( add( a1, b1 ), add( esc_nb, 1 ) ) ); /* Q0 */
+ }
+ ELSE
+ {
+ cp = add( 12, esc_nb ); /* Q0 */
+ }
+ /*shift old bits and replace last 4 bits*/
+ s = (UWord16) L_add( L_shl( s, 4 ), cp );
+ t = s_and( s, 0xFF );
+
+ } /*end of the 2-tuples loop*/
+
+ tot_bits2 = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) );
+ IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */
+ {
+ overflow_flag = 1;
+ move16();
+ }
+ IF( EQ_16( mode, -1 ) )
+ {
+ tot_bits2 = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */
+ }
+ IF( overflow_flag == 0 ) /* No overflow */
+ {
+ *stop = 0;
+ move16();
+ }
+ ELSE /* Overflow */
+ {
+ IF( *stop ){
+ *stop = tot_bits2; /* Q0 */
+ move16();
+ }
+ ELSE
+ {
+ *stop = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */
+ move16();
+ }
+}
+
+*lastnz_out = lastnz; /* Q0 */
+move16();
+*nEncoded = lastnz2; /* Q0 */
+move16();
+/* Safety mechanism to avoid overflow */
+test();
+IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) )
+{
+ FOR( k = 0; k < lastnz2; k++ )
+ {
+ x[k] = 0;
+ move16();
+ }
+}
+
+return tot_bits2;
+}
+}
+
+
+/*-------------------------------------------------------------------*
+ * RCcontextMapping_encode2_estimate_bandWise_start_fx()
+ *
+ * Range coder - start bandwise bit-estimation
+ *-------------------------------------------------------------------*/
+
+Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx(
+ Word16 *x, /* Q0 */
+ const Word16 nt, /* Q0 */
+ const Word16 target, /* Q0 */
+ HANDLE_RC_CONTEXT_MEM hContextMem )
+{
+ Word16 i, k;
+
+ /* Rate flag */
+ IF( GT_16( target, 400 ) )
+ {
+ hContextMem->rateFlag = 2 << NBITS_CONTEXT;
+ move16();
+ }
+ ELSE
+ {
+ hContextMem->rateFlag = 0;
+ move16();
+ }
+
+ hContextMem->bit_estimate_fx = 2; /* Q0 */
+ move32();
+ hContextMem->bit_estimate_e = Q31;
+ move16();
+
+
+ /* Init */
+ hContextMem->nt_half = shr( nt, 1 );
+ move16();
+
+ /* bits to encode lastnz */
+ k = 1;
+ move16();
+
+ WHILE( LT_16( k, hContextMem->nt_half ) )
+ {
+ hContextMem->bit_estimate_fx = L_add( hContextMem->bit_estimate_fx, 1 ); /* exp(bit_estimate_e) */
+ move32();
+
+ k = shl( k, 1 );
+ /* check while condition */
+ }
+
+ /* bits to encode lastnz */
+ hContextMem->nbits_old = extract_l( hContextMem->bit_estimate_fx ); /* Q0 */
+ move16();
+
+ hContextMem->ctx = 0;
+ move16();
+ hContextMem->lastnz = 2;
+ move16();
+
+ /* Find last non-zero tuple */
+
+ FOR( i = nt; i >= 4; i -= 2 )
+ {
+ test();
+ IF( x[i - 2] != 0 || x[i - 1] != 0 )
+ {
+ hContextMem->lastnz = i;
+ move16();
+ BREAK;
+ }
+ }
+ Word16 tmp2 = extract_l( hContextMem->bit_estimate_fx );
+ Word16 tmp = norm_l( hContextMem->bit_estimate_fx );
+ hContextMem->bit_estimate_e = sub( Q31, tmp );
+ move16();
+ hContextMem->bit_estimate_fx = L_shl( hContextMem->bit_estimate_fx, tmp ); /* exp(bit_estimate_e) */
+ move32();
+
+ return tmp2;
+}
+
+/*-------------------------------------------------------------------*
+ * RCcontextMapping_encode2_estimate_bandWise_fx()
+ *
+ * Range coder - bandwise bit-estimation
+ *-------------------------------------------------------------------*/
+
+Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
+ Word16 *x, /* Q0 */
+ const Word16 start_line, /* Q0 */
+ const Word16 end_line, /* Q0 */
+ HANDLE_RC_CONTEXT_MEM hContextMem )
+{
+ Word16 a1, b1, a1_i, b1_i;
+ Word16 k, pki, lev1;
+ UWord16 t;
+ Word16 bandBits = 0;
+ move16();
+ Word16 total_output_bits; /* No. of bits after finalization */
+ Word16 symbol;
+ const UWord8 *lookup;
+ Word16 idx;
+ Word16 tmp;
+
+ /* Main Loop through the 2-tuples */
+ /*hContextMem->nt_half = end_line >> 1;*/
+ FOR( k = start_line; k < min( hContextMem->lastnz, end_line ); k += 2 )
+ {
+ a1_i = k; /* Q0 */
+ move16();
+ b1_i = add( k, 1 ); /* Q0 */
+
+ idx = k;
+ move16();
+
+ /* Get context */
+ t = add( hContextMem->ctx, hContextMem->rateFlag ); /* Q0 */
+
+ IF( GE_16( hContextMem->nt_half, idx ) )
+ {
+ tmp = 0;
+ }
+ ELSE
+ {
+ tmp = ( 1 << NBITS_CONTEXT );
+ }
+
+ t = add( t, tmp ); /* Q0 */
+
+ /* Init current 2-tuple encoding */
+ a1 = abs_s( x[a1_i] ); /* Q0 */
+ b1 = abs_s( x[b1_i] ); /* Q0 */
+ lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */
+
+ /* Signs Bits */
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, imult3216( ONE_IN_Q30, s_min( a1, 1 ) ), Q1, &hContextMem->bit_estimate_e ); /* exp(hContextMem->bit_estimate_e) */
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, imult3216( ONE_IN_Q30, s_min( b1, 1 ) ), Q1, &hContextMem->bit_estimate_e ); /* exp(hContextMem->bit_estimate_e) */
+ move32();
+ move32();
+
+ /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
+ lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+
+ /* check while condition */
+ /* MSBs coding */
+ WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
+ {
+ pki = lookup[lev1]; /* Q0 */
+ move16();
+
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], Q8, &hContextMem->bit_estimate_e ); /* exp(hContextMem->bit_estimate_e) */
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, 2 * ONE_IN_Q29, Q2, &hContextMem->bit_estimate_e ); /* Add the 2 LSB bits that were shifted out exp(hContextMem->bit_estimate_e) */
+ move32();
+ move32();
+
+ // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC];
+ // hContextMem->bit_estimate += 2; /* Add the 2 LSB bits that were shifted out */
+
+ a1 = shr( a1, 1 );
+ b1 = shr( b1, 1 );
+
+ lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */
+ /* check while condition */
+ }
+
+ pki = lookup[lev1]; /* Q0 */
+ move16();
+ symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], Q8, &hContextMem->bit_estimate_e ); /* exp(bit_estimate_e) */
+ move32();
+ // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol];
+
+ /* Update context */
+ lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
+
+ IF( lev1 <= 0 )
+ {
+ t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */
+ }
+ ELSE
+ {
+ t = add( 13, lev1 ); /* Q0 */
+ }
+
+ hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t ); /* Q0 */
+ move16();
+
+ } /*end of the 2-tuples loop*/
+ total_output_bits = round_fx( L_shr( hContextMem->bit_estimate_fx, sub( Q15, hContextMem->bit_estimate_e ) ) ); /* Q0 */
+ // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f );
+
+ bandBits = sub( total_output_bits, hContextMem->nbits_old ); /* Q0 */
+ hContextMem->nbits_old = total_output_bits; /* Q0 */
+ move16();
+
+ return bandBits;
+}
+
+
#ifdef IVAS_CODE_RANGE_CODER
/*-------------------------------------------------------------------*
diff --git a/lib_enc/FEC_enc.c b/lib_enc/FEC_enc.c
deleted file mode 100644
index 3d5aa4f6b215a78e13905dd808f2ecf0e995115d..0000000000000000000000000000000000000000
--- a/lib_enc/FEC_enc.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-#include "ivas_prot_fx.h"
-#include "prot_fx.h"
-
-/*-------------------------------------------------------------------*
- * FEC_encode()
- *
- * Encoder supplementary information for FEC
- *-------------------------------------------------------------------*/
-
-void FEC_encode_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation */
- const Word16 coder_type, /* i : type of coder */
- Word16 clas, /* i : signal clas for current frame */
- const Word16 *fpit, /* i : close loop fractional pitch buffer Q6 */
- const Word16 *res, /* i : LP residual signal frame */
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse */
- const Word16 L_frame, /* i : Frame length */
- const Word32 total_brate, /* i : total codec bitrate */
- const Word16 Q_synth /* i : input scaling */
-)
-{
- Word16 tmpS, index;
- Word16 maxi, sign, tmp_FER_pitch;
- Word32 enr_q, Ltmp;
- Word16 exp_enrq;
-
- tmpS = 0;
- move16();
- enr_q = 1;
- move16();
- sign = 0;
- move16();
- test();
- test();
- IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && acelp_cfg.FEC_mode > 0 )
- {
- /*-----------------------------------------------------------------*
- * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits)
- *-----------------------------------------------------------------*/
- IF( NE_16( coder_type, VOICED ) )
- {
- /* encode signal clas with 2 bits */
- test();
- IF( EQ_16( clas, UNVOICED_CLAS ) )
- {
- index = 0;
- move16();
- }
- ELSE IF( EQ_16( clas, VOICED_TRANSITION ) || EQ_16( clas, UNVOICED_TRANSITION ) )
- {
- index = 1;
- move16();
- }
- ELSE IF( EQ_16( clas, VOICED_CLAS ) )
- {
- index = 2;
- move16();
- }
- ELSE
- {
- index = 3;
- move16();
- }
- push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS );
- }
-
- /*-----------------------------------------------------------------*
- * encode frame energy (5 bits)
- *-----------------------------------------------------------------*/
- test();
- IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */
- {
- /* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */
- /*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/
- Word32 synth32[L_FRAME16k];
- Copy_Scale_sig_16_32( synth, synth32, L_FRAME16k, 0 );
- fer_energy_fx( L_frame, clas, synth32, Q_synth, shr_r( fpit[sub( shr( L_frame, 6 ), 1 )], 6 ), &enr_q, L_frame );
- exp_enrq = sub( 31, shl( Q_synth, 1 ) );
- IF( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */
- {
- exp_enrq = 31;
- move16();
- }
- /* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */
- /*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/
-
- Ltmp = Mpy_32_32( BASOP_Util_Log10( enr_q, exp_enrq ), 894784853 /* 10 / FEC_ENR_STEP Q28 */ ); // Q 25 + 28 - 31 = Q22
- IF( Ltmp < 0 )
- {
- tmpS = extract_l( L_negate( L_shr( L_negate( Ltmp ), Q22 ) ) );
- }
- ELSE
- {
- tmpS = extract_l( L_shr( Ltmp, Q22 ) );
- }
-
- tmpS = s_min( tmpS, FEC_ENR_QLIMIT );
- tmpS = s_max( tmpS, 0 );
-
- push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR );
- }
- /*-----------------------------------------------------------------*
- * Encode last glottal pulse position (8 bits)
- *-----------------------------------------------------------------*/
- test();
- IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */
- {
- /* retrieve the last glottal pulse position of the previous frame */
- /* use the current pitch information to scale or not the quantization */
- tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */
- sign = 0;
- move16();
- maxi = *last_pulse_pos;
- move16();
- IF( maxi < 0 )
- {
- sign = 1;
- move16();
- /*maxi = -maxi; */
- maxi = negate( maxi );
- }
-
- if ( GE_16( tmp_FER_pitch, 128 ) )
- {
- maxi = shr( maxi, 1 );
- }
-
- if ( GT_16( maxi, 127 ) )
- {
- /* better not use the glottal pulse position at all instead of using a wrong pulse */
- /* can happen only with pitch > 254 and max pit = 289 and should happen very rarely */
- maxi = 0;
- move16();
- }
-
- if ( EQ_16( sign, 1 ) )
- {
- maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) */
- }
-
- push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS );
- }
- maxi = 0;
- move16();
-
- /* If bitrate < 24k4, then the pitch
- is not represented in the same domain (12.k instead of 16k) */
- test();
- IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) )
- {
- /*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */
- maxi = findpulse_fx( L_frame, res, shr_r( fpit[sub( shr( L_frame, 6 ), 1 )], 6 ), 0, &sign );
- if ( EQ_16( sign, 1 ) )
- {
- /*maxi = -maxi;*/
- maxi = negate( maxi );
- }
- }
-
- *last_pulse_pos = maxi;
- move16();
- }
- ELSE
- {
- *last_pulse_pos = 0;
- move16();
- }
-
- return;
-}
diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c
index d35f18b61a9dcf5be4bf1727d91abeb852530913..20dced8d7f939e6fed40a47960b823873307fd2e 100644
--- a/lib_enc/FEC_enc_fx.c
+++ b/lib_enc/FEC_enc_fx.c
@@ -5,10 +5,12 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
//#include "prot_fx.h" /* Function prototypes */
-#include "rom_com_fx.h" /* Static table prototypes */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx_enc.h" /* Function prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "prot_fx_enc.h" /* Function prototypes */
+#include "prot.h" /* Function prototypes */
+#include "ivas_prot_fx.h" /* Function prototypes */
/*============================================================================*/
@@ -37,18 +39,18 @@
/* */
/*============================================================================*/
void FEC_encode_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation */
- const Word16 coder_type, /* i : type of coder */
- Word16 clas, /* i : signal clas for current frame */
- const Word16 *fpit, /* i : close loop fractional pitch buffer */
- const Word16 *res, /* i : LP residual signal frame */
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse */
- const Word16 L_frame, /* i : Frame length */
- const Word32 total_brate, /* i : total codec bitrate */
- const Word16 Q_new, /* i : input scaling */
- const Word16 shift /* i : scaling to get 12bits */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
+ const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_synth*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ Word16 clas, /* i : signal clas for current frame Q0*/
+ const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
+ const Word16 *res, /* i : LP residual signal frame Qx*/
+ Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
+ const Word16 L_frame, /* i : Frame length Q0*/
+ const Word32 total_brate, /* i : total codec bitrate Q0*/
+ const Word16 Q_new, /* i : input scaling */
+ const Word16 shift /* i : scaling to get 12bits */
)
{
Word16 tmpS, index;
@@ -99,20 +101,19 @@ void FEC_encode_fx(
/*-----------------------------------------------------------------*
* encode frame energy (5 bits)
*-----------------------------------------------------------------*/
- test();
IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */
{
/* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */
/*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/
- exp_enrq = frame_ener_fx( L_frame, clas, synth, shr_r( fpit[sub( shr( L_frame, 6 ), 1 )], 6 ), &enr_q, L_frame, Q_new, shift, 1 );
+ exp_enrq = frame_ener_fx( L_frame, clas, synth, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), &enr_q, L_frame, Q_new, shift, 1 );
/* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */
/*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/
enr_lg_frac = Log2_norm_lc( enr_q );
- enr_lg_ent = sub( 30, exp_enrq );
- Ltmp = Mpy_32_16( enr_lg_ent, enr_lg_frac, LG10_s3_0 );
- tmpS = extract_h( L_shl( Ltmp, 1 ) );
+ enr_lg_ent = sub( 30, exp_enrq ); /* Q15 */
+ Ltmp = Mpy_32_16( enr_lg_ent, enr_lg_frac, LG10_s3_0 ); /* Q14 */
+ tmpS = extract_h( L_shl( Ltmp, 1 ) ); /* Q15 + 1 -> Q0*/
tmpS = s_min( tmpS, 31 );
tmpS = s_max( tmpS, 0 );
@@ -122,7 +123,6 @@ void FEC_encode_fx(
/*-----------------------------------------------------------------*
* Encode last glottal pulse position (8 bits)
*-----------------------------------------------------------------*/
- test();
IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */
{
/* retrieve the last glottal pulse position of the previous frame */
@@ -130,14 +130,14 @@ void FEC_encode_fx(
tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */
sign = 0;
move16();
- maxi = *last_pulse_pos;
+ maxi = *last_pulse_pos; /* Q0 */
move16();
IF( maxi < 0 )
{
sign = 1;
move16();
/*maxi = -maxi; */
- maxi = negate( maxi );
+ maxi = negate( maxi ); /* Q0 */
}
if ( GE_16( tmp_FER_pitch, 128 ) )
@@ -155,7 +155,7 @@ void FEC_encode_fx(
if ( sign == 1 )
{
- maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) */
+ maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/
}
push_indice_fx( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS );
@@ -169,15 +169,15 @@ void FEC_encode_fx(
IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) )
{
/*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */
- maxi = findpulse_fx( L_frame, res, shr_r( fpit[sub( shr( L_frame, 6 ), 1 )], 6 ), 0, &sign );
+ maxi = findpulse_fx( L_frame, res, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), 0, &sign ); /* Q0 */
if ( sign == 1 )
{
/*maxi = -maxi;*/
- maxi = negate( maxi );
+ maxi = negate( maxi ); /* Q0 */
}
}
- *last_pulse_pos = maxi;
+ *last_pulse_pos = maxi; /* Q0 */
move16();
}
ELSE
@@ -198,8 +198,8 @@ void FEC_encode_fx(
*-------------------------------------------------------------------*/
void FEC_lsf_estim_enc_fx(
- Encoder_State *st_fx, /* i : Encoder static memory */
- Word16 *lsf /* o : estimated LSF vector */
+ Encoder_State *st_fx, /* i : Encoder static memory */
+ Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/
)
{
Word16 i;
@@ -222,7 +222,7 @@ void FEC_lsf_estim_enc_fx(
IF( EQ_16( st_fx->last_coder_type, UNVOICED ) )
{
/* clearly unvoiced */
- alpha = _ALPHA_UU_FX;
+ alpha = _ALPHA_UU_FX; /* Q15 */
move16();
}
ELSE
@@ -231,52 +231,54 @@ void FEC_lsf_estim_enc_fx(
test();
IF( EQ_16( st_fx->last_coder_type, AUDIO ) || EQ_16( st_fx->clas, INACTIVE_CLAS ) )
{
- alpha = 32604;
+ alpha = 32604; /* 0.995 in Q15 */
move16();
}
ELSE IF( EQ_16( st_fx->clas, UNVOICED_CLAS ) )
{
/* if stable, do not flatten the spectrum in the first erased frame */
/* alpha = st->stab_fac * (1.0f - 2.0f*ALPHA_U) + 2.0f*ALPHA_U; */
- alpha = add( mult( st_fx->stab_fac_fx, 32768 - _ALPHA_U_FX_X_2 ), _ALPHA_U_FX_X_2 );
+ alpha = add( mult( st_fx->stab_fac_fx, 32768 - _ALPHA_U_FX_X_2 ), _ALPHA_U_FX_X_2 ); /* Q15 */
}
ELSE IF( EQ_16( st_fx->clas, UNVOICED_TRANSITION ) )
{
- alpha = _ALPHA_UT_FX;
+ alpha = _ALPHA_UT_FX; /* Q15 */
move16();
}
ELSE IF( EQ_16( st_fx->clas, VOICED_CLAS ) || EQ_16( st_fx->clas, ONSET ) )
{
/* clearly voiced - mild convergence to the CNG spectrum for the first three erased frames */
- alpha = _ALPHA_V_FX;
+ alpha = _ALPHA_V_FX; /* Q15 */
move16();
}
ELSE IF( EQ_16( st_fx->clas, SIN_ONSET ) )
{
- alpha = _ALPHA_S_FX;
+ alpha = _ALPHA_S_FX; /* Q15 */
move16();
}
ELSE
{
/* long erasures and onsets - rapid convergence to the CNG spectrum */
- alpha = _ALPHA_VT_FX;
+ alpha = _ALPHA_VT_FX; /* Q15 */
move16();
}
}
/*----------------------------------------------------------------------*
* Extrapolate LSF vector
*----------------------------------------------------------------------*/
- tmp = sub( 32767, alpha );
+ tmp = sub( 32767, alpha ); /* Q15 */
/* extrapolate the old LSF vector */
FOR( i = 0; i < M; i++ )
{
/* calculate mean LSF vector */
/*lsf_mean[i] = BETA_FEC * lsf_mean[i] + (1-BETA_FEC) * st->lsf_adaptive_mean[i]; */
- lsf_mean[i] = mac_r( L_mult( BETA_FEC_FX, lsf_mean[i] ), 32768 - BETA_FEC_FX, st_fx->lsf_adaptive_mean_fx[i] );
+ lsf_mean[i] = mac_r( L_mult( BETA_FEC_FX, lsf_mean[i] ), 32768 - BETA_FEC_FX, st_fx->lsf_adaptive_mean_fx[i] ); /* Qlog2(2.56) */
+ move16();
/* move old LSF vector towards the mean LSF vector */
/* lsf[i] = alpha * st->lsf_old[i] + (1.0f - alpha) * lsf_mean[i]; */
- lsf[i] = mac_r( L_mult( alpha, st_fx->lsf_old_fx[i] ), tmp, lsf_mean[i] );
+ lsf[i] = mac_r( L_mult( alpha, st_fx->lsf_old_fx[i] ), tmp, lsf_mean[i] ); /* Qlog2(2.56) */
+ move16();
}
/* check LSF stability through LSF ordering */
@@ -291,3 +293,175 @@ void FEC_lsf_estim_enc_fx(
return;
}
+
+/*-------------------------------------------------------------------*
+ * FEC_encode()
+ *
+ * Encoder supplementary information for FEC
+ *-------------------------------------------------------------------*/
+
+void FEC_encode_ivas_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
+ const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ Word16 clas, /* i : signal clas for current frame Q0*/
+ const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
+ const Word16 *res, /* i : LP residual signal frame Qx*/
+ Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
+ const Word16 L_frame, /* i : Frame length Q0*/
+ const Word32 total_brate, /* i : total codec bitrate Q0*/
+ const Word16 Q_synth /* i : input scaling */
+)
+{
+ Word16 tmpS, index;
+ Word16 maxi, sign, tmp_FER_pitch;
+ Word32 enr_q, Ltmp;
+ Word16 exp_enrq;
+
+ tmpS = 0;
+ move16();
+ enr_q = 1;
+ move16();
+ sign = 0;
+ move16();
+ test();
+ test();
+ IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && acelp_cfg.FEC_mode > 0 )
+ {
+ /*-----------------------------------------------------------------*
+ * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits)
+ *-----------------------------------------------------------------*/
+ IF( NE_16( coder_type, VOICED ) )
+ {
+ /* encode signal clas with 2 bits */
+ test();
+ IF( clas == UNVOICED_CLAS )
+ {
+ index = 0;
+ move16();
+ }
+ ELSE IF( EQ_16( clas, VOICED_TRANSITION ) || EQ_16( clas, UNVOICED_TRANSITION ) )
+ {
+ index = 1;
+ move16();
+ }
+ ELSE IF( EQ_16( clas, VOICED_CLAS ) )
+ {
+ index = 2;
+ move16();
+ }
+ ELSE
+ {
+ index = 3;
+ move16();
+ }
+ push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS );
+ }
+
+ /*-----------------------------------------------------------------*
+ * encode frame energy (5 bits)
+ *-----------------------------------------------------------------*/
+ IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */
+ {
+ /* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */
+ /*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/
+ Word32 synth32[L_FRAME16k];
+ Copy_Scale_sig_16_32( synth, synth32, L_FRAME16k, 0 ); /* Qsynth */
+ fer_energy_fx( L_frame, clas, synth32, Q_synth, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), &enr_q, L_frame );
+ exp_enrq = sub( 31, shl( Q_synth, 1 ) );
+
+ test();
+ test();
+ if ( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */
+ {
+ exp_enrq = 31;
+ move16();
+ }
+ /* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */
+ /*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/
+
+ Ltmp = Mpy_32_32( BASOP_Util_Log10( enr_q, exp_enrq ), 894784853 /* 10 / FEC_ENR_STEP Q28 */ ); // Q 25 + 28 - 31 = Q22
+ IF( Ltmp < 0 )
+ {
+ tmpS = extract_l( L_negate( L_shr( L_negate( Ltmp ), Q22 ) ) ); /* Q0 */
+ }
+ ELSE
+ {
+ tmpS = extract_l( L_shr( Ltmp, Q22 ) ); /* Q0 */
+ }
+
+ tmpS = s_min( tmpS, FEC_ENR_QLIMIT );
+ tmpS = s_max( tmpS, 0 );
+
+ push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR );
+ }
+ /*-----------------------------------------------------------------*
+ * Encode last glottal pulse position (8 bits)
+ *-----------------------------------------------------------------*/
+
+ IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */
+ {
+ /* retrieve the last glottal pulse position of the previous frame */
+ /* use the current pitch information to scale or not the quantization */
+ tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */
+ sign = 0;
+ move16();
+ maxi = *last_pulse_pos; /* Q0 */
+ move16();
+ IF( maxi < 0 )
+ {
+ sign = 1;
+ move16();
+ /*maxi = -maxi; */
+ maxi = negate( maxi );
+ }
+
+ if ( GE_16( tmp_FER_pitch, 128 ) )
+ {
+ maxi = shr( maxi, 1 );
+ }
+
+ if ( GT_16( maxi, 127 ) )
+ {
+ /* better not use the glottal pulse position at all instead of using a wrong pulse */
+ /* can happen only with pitch > 254 and max pit = 289 and should happen very rarely */
+ maxi = 0;
+ move16();
+ }
+
+ if ( EQ_16( sign, 1 ) )
+ {
+ maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/
+ }
+
+ push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS );
+ }
+ maxi = 0;
+ move16();
+
+ /* If bitrate < 24k4, then the pitch
+ is not represented in the same domain (12.k instead of 16k) */
+ test();
+ IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) )
+ {
+ /*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */
+ maxi = findpulse_fx( L_frame, res, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), 0, &sign );
+ if ( EQ_16( sign, 1 ) )
+ {
+ /*maxi = -maxi;*/
+ maxi = negate( maxi );
+ }
+ }
+
+ *last_pulse_pos = maxi; /* Q0 */
+ move16();
+ }
+ ELSE
+ {
+ *last_pulse_pos = 0;
+ move16();
+ }
+
+ return;
+}
diff --git a/lib_enc/SNR_calc.c b/lib_enc/SNR_calc.c
deleted file mode 100644
index 8d4adb219f2e97f01fc9e529ffbc94de34a8fde5..0000000000000000000000000000000000000000
--- a/lib_enc/SNR_calc.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "rom_enc.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/SNR_calc_fx.c b/lib_enc/SNR_calc_fx.c
index 320a68d255f539a42d1f543642c5abcd85a10863..1213a6b320fbd2ea3ee38d2096fb8d866ecb7b89 100644
--- a/lib_enc/SNR_calc_fx.c
+++ b/lib_enc/SNR_calc_fx.c
@@ -10,6 +10,7 @@
#include "prot_fx_enc.h" /* Function prototypes */
#include "rom_enc.h"
#include "rom_com.h"
+#include "prot.h"
/*-------------------------------------------------------------------*
@@ -19,16 +20,15 @@
*-------------------------------------------------------------------*/
void calc_lf_snr_fx(
- Word32 *lf_snr_smooth, /* o : smoothed lf_snr*/
- Word32 *lf_snr, /* o : long time frequency domain
- SNR calculated by l_speech_snr and l_silence_snr*/
- const Word32 l_speech_snr, /* i : sum of active frames snr */
- const Word32 l_speech_snr_count, /* i : amount of the active frame */
- const Word32 l_silence_snr, /* i : sum of the nonactive frames snr*/
- const Word32 l_silence_snr_count, /* i : amount of the nonactive frame */
- const Word16 fg_energy_count, /* i : amount of the foreground energy frame */
- const Word16 bg_energy_count, /* i : amount of the background energy frame */
- const Word16 bw_index /* i : band width index*/
+ Word32 *lf_snr_smooth, /* o : smoothed lf_snr Q25*/
+ Word32 *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr Q25*/
+ const Word32 l_speech_snr, /* i : sum of active frames snr Q16*/
+ const Word32 l_speech_snr_count, /* i : amount of the active frame Q0*/
+ const Word32 l_silence_snr, /* i : sum of the nonactive frames snr Q16*/
+ const Word32 l_silence_snr_count, /* i : amount of the nonactive frame Q0*/
+ const Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/
+ const Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/
+ const Word16 bw_index /* i : band width index Q0*/
)
{
@@ -36,18 +36,18 @@ void calc_lf_snr_fx(
Word16 q_divout, q_divout1;
- div1 = VAD_L_div( l_speech_snr, l_speech_snr_count, 16, 0, &q_divout );
- div2 = VAD_L_div( l_silence_snr, l_silence_snr_count, 16, 0, &q_divout1 );
- l_snr = VAD_L_ADD( div1, q_divout, L_negate( div2 ), q_divout1, &q_divout );
+ div1 = VAD_L_div( l_speech_snr, l_speech_snr_count, 16, 0, &q_divout ); /* q_divout */
+ div2 = VAD_L_div( l_silence_snr, l_silence_snr_count, 16, 0, &q_divout1 ); /* q_divout1 */
+ l_snr = VAD_L_ADD( div1, q_divout, L_negate( div2 ), q_divout1, &q_divout ); /* q_divout */
*lf_snr_smooth = MUL_F( *lf_snr_smooth, 29490 /* 0.9 Q15 */ );
move32();
- tmp = MUL_F( l_snr, 26214 );
- *lf_snr_smooth = VAD_L_ADD( *lf_snr_smooth, 25, tmp, add( 3, q_divout ), &q_divout1 );
+ tmp = MUL_F( l_snr, 26214 /* 0.8 in Q15 */ );
+ *lf_snr_smooth = VAD_L_ADD( *lf_snr_smooth, 25, tmp, add( 3, q_divout ), &q_divout1 ); /* q_divout1 */
move32();
- *lf_snr_smooth = L_shr( *lf_snr_smooth, sub( q_divout1, 25 ) );
+ *lf_snr_smooth = L_shr( *lf_snr_smooth, sub( q_divout1, 25 ) ); /* Q25 */
move32();
- l_snr = L_shr( l_snr, sub( q_divout, 25 ) );
+ l_snr = L_shr( l_snr, sub( q_divout, 25 ) ); /* Q25 */
test();
if ( ( LT_16( bg_energy_count, 56 ) ) || ( LT_16( fg_energy_count, 56 ) ) )
@@ -60,9 +60,9 @@ void calc_lf_snr_fx(
l_snr = L_sub( l_snr, 12079595 /* 0.36 Q25 */ );
l_snr = L_max( 0, l_snr );
- l_snr = L_min( l_snr, MAX_LF_SNR_TAB_FX[bw_index] );
+ l_snr = L_min( l_snr, MAX_LF_SNR_TAB_FX[bw_index] ); /* Q25 */
- *lf_snr = l_snr;
+ *lf_snr = l_snr; /* Q25 */
move32();
return;
}
@@ -73,14 +73,14 @@ void calc_lf_snr_fx(
*-------------------------------------------------------------------*/
void calc_lt_snr_fx(
VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word32 *lt_snr_org_fp, /* o : original long time SNR*/
- Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy*/
- Word32 fg_energy, /* i : foreground energy sum */
- Word16 fg_energy_count, /* i : amount of the foreground energy frame */
- Word32 bg_energy, /* i : background energy sum */
- Word16 bg_energy_count, /* i : amount of the background energy frame */
- Word16 bw_index, /* i : band width index*/
- Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0*/
+ Word32 *lt_snr_org_fp, /* o : original long time SNR Q25*/
+ Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy Q25*/
+ Word32 fg_energy, /* i : foreground energy sum Qx*/
+ Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/
+ Word32 bg_energy, /* i : background energy sum Qx*/
+ Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/
+ Word16 bw_index, /* i : band width index Q0*/
+ Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0 Q10*/
)
{
Word16 tmp_lt_noise_sp_center;
@@ -89,7 +89,7 @@ void calc_lt_snr_fx(
Word32 lt_snr, div1, div2, tmp;
- tmp_lt_noise_sp_center = sub( lt_noise_sp_center0, 1432 /* 1.4 Q10 */ );
+ tmp_lt_noise_sp_center = sub( lt_noise_sp_center0, 1432 /* 1.4 Q10 */ ); /* Q10 */
if ( GT_16( tmp_lt_noise_sp_center, 818 /* 0.8 Q10 */ ) )
{
tmp_lt_noise_sp_center = 818 /* 0.8 Q10 */;
@@ -103,28 +103,29 @@ void calc_lt_snr_fx(
}
div1 = MUL_F( fg_energy, bg_energy_count );
- div1 = VAD_L_ADD( div1, hVAD_CLDFB->fg_energy_scale, 1, 126, &q_div1 );
+ div1 = VAD_L_ADD( div1, hVAD_CLDFB->fg_energy_scale, 1, 126, &q_div1 ); /* q_div1 */
div2 = MUL_F( bg_energy, fg_energy_count );
- div2 = VAD_L_ADD( div2, hVAD_CLDFB->bg_energy_scale, 1, 126, &q_div2 );
- if ( div2 == 0 )
+ div2 = VAD_L_ADD( div2, hVAD_CLDFB->bg_energy_scale, 1, 126, &q_div2 ); /* q_div2 */
+ IF( div2 == 0 )
{
div2 = 1;
move32(); /* div2==0 , may occur for >30000 frames all zero input */
if ( div1 != 0 )
{
hVAD_CLDFB->bg_energy_scale = add( hVAD_CLDFB->fg_energy_scale, 50 );
+ move16();
}
}
- div2 = VAD_L_div( div1, div2, q_div1, q_div2, &q_divout );
+ div2 = VAD_L_div( div1, div2, q_div1, q_div2, &q_divout ); /* q_divout */
lt_snr_org = VAD_Log2( div2, q_divout );
- lt_snr_org = MUL_F( lt_snr_org, 9864 );
- lt_snr = lt_snr_org;
+ lt_snr_org = MUL_F( lt_snr_org, 9864 /* 0.3 in Q15 */ ); /* Q25 */
+ lt_snr = lt_snr_org; /* Q25 */
move32();
- *lt_snr_org_fp = lt_snr;
+ *lt_snr_org_fp = lt_snr; /* Q25 */
move32();
test();
- IF( LT_16( bg_energy_count, 56 ) || LT_16( fg_energy_count, 56 ) )
+ if ( LT_16( bg_energy_count, 56 ) || LT_16( fg_energy_count, 56 ) )
{
lt_snr = 70464302 /* 2.1 Q25 */;
move32();
@@ -132,26 +133,26 @@ void calc_lt_snr_fx(
IF( EQ_16( bw_index, CLDFBVAD_NB_ID ) )
{
- lt_snr = L_sub( L_shr( lt_snr, 1 ), 25165823 /* 0.75 Q25 */ );
+ lt_snr = L_sub( L_shr( lt_snr, 1 ), 25165823 /* 0.75 Q25 */ ); /* Q25 */
}
ELSE IF( EQ_16( bw_index, CLDFBVAD_WB_ID ) )
{
- lt_snr = L_sub( L_shr( lt_snr, 1 ), 25165823 /* 0.75 Q25 */ );
+ lt_snr = L_sub( L_shr( lt_snr, 1 ), 25165823 /* 0.75 Q25 */ ); /* Q25 */
}
ELSE
{
- lt_snr = MUL_F( lt_snr, 15073 /* 0.46 Q15 */ );
- lt_snr = L_sub( lt_snr, 23152557 /* 0.69 Q25 */ );
+ lt_snr = MUL_F( lt_snr, 15073 /* 0.46 Q15 */ ); /* Q25 */
+ lt_snr = L_sub( lt_snr, 23152557 /* 0.69 Q25 */ ); /* Q25 */
}
- tmp = MUL_F( lt_snr, 13107 /* 0.4 Q15 */ );
+ tmp = MUL_F( lt_snr, 13107 /* 0.4 Q15 */ ); /* Q25 */
- tmp = L_add( L_shr( tmp, 1 ), -26214 );
+ tmp = L_add( L_shr( tmp, 1 ), -26214 /* 0.0007 in Q25 */ );
- tmp = MUL_F( tmp, 13107 /* 0.4 Q15 */ );
+ tmp = MUL_F( tmp, 13107 /* 0.4 Q15 */ ); /* Q25 */
tmp = MUL_F( tmp, tmp_lt_noise_sp_center );
- lt_snr = VAD_L_ADD( lt_snr, 25, tmp, 19, &q_divout1 );
- lt_snr = L_shr( lt_snr, sub( q_divout1, 25 ) );
+ lt_snr = VAD_L_ADD( lt_snr, 25, tmp, 19, &q_divout1 ); /* q_divout1 */
+ lt_snr = L_shr( lt_snr, sub( q_divout1, 25 ) ); /* Q25 */
lt_snr = L_max( 0, lt_snr );
@@ -161,7 +162,7 @@ void calc_lt_snr_fx(
move32();
}
- *lt_snr_fp = lt_snr;
+ *lt_snr_fp = lt_snr; /* Q25 */
move32();
return;
}
@@ -172,9 +173,9 @@ void calc_lt_snr_fx(
*
*-------------------------------------------------------------------*/
void calc_snr_flux_fx(
- Word32 tsnr, /* i : time-domain SNR*/
- Word32 *pre_snr, /* i/o: time-domain SNR storage*/
- Word32 *snr_flux_fp /* o : average tsnr*/
+ Word32 tsnr, /* i : time-domain SNR Q25*/
+ Word32 *pre_snr, /* i/o: time-domain SNR storage Q25*/
+ Word32 *snr_flux_fp /* o : average tsnr Q25*/
)
{
Word32 i;
@@ -186,7 +187,7 @@ void calc_snr_flux_fx(
test();
IF( ( LT_32( L_shr( tsnr, 1 ), 43620759 /* 2.6f/2.0f Q25 */ ) ) && tsnr > 0 )
{
- pre_snr[0] = tsnr;
+ pre_snr[0] = tsnr; /* Q25 */
move32();
}
ELSE IF( tsnr <= 0 )
@@ -206,17 +207,17 @@ void calc_snr_flux_fx(
s16MaxCoefNorm = sub( ffr_getSfWord32( pre_snr, 32 ), 5 );
FOR( i = 0; i < 32; i++ )
{
- tmp = L_shl( pre_snr[i], s16MaxCoefNorm );
+ tmp = L_shl( pre_snr[i], s16MaxCoefNorm ); /* Q25 + s16MaxCoefNorm */
snr_flux = L_add( snr_flux, tmp );
}
snr_flux = L_shr( snr_flux, add( s16MaxCoefNorm, 5 ) );
- *snr_flux_fp = snr_flux;
+ *snr_flux_fp = snr_flux; /* Q25 */
move32();
/*update the tsnr storage pre_snr*/
FOR( i = PRE_SNR_NUM - 1; i > 0; i-- )
{
- pre_snr[i] = pre_snr[i - 1];
+ pre_snr[i] = pre_snr[i - 1]; /* Q25 */
move32();
}
return;
@@ -229,12 +230,12 @@ void calc_snr_flux_fx(
*
*-------------------------------------------------------------------*/
void snr_calc(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- const Word16 sacle_sbpower, /* i : the Scaling of sbpower*/
- Word32 *snr, /* o : frequency domain SNR */
- Word32 *tsnr, /* o : time domain SNR */
- const Word32 frame_energy, /* i : current frame energy */
- const Word32 bwidth /* i : audio band width*/
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ const Word16 sacle_sbpower, /* i : the Scaling of sbpower */
+ Word32 *snr, /* o : frequency domain SNR Q25*/
+ Word32 *tsnr, /* o : time domain SNR Q25*/
+ const Word32 frame_energy, /* i : current frame energy sacle_sbpower*/
+ const Word32 bwidth /* i : audio band width Q0*/
)
{
Word32 i;
@@ -248,10 +249,12 @@ void snr_calc(
Word16 tmp_addQ1, tmp_addQ2, minscale, minscale1, minscale2, s16MaxCoefNorm, q_divout;
Word32 tmpspec_amp;
Word32 const CONSTfix = 1759218560;
- Word32 snr_tmpidx[12] = { 0 };
+ move32();
+ Word32 snr_tmpidx[12];
+ set_zero_fx( snr_tmpidx, 12 );
- SNR_sb_num = SNR_SUB_BAND_NUM[bwidth - CLDFBVAD_NB_ID];
+ SNR_sb_num = SNR_SUB_BAND_NUM[bwidth - CLDFBVAD_NB_ID]; /* Q0 */
move16();
sb_bg_energy = hVAD_CLDFB->sb_bg_energy;
frame_sb_energy = hVAD_CLDFB->frame_sb_energy;
@@ -262,14 +265,14 @@ void snr_calc(
move32();
FOR( i = 0; i < SNR_sb_num; i++ )
{
- div1 = VAD_L_ADD( frame_sb_energy[i], hVAD_CLDFB->frame_sb_energy_scale, CONSTfix, 44, &tmp_addQ1 );
- div2 = VAD_L_ADD( sb_bg_energy[i], hVAD_CLDFB->sb_bg_energy_scale, CONSTfix, 44, &tmp_addQ2 );
- tmp = VAD_L_div( div1, div2, tmp_addQ1, tmp_addQ2, &q_divout );
+ div1 = VAD_L_ADD( frame_sb_energy[i], hVAD_CLDFB->frame_sb_energy_scale, CONSTfix, 44, &tmp_addQ1 ); /* tmp_addQ1 */
+ div2 = VAD_L_ADD( sb_bg_energy[i], hVAD_CLDFB->sb_bg_energy_scale, CONSTfix, 44, &tmp_addQ2 ); /* tmp_addQ2 */
+ tmp = VAD_L_div( div1, div2, tmp_addQ1, tmp_addQ2, &q_divout ); /* q_divout */
tmp = VAD_Log2( tmp, q_divout );
if ( GT_32( tmp, -3355443 /* -0.10 Q25 */ ) )
{
- snr_tmpidx[i] = tmp;
+ snr_tmpidx[i] = tmp; /* Q25 */
move32();
}
}
@@ -277,21 +280,21 @@ void snr_calc(
s16MaxCoefNorm = sub( ffr_getSfWord32( snr_tmpidx, (Word16) SNR_sb_num ), 4 );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- tmpspec_amp = L_shl( snr_tmpidx[i], s16MaxCoefNorm );
+ tmpspec_amp = L_shl( snr_tmpidx[i], s16MaxCoefNorm ); /* Q25 + s16MaxCoefNorm */
snr_tmp = L_add( snr_tmp, tmpspec_amp );
}
snr_tmp = L_max( 0, snr_tmp );
- snr_tmp = MUL_F( snr_tmp, BAND_MUL[bwidth - CLDFBVAD_NB_ID] );
- *snr = L_shr( snr_tmp, s16MaxCoefNorm );
+ snr_tmp = MUL_F( snr_tmp, BAND_MUL[bwidth - CLDFBVAD_NB_ID] ); /* Q25 + s16MaxCoefNorm */
+ *snr = L_shr( snr_tmp, s16MaxCoefNorm ); /* Q25 */
move32();
- IF( bwidth == CLDFBVAD_SWB_ID )
+ IF( EQ_32( bwidth, CLDFBVAD_SWB_ID ) )
{
IF( t_bg_energy )
{
minscale = norm_l( t_bg_energy );
minscale2 = sub( s_min( add( minscale, hVAD_CLDFB->scale_t_bg_energy ), 31 ), 1 );
- tmpsb_eg = L_shr( t_bg_energy, sub( hVAD_CLDFB->scale_t_bg_energy, minscale2 ) );
+ tmpsb_eg = L_shr( t_bg_energy, sub( hVAD_CLDFB->scale_t_bg_energy, minscale2 ) ); /* minscale2 */
constff = L_shr( 1, sub( 31, minscale2 ) );
}
ELSE
@@ -304,12 +307,12 @@ void snr_calc(
move16();
}
div2 = L_add( tmpsb_eg, constff );
- tmp = VAD_L_div( frame_energy, div2, sacle_sbpower, minscale2, &q_divout );
+ tmp = VAD_L_div( frame_energy, div2, sacle_sbpower, minscale2, &q_divout ); /* q_divout */
IF( tmp )
{
minscale = norm_l( tmp );
minscale2 = sub( s_min( add( minscale, q_divout ), 31 ), 1 );
- tmpsb_eg = L_shr( tmp, limitScale32( sub( q_divout, minscale2 ) ) );
+ tmpsb_eg = L_shr( tmp, limitScale32( sub( q_divout, minscale2 ) ) ); /* minscale2 */
constff = L_shr( 1, sub( 31, minscale2 ) );
tmp = L_add( tmpsb_eg, constff );
}
@@ -323,7 +326,7 @@ void snr_calc(
*tsnr = VAD_Log2( tmp, minscale2 );
move32();
#ifdef BASOP_NOGLOB
- *tsnr = L_add_sat( *tsnr, MUL_F( *tsnr, 6226 ) ); /* *tsnr *= 1.2; */
+ *tsnr = L_add_sat( *tsnr, MUL_F( *tsnr, 6226 ) ); /* *tsnr *= 1.2; Q25*/
#else
*tsnr = L_add( *tsnr, MUL_F( *tsnr, 6226 ) ); /* *tsnr *= 1.2; */
#endif
@@ -335,7 +338,7 @@ void snr_calc(
{
minscale = norm_l( frame_energy );
minscale1 = sub( s_min( add( minscale, sacle_sbpower ), 44 ), 1 );
- tmpframe_eg = L_shr( frame_energy, sub( sacle_sbpower, minscale1 ) );
+ tmpframe_eg = L_shr( frame_energy, sub( sacle_sbpower, minscale1 ) ); /* minscale1 */
constff = L_shr( CONSTfix, sub( 44, minscale1 ) );
}
ELSE
@@ -352,7 +355,7 @@ void snr_calc(
{
minscale = norm_l( t_bg_energy );
minscale2 = sub( s_min( add( minscale, hVAD_CLDFB->scale_t_bg_energy ), 44 ), 1 );
- tmpsb_eg = L_shr( t_bg_energy, sub( hVAD_CLDFB->scale_t_bg_energy, minscale2 ) );
+ tmpsb_eg = L_shr( t_bg_energy, sub( hVAD_CLDFB->scale_t_bg_energy, minscale2 ) ); /* minscale2 */
constff = L_shr( CONSTfix, sub( 44, minscale2 ) );
}
ELSE
@@ -365,29 +368,29 @@ void snr_calc(
move16();
}
div2 = L_add( tmpsb_eg, constff );
- tmp = VAD_L_div( div1, div2, minscale1, minscale2, &q_divout );
- *tsnr = VAD_Log2( tmp, q_divout );
+ tmp = VAD_L_div( div1, div2, minscale1, minscale2, &q_divout ); /* q_divout */
+ *tsnr = VAD_Log2( tmp, q_divout ); /* Q25 */
move32();
}
return;
}
Word32 construct_snr_thresh_fx(
- Word16 sp_center[], /* i : spectral center*/
- Word32 snr_flux, /* i : snr flux*/
- Word32 lt_snr, /* i : long time time domain snr*/
- Word32 l_snr, /* i : long time frequency domain snr*/
- Word32 continuous_speech_num, /* i : amount of continuous speech frames*/
- Word16 continuous_noise_num, /* i : amount of continuous noise frames*/
- Word32 fg_energy_est_start, /* i : whether if estimated energy*/
- Word16 bw_index /* i : band width index*/
+ Word16 sp_center[], /* i : spectral center Q10*/
+ Word32 snr_flux, /* i : snr flux Q25*/
+ Word32 lt_snr, /* i : long time time domain snr Q25*/
+ Word32 l_snr, /* i : long time frequency domain snr Q25*/
+ Word32 continuous_speech_num, /* i : amount of continuous speech frames Q0*/
+ Word16 continuous_noise_num, /* i : amount of continuous noise frames Q0*/
+ Word32 fg_energy_est_start, /* i : whether if estimated energy Q0*/
+ Word16 bw_index /* i : band width index Q0*/
)
{
Word32 bw_snr, tmp_snr, snr_delta, test_l_snr, tmp, div1, div2;
- snr_delta = COMVAD_INIT_SNR_DELTA_FX[bw_index];
+ snr_delta = COMVAD_INIT_SNR_DELTA_FX[bw_index]; /* Q25 */
move32();
bw_snr = lt_snr;
move32();
@@ -397,126 +400,108 @@ Word32 construct_snr_thresh_fx(
move32();
IF( EQ_16( bw_index, CLDFBVAD_SWB_ID ) )
{
-
- IF( GT_16( sp_center[3], 2864 /* 2.80 Q10 */ ) )
+ IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
{
- snr_delta = snr_delta;
- move32();
- }
- ELSE IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
- {
- snr_delta = L_add( snr_delta, 1006633 /* 0.03 Q25 */ );
+ snr_delta = L_add( snr_delta, 1006633 /* 0.03 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[2], 1637 /* 1.6 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 1677722 /* 0.05 Q25 */ );
+ snr_delta = L_add( snr_delta, 1677722 /* 0.05 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[3], 1432 /* 1.4 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE
{
- snr_delta = L_add( snr_delta, 13421773 /* 0.40 Q25 */ );
+ snr_delta = L_add( snr_delta, 13421773 /* 0.40 Q25 */ ); /* Q25 */
}
- tmp = MUL_F( l_snr, 3277 /* 0.1 Q15 */ );
+ tmp = MUL_F( l_snr, 3277 /* 0.1 Q15 */ ); /* Q25 */
tmp = L_add( tmp, 20132659 /* 0.6 Q25 */ );
test();
test();
IF( GT_32( continuous_speech_num, 8 ) && EQ_32( fg_energy_est_start, 1 ) )
{
- snr_delta = L_sub( snr_delta, 6710886 /* 0.2 Q25 */ );
+ snr_delta = L_sub( snr_delta, 6710886 /* 0.2 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 12 ) && ( GT_32( snr_flux, tmp ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 24 ) )
{
- snr_delta = L_add( snr_delta, 6710886 /* 0.2 Q25 */ );
+ snr_delta = L_add( snr_delta, 6710886 /* 0.2 Q25 */ ); /* Q25 */
}
ELSE IF( ( GT_16( continuous_noise_num, 4 ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
}
ELSE IF( EQ_16( bw_index, CLDFBVAD_WB_ID ) )
{
-
- IF( GT_16( sp_center[3], 2864 /* 2.80 Q10 */ ) )
+ IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
{
- snr_delta = snr_delta;
- move32();
- }
- ELSE IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
- {
- snr_delta = L_add( snr_delta, 1006633 /* 0.03 Q25 */ );
+ snr_delta = L_add( snr_delta, 1006633 /* 0.03 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[2], 1637 /* 1.6 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 1677722 /* 0.05 Q25 */ );
+ snr_delta = L_add( snr_delta, 1677722 /* 0.05 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[3], 1432 /* 1.4 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE
{
- snr_delta = L_add( snr_delta, 10066330 /* 0.30 Q25 */ );
+ snr_delta = L_add( snr_delta, 10066330 /* 0.30 Q25 */ ); /* Q25 */
}
- tmp = MUL_F( bw_snr, 3277 /* 0.1 Q15 */ );
- tmp = L_add( tmp, 20132659 /* 0.6 Q25 */ );
+ tmp = MUL_F( bw_snr, 3277 /* 0.1 Q15 */ ); /* Q25 */
+ tmp = L_add( tmp, 20132659 /* 0.6 Q25 */ ); /* Q25 */
test();
test();
IF( GT_32( continuous_speech_num, 8 ) && EQ_32( fg_energy_est_start, 1 ) )
{
- snr_delta = L_sub( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_sub( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 12 ) && ( GT_32( snr_flux, tmp ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 24 ) )
{
- snr_delta = L_add( snr_delta, 6710886 /* 0.20 Q25 */ );
+ snr_delta = L_add( snr_delta, 6710886 /* 0.20 Q25 */ ); /* Q25 */
}
ELSE IF( ( GT_16( continuous_noise_num, 4 ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
}
ELSE IF( EQ_16( bw_index, CLDFBVAD_NB_ID ) )
{
-
- IF( GT_16( sp_center[3], 3069 /* 3.0 Q10 */ ) )
- {
- snr_delta = snr_delta;
- move32();
- }
- ELSE IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
+ IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 671089 /* 0.02 Q25 */ );
+ snr_delta = L_add( snr_delta, 671089 /* 0.02 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[2], 1637 /* 1.6 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 1342177 /* 0.04 Q25 */ );
+ snr_delta = L_add( snr_delta, 1342177 /* 0.04 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[2], 1494 /* 1.46 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE
{
- snr_delta = L_add( snr_delta, 6039798 /* 0.18 Q25 */ );
+ snr_delta = L_add( snr_delta, 6039798 /* 0.18 Q25 */ ); /* Q25 */
}
- tmp = MUL_F( l_snr, 3277 /* 0.1 Q15 */ );
- div1 = L_add( tmp, 6710886 /* 0.2 Q25 */ );
- div2 = L_add( tmp, 20132659 /* 0.6 Q25 */ );
+ tmp = MUL_F( l_snr, 3277 /* 0.1 Q15 */ ); /* Q25 */
+ div1 = L_add( tmp, 6710886 /* 0.2 Q25 */ ); /* Q25 */
+ div2 = L_add( tmp, 20132659 /* 0.6 Q25 */ ); /* Q25 */
test();
test();
@@ -525,19 +510,19 @@ Word32 construct_snr_thresh_fx(
test();
IF( GT_32( continuous_speech_num, 80 ) && EQ_32( fg_energy_est_start, 1 ) && ( GT_16( sp_center[0], 1432 /* 1.4 Q10 */ ) ) )
{
- snr_delta = L_sub( snr_delta, 10737418 /* 0.32 Q25 */ );
+ snr_delta = L_sub( snr_delta, 10737418 /* 0.32 Q25 */ ); /* Q25 */
}
ELSE IF( GT_32( continuous_speech_num, 8 ) && EQ_32( fg_energy_est_start, 1 ) && ( GT_32( snr_flux, div1 ) ) )
{
- snr_delta = L_sub( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_sub( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 12 ) && ( GT_32( snr_flux, div2 ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 24 ) )
{
- snr_delta = L_add( snr_delta, 6710886 /* 0.2 Q25 */ );
+ snr_delta = L_add( snr_delta, 6710886 /* 0.2 Q25 */ ); /* Q25 */
}
}
ELSE
@@ -545,7 +530,7 @@ Word32 construct_snr_thresh_fx(
snr_delta = 33554431 /* 1.0 Q25 */;
move32();
}
- tmp_snr = L_add( snr_delta, test_l_snr );
+ tmp_snr = L_add( snr_delta, test_l_snr ); /* Q25 */
return tmp_snr;
diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c
deleted file mode 100644
index 48f1e417f07330c9fb1dde0dd9e83f6d3b8a75c1..0000000000000000000000000000000000000000
--- a/lib_enc/acelp_core_enc.c
+++ /dev/null
@@ -1,970 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_enc.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "ivas_cnst.h"
-#include "ivas_prot.h"
-#include "ivas_prot_fx.h"
-#include "prot_fx.h"
-#include "prot_fx_enc.h"
-#include "ivas_rom_com.h"
-#include "wmc_auto.h"
-#include "options_warnings.h"
-
-#include "prot_fx_enc.h"
-#include "prot_fx.h"
-
-/*-------------------------------------------------------------------*
- * acelp_core_enc()
- *
- * ACELP core encoder
- *--------------------------------------------------------------------*/
-ivas_error acelp_core_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 inp[], /* i : input signal of the current frame */
- Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes*/
- Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word32 epsP[M + 1], /* i : LP prediction errors */
- Word16 lsp_new[M], /* i : LSPs at the end of the frame */
- Word16 lsp_mid[M], /* i : LSPs in the middle of the frame */
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- const Word16 attack_flag, /* i : attack flag (GSC or TC) */
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors_fx, /* o : voicing factors Q15 */
- Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
- Word16 *q_old_syn_12k8_16,
- Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits, /* o : number of unused bits */
- STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
- Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
- Word16 Q_new )
-{
- Word16 i, nBits; /* reserved bits */
- LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */
- Word16 tc_subfr; /* TC sub-frame indication */
- Word16 allow_cn_step;
- Word32 int_fs;
- Word16 nb_bits; /* parameters handling */
-
- /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */
- Word16 pstreaklen;
- Word16 sid_bw = -1;
- Word16 next_force_sf_bck;
- Word16 uc_two_stage_flag;
- Word16 position;
- Word16 ppp_mode, nelp_mode;
- Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
-
- /* bitstream */
- BSTR_ENC_HANDLE hBstr = st->hBstr;
- Word16 old_exc_fx[L_EXC], *exc_fx; /* excitation signal buffer */
- Word16 lsf_new_fx[M]; /* ISFs at the end of the frame */
- Word16 Aq[NB_SUBFR16k * ( M + 1 )]; /* A(z) quantized for the 4 subframes */
- Word16 syn_fx[L_FRAME16k]; /* synthesis vector */
- Word16 res_fx[L_FRAME16k]; /* Residual signal for FER protection */
- Word16 exc2_fx[L_FRAME16k]; /* enhanced excitation */
- Word16 Es_pred_fx; /* predicited scaled innovation energy */
- Word16 tmp_noise_fx; /* NB post-filter long-term noise energy*/
- Word16 old_bwe_exc_fx[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer Q_new */
- Word16 *bwe_exc_fx; /* excitation for SWB TBE Q_new */
- Word16 mem_MA_fx[M], mem_AR_fx[M], lsp_new_bck_fx[M], /*lsf_new_bck_fx[M],*/ lsp_mid_bck_fx[M], mem_syn_bck_fx[M];
- Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2];
- Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx;
-
-#ifdef MSAN_FIX
- set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 );
- set16_fx( old_exc_fx, 0, L_EXC );
- set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) );
- set16_fx( syn_fx, 0, L_FRAME16k );
-#endif
-
- Word16 tilt_code_bck_fx;
- Word32 gc_threshold_bck_fx;
- Word16 clip_var_bck_fx[6];
- Word32 q_env_fx[NUM_ENV_CNG];
-#ifdef MSAN_FIX
- set32_fx( q_env_fx, 0, NUM_ENV_CNG );
-#endif
- Word16 exc3_fx[L_FRAME16k];
- Word16 syn1_fx[L_FRAME16k];
- Word16 *tdm_Pri_pitch_buf_fx;
-
- Word16 att_fx;
- Word16 tmpF_fx;
-
- test();
- IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL )
- {
- Scale_sig( st->hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2, sub( Q_new, st->prev_Q_new ) ); // Q_new
- }
- IF( st->hLPDmem )
- {
- Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, st->hLPDmem->q_lpd_old_exc ) ); // Q_new
- st->hLPDmem->q_lpd_old_exc = Q_new;
- move16();
- Scale_sig( st->hLPDmem->syn, M + 1, sub( Q_new, st->hLPDmem->q_lpd_syn ) ); // Q_new
- st->hLPDmem->q_lpd_syn = Q_new;
- move16();
- Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- move16();
- st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
- move16();
- }
-
- Scale_sig32( st->Bin_E_old_fx, L_FFT / 2, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E_old ) ); // Q_new + Q_scale - 2
- st->q_Bin_E_old = add( Q_new, Q_SCALE - 2 );
- move16();
- Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E ) ); // Q_new + Q_scale - 2
- st->q_Bin_E = add( Q_new, Q_SCALE - 2 );
- move16();
-
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move32();
-
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->core_brate, SID_2k40 ) )
- {
- /* Core was ACELP because of DTX in MDCT-Stereo, but SID encoding for that is done in separate function */
- return error;
- }
-
- push_wmops( "acelp_core_enc" );
- /*------------------------------------------------------------------*
- * Initialization
- *------------------------------------------------------------------*/
-
- hLPDmem = st->hLPDmem;
-
- Es_pred_fx = 0;
- move16();
-
- exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */
- Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM );
- Scale_sig( old_exc_fx, L_EXC_MEM, sub( Q_new, hLPDmem->q_lpd_old_exc ) ); // Q_new
- IF( st->hBWE_TD != NULL )
- {
- bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */
- Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 );
- }
- ELSE
- {
- bwe_exc_fx = NULL;
- }
-
- st->bpf_off = 0;
- move16();
-
- test();
- test();
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) )
- {
- /* in case of HQ->ACELP switching, do not apply BPF */
- st->bpf_off = 1;
- move16();
- /* reset the GSC pre echo energy threshold in case of switching */
- if ( st->hGSCEnc != NULL )
- {
- st->hGSCEnc->Last_frame_ener_fx = MAX_32;
- move32();
- }
- }
-
- /* force safety-net LSFQ in the first frames after CNG segment */
- if ( LE_32( st->last_core_brate, SID_2k40 ) )
- {
- st->Nb_ACELP_frames = 0;
- move16();
- }
- st->Nb_ACELP_frames = add( st->Nb_ACELP_frames, 1 );
- move16();
-
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- int_fs = INT_FS_12k8;
- move32();
- }
- ELSE
- {
- int_fs = INT_FS_16k;
- move32();
- }
-
- tmp_noise_fx = 0;
- move16();
- tc_subfr = -1;
- move16();
- position = -1;
- move16();
-
- /* SC-VBR temporary variables */
- pstreaklen = 0;
- move16();
- clip_var_fx = 0;
- move16();
- mem_w0_bck_fx = 0;
- move16();
- streaklimit_fx = 0;
- move16();
-
- /* channel-aware mode */
- reset_rf_indices_fx( st );
-
- /* VBR modes */
- IF( st->Opt_SC_VBR )
- {
- ppp_mode = st->hSC_VBR->ppp_mode;
- nelp_mode = st->hSC_VBR->nelp_mode;
- }
- ELSE
- {
- ppp_mode = 0;
- nelp_mode = 0;
- }
- move16();
- move16();
-
- test();
- /* TD stereo */
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
- {
- tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag;
- tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode;
- tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag;
- tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx;
- }
- ELSE
- {
- tdm_lp_reuse_flag = 0;
- tdm_low_rate_mode = 0;
- test();
- if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode )
- {
- tdm_low_rate_mode = 1;
- move16();
- }
- tdm_Pitch_reuse_flag = 0;
- tdm_Pri_pitch_buf_fx = NULL;
- }
- move16();
- move16();
- move16();
-
- /*-----------------------------------------------------------------*
- * ACELP@12k8 / ACELP@16k switching
- *-----------------------------------------------------------------*/
-
- test();
- test();
- IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) )
- {
- /* in case of switching, do not apply BPF (flag employed also in updt_enc()) */
- st->bpf_off = 1;
- move16();
-
- /* force safety-net LSFQ in the first frames after ACELP@12k8/ACELP@16k switching */
- st->Nb_ACELP_frames = 1;
- move16();
-
- /* convert old quantized LSP vector */
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
- move16();
- }
- ELSE
- {
- st->rate_switching_reset = st->rate_switching_reset_16kHz;
- move16();
- Copy( st->lsp_old16k_fx, st->lsp_old_fx, M ); // Q15
- }
-
- /* convert old quantized LSF vector */
- lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs );
-
- /* interpolation of unquantized ISPs */
- IF( st->rate_switching_reset )
- {
- /*extrapolation in case of unstable LSP*/
- int_lsp4_ivas_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 );
- }
- ELSE
- {
- int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 );
- }
-
- /* Reset LPC mem */
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
- set16_fx( st->mem_MA_fx, 0, M );
-
- /* update synthesis filter memories */
- synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC );
- Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M );
-
- /* update Aw[] coefficients */
- weight_a_subfr_fx( shr( st->L_frame, 6 ), A, Aw, st->gamma, M );
- }
- IF( st->hLPDmem )
- {
- st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
- move16();
- st->hLPDmem->q_lpd_old_exc = Q_new;
- move16();
- st->hLPDmem->q_lpd_syn = Q_new;
- move16();
- }
-
- test();
- test();
- if ( st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0 )
- {
- st->rate_switching_reset = 1;
- move16();
- }
-
- /*----------------------------------------------------------------*
- * Encoding of CNG frames
- *----------------------------------------------------------------*/
- test();
- IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) )
- {
- IF( EQ_16( st->cng_type, LP_CNG ) )
- {
- /* Run CNG post parameter update */
- cng_params_postupd_ivas_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
-
- /* encode CNG parameters */
- CNG_enc_ivas_fx( st, Aq, inp, /*ener_fx,*/ lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw );
-
- /* comfort noise generation */
- CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngEnc->Enew_fx, &st->hTdCngEnc->cng_seed, exc_fx, exc2_fx, &st->hTdCngEnc->lp_ener_fx, st->last_core_brate,
- &st->hDtxEnc->first_CNG, &st->hTdCngEnc->cng_ener_seed, bwe_exc_fx, allow_cn_step, &st->hTdCngEnc->last_allow_cn_step, sub( st->prev_Q_new, 1 ), sub( Q_new, 1 ), st->hTdCngEnc->num_ho,
- q_env_fx, st->hTdCngEnc->lp_env_fx, st->hTdCngEnc->old_env_fx, st->hTdCngEnc->exc_mem_fx, st->hTdCngEnc->exc_mem1_fx, &sid_bw, &st->hTdCngEnc->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, EVS_MONO );
-
- Scale_sig( exc_fx, st->L_frame, 1 );
- }
- ELSE
- {
- test();
- IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- FdCng_encodeSID_ivas_fx( st );
- st->hDtxEnc->last_CNG_L_frame = st->L_frame;
- move16();
- }
-
- Word16 Q_cngNoise = Q31, zero_flag = 0;
- move16();
- move16();
- FOR( Word16 j = 0; j < NPART; j++ )
- {
- IF( st->hFdCngEnc->hFdCngCom->cngNoiseLevel[j] != 0 )
- {
- zero_flag = 1;
- move16();
- BREAK;
- }
- }
- IF( zero_flag )
- {
- Q_cngNoise = getScaleFactor32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART );
- }
- Scale_sig32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART, Q_cngNoise );
- st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp = sub( st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp, Q_cngNoise );
- move16();
-
- generate_comfort_noise_enc_ivas_fx( st, Q_new, 1 );
- st->hTcxEnc->q_Txnq = Q_new;
- move16();
- Scale_sig( st->hFdCngEnc->hFdCngCom->A_cng, ( M + 1 ), sub( Q12, sub( 14, norm_s( st->hFdCngEnc->hFdCngCom->A_cng[0] ) ) ) );
- FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq, lsp_new, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
- Copy( exc2_fx, exc3_fx, st->L_frame );
-
- IF( EQ_32( st->core_brate, SID_2k40 ) )
- {
- IF( st->hTdCngEnc != NULL )
- {
- Word16 enr, enr_index;
- enr = cng_energy_ivas_fx( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att_fx, exc_fx, st->L_frame, Q_new );
-
- /* calculate the energy quantization index */
- enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */
- enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */
-
- /* limit the energy quantization index */
- enr_index = s_min( enr_index, 127 );
- enr_index = s_max( enr_index, 0 );
- st->hTdCngEnc->old_enr_index = enr_index;
- move16();
- }
- }
- }
-
- /* Reset HO counter in the first SID frame */
- if ( st->hTdCngEnc != NULL )
- {
- st->hTdCngEnc->burst_ho_cnt = 0;
- move16();
- }
-
- Scale_sig( st->hLPDmem->mem_syn, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- Scale_sig( st->hLPDmem->mem_syn2, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- Scale_sig( st->hLPDmem->mem_syn3, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- move16();
- st->hLPDmem->q_mem_syn = st->Q_syn;
- move16();
-
- /* synthesis at 12.8kHz sampling rate */
- syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn );
-
- /* reset the encoder */
- CNG_reset_enc_fx( st, hLPDmem, pitch_buf, voice_factors_fx, 0 );
-
- /* update st->mem_syn1_flt for ACELP core switching */
- Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn1_fx, M );
-
- /* update ACELP core synthesis filter memory */
- Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M );
-
- /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn1_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM );
-
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) );
- move16();
- Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) );
- save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- *q_old_syn_12k8_16 = st->Q_syn;
- move16();
- st->hBWE_FD->q_mem_deemph_old_syn = st->Q_syn;
- move16();
- }
-
- Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) );
- st->hLPDmem->q_lpd_syn = st->Q_syn;
- move16();
-
- /*Update MODE2 core switching memory*/
- deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) );
- Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 );
- }
-
- /*----------------------------------------------------------------*
- * Encoding of all other frames
- *----------------------------------------------------------------*/
- ELSE
- {
-
- /*-----------------------------------------------------------------*
- * Configure ACELP bit allocation
- *-----------------------------------------------------------------*/
-
- Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k );
- Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp );
- st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp );
- move16();
- nb_bits = 0;
- move16();
- st->acelp_cfg.FEC_mode = 0;
- move16();
- uc_two_stage_flag = 0;
- move16();
-
- test();
- IF( !nelp_mode && !ppp_mode )
- {
- config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
- }
-
- /*-----------------------------------------------------------------*
- * After inactive period, use the most up-to-date ISPs
- *-----------------------------------------------------------------*/
-
- test();
- test();
- IF( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) )
- {
- Copy( st->hDtxEnc->lspCNG_fx, st->lsp_old_fx, M ); // Q15
- lsp2lsf_fx( st->hDtxEnc->lspCNG_fx, st->lsf_old_fx, M, int_fs );
- }
-
- /*-----------------------------------------------------------------*
- * Reset higher ACELP pre-quantizer in case of switching
- *-----------------------------------------------------------------*/
-
- IF( !st->use_acelp_preq )
- {
- st->mem_deemp_preQ_fx = 0;
- move16();
- st->last_code_preq = 0;
- move16();
- st->last_nq_preQ = 0;
- move16();
- }
- st->use_acelp_preq = 0;
- move16();
-
- /*-----------------------------------------------------------------*
- * LSF Quantization
- * A[z] calculation
- *-----------------------------------------------------------------*/
-
- /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */
- lsf_syn_mem_backup_ivas_fx( st, &tilt_code_bck_fx, &gc_threshold_bck_fx, clip_var_bck_fx, &next_force_sf_bck, lsp_new, lsp_mid, &clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, &mem_w0_bck_fx, &streaklimit_fx, &pstreaklen );
-
- IF( !tdm_lp_reuse_flag )
- {
- lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new );
- }
- ELSE
- {
- const Word16 *pt_interp_2_fx;
-
- IF( NE_16( st->active_cnt, 1 ) )
- {
- Word16 beta_index;
- Word16 lsf_wgts_fx[M];
-
- /* intra_frame prediction for the LSFs */
- lsp2lsf_fx( lsp_new, lsf_new_fx, M, 12800 );
-
- Unified_weighting_fx( &st->Bin_E_fx[L_FFT / 2], add( Q_new, ( QSCALE - 2 ) ), lsf_new_fx, lsf_wgts_fx, st->bwidth == NB, (Word16) EQ_16( st->coder_type, UNVOICED ), st->sr_core, M );
-
- tdm_SCh_lsf_reuse_fx( ENC, st->element_brate, lsf_new_fx, lsp_new, tdm_lsfQ_PCh, lsf_wgts_fx, &beta_index );
-
- push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS );
- }
-
- pt_interp_2_fx = interpol_frac_12k8_fx;
-
- test();
- if ( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) )
- {
- pt_interp_2_fx = interpol_frac2_fx;
- }
-
- IF( EQ_16( st->active_cnt, 1 ) )
- {
- Copy( lsp_new, st->lsp_old_fx, M ); // Q15
- lsp2lsf_fx( lsp_new, st->lsf_old_fx, M, st->sr_core ); // Q x2.56
- lsp2lsf_fx( lsp_new, lsf_new_fx, M, st->sr_core ); // Q x2.56
- }
-
- /* LSP interpolation and conversion of LSPs to A(z) */
- int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new, Aq, M, pt_interp_2_fx, 0 );
-
- /* Check LSF stability (distance between old LSFs and current LSFs) */
- st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15
- }
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
- {
- /* Prepare ACB memory from last HQ frame */
- tmpF_fx = hLPDmem->old_exc[0];
- PREEMPH_FX( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx );
- Copy( hLPDmem->old_exc + sub( st->L_frame, M ), hLPDmem->mem_syn, M );
- Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 );
- }
-
- test();
- IF( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
- {
- /* Prepare ACB memory of old_bwe_exc */
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
- }
- ELSE
- {
- lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC );
- }
- }
-
- /*---------------------------------------------------------------*
- * Calculation of LP residual (filtering through A[z] filter)
- *---------------------------------------------------------------*/
-
- calc_residu_fx( st, inp, res_fx, Aq );
- calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
-
- IF( NE_16( att_fx, 32767 /* ONE_IN_Q15 */ ) )
- {
- v_multc_fixed_16_16( res_fx, att_fx, res_fx, st->L_frame );
- }
-
- /*-----------------------------------------------------------------*
- * Determine TC subframe classification
- *-----------------------------------------------------------------*/
-
- IF( EQ_16( st->coder_type, TRANSITION ) )
- {
- tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx );
-
- config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
- }
-
- /*---------------------------------------------------------------*
- * Calculation of prediction for scaled innovation energy
- * (for memory-less gain quantizer)
- *---------------------------------------------------------------*/
-
- IF( nb_bits > 0 )
- {
- Es_pred_enc_fx( &Es_pred_fx, &i, st->L_frame, res_fx, st->voicing_fx, nb_bits, uc_two_stage_flag, Q_new );
- push_indice( hBstr, IND_ES_PRED, i, nb_bits );
- }
-
- /*------------------------------------------------------------*
- * Encode excitation according to coding type
- *------------------------------------------------------------*/
- test();
- test();
- IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
- {
- IF( LE_16( st->coder_type, UNVOICED ) )
- {
- tdm_low_rate_enc( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new );
- }
- ELSE /* GENERIC */
- {
- encod_gen_2sbfr( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
- }
- }
- ELSE IF( nelp_mode )
- {
- /* SC-VBR - NELP frames */
- encod_nelp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
- }
-
- ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
- {
- /* UNVOICED frames (Gauss. excitation) */
- encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
- }
- ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
- {
- encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new );
- }
- ELSE IF( ppp_mode )
- {
- /* SC-VBR - PPP frames */
- IF( ( error = encod_ppp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-
- IF( st->hSC_VBR->bump_up ) /* PPP failed, bump up */
- {
- /* restore memories of LSF quantizer and synthesis filter */
- lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen );
- /* Configure ACELP bit allocation */
- config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
-
- /* redo LSF quantization */
- lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new );
-
- /* recalculation of LP residual (filtering through A[z] filter) */
- calc_residu_fx( st, inp, res_fx, Aq );
- st->hTdCngEnc->burst_ho_cnt = 0;
- move16();
- /* VOICED frames in SC-VBR */
- encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
- }
- }
- ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && st->inactive_coder_type_flag ) )
- {
- /* AUDIO and INACTIVE frames (coded by GSC technology) */
- encod_audio_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
- }
- ELSE
- {
- /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
- encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
- }
-
- FOR( i = 0; i < NB_SUBFR16k; i++ )
- {
- Scale_sig( &Aq[i * ( M + 1 )], ( M + 1 ), sub( Q12, sub( Q14, norm_s( Aq[i * ( M + 1 )] ) ) ) ); // Q12
- }
-
- /* update mem_syn1_flt for ACELP core switching */
- Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M );
-
- /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM );
-
- Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) );
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) );
- move16();
- Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) );
-
- save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- *q_old_syn_12k8_16 = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn );
- move16();
- st->hBWE_FD->q_mem_deemph_old_syn = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn );
- move16();
- Scale_sig( syn_fx, st->L_frame, sub( st->Q_syn, s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ) );
- }
-
- /*Update MODE2 core switching memory*/
- Copy( syn_fx, syn1_fx, st->L_frame );
-
- Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) );
- st->hLPDmem->q_lpd_syn = st->Q_syn;
- move16();
-
- /*Update MODE2 core switching memory*/
- deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) );
-
- Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 );
-
- test();
- IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL )
- {
- Copy( syn1_fx + shr( st->L_frame, 1 ), st->hTcxEnc->Txnq, shr( st->L_frame, 1 ) );
-#ifdef MSAN_FIX
- Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 1 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) );
-#else
- Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 2 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) );
-#endif
- st->hTcxEnc->q_Txnq = st->Q_syn;
- move16();
- }
-
- /*--------------------------------------------------------------------------------------*
- * Modify the excitation signal when the noise is stationary
- *--------------------------------------------------------------------------------------*/
- test();
- test();
- test();
- test();
- IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
- {
- /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */
- Copy( exc_fx, exc2_fx, st->L_frame );
-
- stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, Q_new );
- }
-
- /*-----------------------------------------------------------------*
- * Encode supplementary information for Frame Error Concealment
- *-----------------------------------------------------------------*/
-
- Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) );
-#ifdef MSAN_FIX
- Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) );
-#else
- Scale_sig( res_fx, L_FRAME16k, sub( s_min( st->Q_syn, Q_new ), Q_new ) );
-#endif
- FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) );
- IF( st->hBWE_TD != NULL )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- Copy( Aq + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
- ELSE
- {
- Copy( Aq + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
- }
-
-
- } /* end of active inp coding */
-
- /*-----------------------------------------------------------------*
- * Write ACELP unused bits
- *-----------------------------------------------------------------*/
- test();
- test();
- IF( NE_32( st->core_brate, SID_2k40 ) && NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, PPP_NELP_2k80 ) )
- {
- nBits = st->acelp_cfg.ubits;
- move16();
- WHILE( nBits > 0 )
- {
- i = s_min( nBits, 16 );
- push_indice( hBstr, IND_UNUSED, 0, i );
- nBits = sub( nBits, i );
- }
- }
-
- /*-----------------------------------------------------------------*
- * Apply non linearity in case of SWB TBE
- *-----------------------------------------------------------------*/
-
- IF( st->hBWE_TD != NULL )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st->last_Opt_SC_VBR, 1 ) && st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move16();
- set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
- {
- /* Apply a non linearity to the SHB excitation */
- Copy_Scale_sig_16_32( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
- non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame );
- Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
- }
-
- test();
- if ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Updates
- *-----------------------------------------------------------------*/
-
- IF( st->hBWE_TD != NULL )
- {
- st->Q_exc = Q_new;
- move16();
- }
-
- updt_enc_fx( st, old_exc_fx, pitch_buf, Es_pred_fx, Aq, lsf_new_fx, lsp_new, old_bwe_exc_fx );
- st->hLPDmem->q_lpd_old_exc = Q_new;
- move16();
-
- test();
- test();
- IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && GT_32( st->core_brate, SID_2k40 ) )
- {
- /* update CNG parameters in active frames */
- Word16 q_exc = st->hTdCngEnc->cng_Qexc_buf[0];
- move16();
- FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
- {
- q_exc = s_min( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] );
- }
- q_exc = s_min( q_exc, Q_new );
-
- Scale_sig( exc_fx, L_EXC - L_EXC_MEM, sub( q_exc, Q_new ) );
- FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
- {
- Scale_sig( st->hTdCngEnc->cng_exc2_buf + ii * L_FFT, L_FFT, sub( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ) );
- st->hTdCngEnc->cng_Qexc_buf[ii] = q_exc;
- move16();
- }
- cng_params_upd_ivas_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx,
- &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt,
- st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode,
- st->hFdCngEnc->hFdCngCom->CngBandwidth );
-
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- /* store LSPs@16k, potentially to be used in CNG@16k */
- Copy( st->lsp_old16k_fx, &( st->hTdCngEnc->ho_lsp_circ2_fx[( st->hTdCngEnc->ho_circ_ptr ) * M] ), M );
- }
-
- /* set LSP@16k flag for the first buffer */
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 0;
- }
- ELSE
- {
- st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 1;
- }
- move16();
- /* efficient DTX hangover control */
- IF( GT_16( st->hTdCngEnc->burst_ho_cnt, 1 ) )
- {
- dtx_hangover_control_fx( st, lsp_new );
- }
- }
-
- /* SC-VBR update of average data rate */
- IF( EQ_16( st->vad_flag, 1 ) )
- {
- /* reset in case of bitrate switching in EVS */
- if ( st->hSC_VBR != NULL )
- {
- update_average_rate_fx( st->hSC_VBR, st->core_brate );
- }
- }
- st->prev_Q_new = Q_new;
- move16();
- pop_wmops();
-
- return error;
-}
diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c
index 66e34e2a58b614dace296d7eaea7ec8ceb7cc31b..55d440912ec0d92fa4e384fcfe6e1a91b8a70979 100644
--- a/lib_enc/acelp_core_enc_fx.c
+++ b/lib_enc/acelp_core_enc_fx.c
@@ -6,36 +6,39 @@
#include
#include "options.h" /* Compilation switches */
#include "cnst.h"
+#include "prot.h"
#include "prot_fx.h"
#include "stat_enc.h"
#include "rom_com.h"
-#include "rom_enc.h" /* Encoder static table prototypes */
-#include "rom_com_fx.h" /* Static table prototypes */
-//#include "prot_fx.h" /* Function prototypes */
+#include "rom_enc.h" /* Encoder static table prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
+#include "ivas_cnst.h"
+#include "ivas_prot.h"
+#include "ivas_prot_fx.h"
/*-------------------------------------------------------------------*
- * acelp_core_enc()
+ * acelp_core_enc_fx()
*
* ACELP core encoder
*--------------------------------------------------------------------*/
ivas_error acelp_core_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 inp_fx[], /* i : input signal of the current frame */
- const Word32 ener_fx, /* i : residual energy from Levinson-Durbin*/
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes*/
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors */
- const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame */
- Word16 vad_hover_flag_fx, /* i : VAD hangover flag */
- const Word16 attack_flag, /* i : attack flag (GSC or TC) */
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits_fx, /* o : number of unused bits */
+ const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/
+ const Word32 ener_fx, /* i : residual energy from Levinson-Durbin Q6*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors Qx*/
+ const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors Qx*/
+ Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame Q15*/
+ Word16 vad_hover_flag_fx, /* i : VAD hangover flag Q0*/
+ const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn*/
+ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word16 *unbits_fx, /* o : number of unused bits Q0*/
const Word16 Q_new,
const Word16 shift
#ifdef ADD_LRTD
@@ -86,6 +89,7 @@ ivas_error acelp_core_enc_fx(
Word16 *tdm_Pri_pitch_buf;
Word16 uc_two_stage_flag;
Word16 att;
+ move16();
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
@@ -113,14 +117,15 @@ ivas_error acelp_core_enc_fx(
move16();
coder_type = st_fx->coder_type;
+ move16();
- exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */
- Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM );
+ exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */
+ Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); // q_lpd_old_exc
IF( hBWE_TD != NULL )
{
- bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */
- Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 );
+ bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */
+ Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); // Q_exc
}
ELSE
{
@@ -151,7 +156,8 @@ ivas_error acelp_core_enc_fx(
st_fx->Nb_ACELP_frames = 0;
move16();
}
- st_fx->Nb_ACELP_frames = add( st_fx->Nb_ACELP_frames, 1 );
+ st_fx->Nb_ACELP_frames = add( st_fx->Nb_ACELP_frames, 1 ); // Q0
+ move16();
int_fs_fx = INT_FS_16k_FX;
move16();
@@ -242,13 +248,14 @@ ivas_error acelp_core_enc_fx(
/* convert old quantized LSP vector */
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
- st_fx->rate_switching_reset = lsp_convert_poly_fx( st_fx->lsp_old_fx, st_fx->L_frame, 0 );
+ st_fx->rate_switching_reset = lsp_convert_poly_fx( st_fx->lsp_old_fx, st_fx->L_frame, 0 ); // Q0
+ move16();
}
ELSE
{
- st_fx->rate_switching_reset = st_fx->rate_switching_reset_16kHz;
+ st_fx->rate_switching_reset = st_fx->rate_switching_reset_16kHz; // Q0
move16();
- Copy( st_fx->lsp_old16k_fx, st_fx->lsp_old_fx, M );
+ Copy( st_fx->lsp_old16k_fx, st_fx->lsp_old_fx, M ); // Q15
}
/* convert old quantized LSF vector */
@@ -266,14 +273,14 @@ ivas_error acelp_core_enc_fx(
}
/* Reset LPC mem */
- Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M );
+ Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); // x2.56
set16_fx( st_fx->mem_MA_fx, 0, M );
/* update synthesis filter memories */
synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC );
- Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M );
+ Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); // q_lpd_old_exc
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); // q_mem_syn
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M ); // q_mem_syn
/* update Aw[] coefficients */
weight_a_subfr_fx( shr( st_fx->L_frame, 6 ), A_fx, Aw_fx, st_fx->gamma, M );
@@ -320,24 +327,24 @@ ivas_error acelp_core_enc_fx(
FdCng_exc( st_fx->hFdCngEnc->hFdCngCom, &hDtxEnc->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx,
hDtxEnc->first_CNG, hDtxEnc->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
- Copy( exc2_fx, exc3_fx, st_fx->L_frame );
+ Copy( exc2_fx, exc3_fx, st_fx->L_frame ); // Q12
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
{
IF( hTdCngEnc != NULL )
{
/*IVAS_CODE CNG_att is missing */
- enr = cng_energy_fx( st_fx->element_mode, st_fx->bwidth, hDtxEnc->CNG_mode, /*st_fx->hTdCngEnc->CNG_att*/ 0, exc_fx, st_fx->L_frame, Q_new );
+ enr = cng_energy_fx( st_fx->element_mode, st_fx->bwidth, hDtxEnc->CNG_mode, /*st_fx->hTdCngEnc->CNG_att*/ 0, exc_fx, st_fx->L_frame, Q_new ); // Q8
/* calculate the energy quantization index */
enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */
enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */
/* limit the energy quantization index */
- enr_index = s_min( enr_index, 127 );
+ enr_index = s_min( enr_index, 127 ); // Q0
enr_index = s_max( enr_index, 0 );
- hTdCngEnc->old_enr_index = enr_index;
+ hTdCngEnc->old_enr_index = enr_index; /* Q0 */
move16();
}
}
@@ -361,7 +368,7 @@ ivas_error acelp_core_enc_fx(
Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M );
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn1_fx + st_fx->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM );
+ Copy( syn1_fx + st_fx->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); /* st_fx->Q_syn */
IF( hBWE_FD != NULL )
{
@@ -372,7 +379,7 @@ ivas_error acelp_core_enc_fx(
tmp16 = hLPDmem->syn[M];
move16();
E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st_fx->preemph_fac, st_fx->L_frame, &tmp16 );
- Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 );
+ Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 ); /* st_fx->Q_syn */
}
/*----------------------------------------------------------------*
@@ -408,7 +415,7 @@ ivas_error acelp_core_enc_fx(
test();
IF( st_fx->hDtxEnc != NULL && ( st_fx->last_core_brate == FRAME_NO_DATA || EQ_32( st_fx->last_core_brate, SID_2k40 ) ) )
{
- Copy( hDtxEnc->lspCNG_fx, st_fx->lsp_old_fx, M );
+ Copy( hDtxEnc->lspCNG_fx, st_fx->lsp_old_fx, M ); // Q15
lsp2lsf_fx( hDtxEnc->lspCNG_fx, st_fx->lsf_old_fx, M, int_fs_fx );
}
@@ -580,8 +587,7 @@ ivas_error acelp_core_enc_fx(
ELSE IF( EQ_16( coder_type, TRANSITION ) )
{
tc_subfr_fx = encod_tran_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx,
- exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new );
- move16();
+ exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */
}
ELSE IF( hSC_VBR->ppp_mode )
{
@@ -632,7 +638,7 @@ ivas_error acelp_core_enc_fx(
}
/* update st->mem_syn1 for ACELP core switching */
- Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M );
+ Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M ); /* q_mem_syn */
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
Copy( syn_fx + st_fx->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM );
@@ -643,25 +649,31 @@ ivas_error acelp_core_enc_fx(
save_old_syn_fx( st_fx->L_frame, syn_fx, old_syn_12k8_16k_fx, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx );
}
/*Update MODE2 core switching memory*/
- Copy( syn_fx, syn1_fx, st_fx->L_frame );
+ Copy( syn_fx, syn1_fx, st_fx->L_frame ); // Q_syn
E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st_fx->preemph_fac, st_fx->L_frame, &hLPDmem->syn[M] );
- Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 );
- IF( GT_16( st_fx->element_mode, EVS_MONO ) && st_fx->hTcxEnc != NULL )
+ Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 ); // Q_syn
+
+ test();
+ IF( st_fx->element_mode > EVS_MONO && st_fx->hTcxEnc != NULL )
{
- Copy( syn1_fx + st_fx->L_frame / 2, st_fx->hTcxEnc->Txnq, st_fx->L_frame / 2 );
+ Copy( syn1_fx + st_fx->L_frame / 2, st_fx->hTcxEnc->Txnq, st_fx->L_frame / 2 ); // Q_syn
}
/*--------------------------------------------------------------------------------------*
* Modify the excitation signal when the noise is stationary
*--------------------------------------------------------------------------------------*/
+ test();
+ test();
+ test();
+ test();
IF( !( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st_fx->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
{
L_epsP[0] = L_Comp( epsP_h_fx[2], epsP_l_fx[2] );
move32();
L_epsP[1] = L_Comp( epsP_h_fx[M], epsP_l_fx[M] );
move32();
- Copy( exc_fx, exc2_fx, st_fx->L_frame );
+ Copy( exc_fx, exc2_fx, st_fx->L_frame ); // Q_new
stat_noise_uv_enc_fx( st_fx, L_epsP, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag, Q_new );
}
@@ -677,11 +689,11 @@ ivas_error acelp_core_enc_fx(
{
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
- Copy( Aq_fx + 2 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
+ Copy( Aq_fx + 2 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
}
ELSE
{
- Copy( Aq_fx + 3 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
+ Copy( Aq_fx + 3 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
}
}
} /* end of active inp coding */
@@ -695,13 +707,14 @@ ivas_error acelp_core_enc_fx(
IF( NE_32( st_fx->core_brate, SID_2k40 ) && NE_32( st_fx->core_brate, FRAME_NO_DATA ) && NE_32( st_fx->core_brate, PPP_NELP_2k80 ) )
{
/* reserved bits */
- nBits = st_fx->acelp_cfg.ubits;
+ nBits = st_fx->acelp_cfg.ubits; // Q0
+ move16();
WHILE( nBits > 0 )
{
- i = s_min( nBits, 16 );
+ i = s_min( nBits, 16 ); // Q0
push_indice_fx( st_fx->hBstr, IND_UNUSED, 0, i );
- nBits = sub( nBits, i );
+ nBits = sub( nBits, i ); // Q0
}
}
@@ -742,6 +755,7 @@ ivas_error acelp_core_enc_fx(
*-----------------------------------------------------------------*/
updt_enc_fx( st_fx, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, old_bwe_exc_fx );
+ test();
test();
IF( hTdCngEnc != NULL && ( st_fx->Opt_DTX_ON != 0 ) && ( GT_32( st_fx->core_brate, SID_2k40 ) ) )
{
@@ -753,7 +767,7 @@ ivas_error acelp_core_enc_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
/* store LSPs@16k, potentially to be used in CNG@16k */
- Copy( st_fx->lsp_old16k_fx, &( hTdCngEnc->ho_lsp_circ2_fx[( hTdCngEnc->ho_circ_ptr ) * M] ), M );
+ Copy( st_fx->lsp_old16k_fx, &( hTdCngEnc->ho_lsp_circ2_fx[( hTdCngEnc->ho_circ_ptr ) * M] ), M ); // Q15
}
/* Set 16k LSP flag for CNG buffer */
@@ -773,6 +787,7 @@ ivas_error acelp_core_enc_fx(
}
/* SC-VBR update of average data rate */
+ test();
IF( EQ_16( st_fx->vad_flag, 1 ) && ( hSC_VBR != NULL ) )
{
update_average_rate_fx( hSC_VBR, st_fx->core_brate );
@@ -780,3 +795,925 @@ ivas_error acelp_core_enc_fx(
return error;
}
+
+/*-------------------------------------------------------------------*
+ * acelp_core_enc_ivas_fx()
+ *
+ * ACELP core encoder
+ *--------------------------------------------------------------------*/
+ivas_error acelp_core_enc_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 inp[], /* i : input signal of the current frame Q_new*/
+ Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/
+ Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/
+ Word16 *q_old_syn_12k8_16,
+ Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word16 *unbits, /* o : number of unused bits Q0*/
+ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
+ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/
+ Word16 Q_new )
+{
+ Word16 i, nBits; /* reserved bits */
+ LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */
+ Word16 tc_subfr; /* TC sub-frame indication */
+ Word16 allow_cn_step;
+ Word32 int_fs;
+ Word16 nb_bits; /* parameters handling */
+
+ /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */
+ Word16 pstreaklen;
+ Word16 sid_bw = -1;
+ move16();
+ Word16 next_force_sf_bck;
+ Word16 uc_two_stage_flag;
+ Word16 position;
+ Word16 ppp_mode, nelp_mode;
+ Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
+
+ /* bitstream */
+ BSTR_ENC_HANDLE hBstr = st->hBstr;
+ Word16 old_exc_fx[L_EXC], *exc_fx; /* excitation signal buffer */
+ Word16 lsf_new_fx[M]; /* ISFs at the end of the frame */
+ Word16 Aq[NB_SUBFR16k * ( M + 1 )]; /* A(z) quantized for the 4 subframes */
+ Word16 syn_fx[L_FRAME16k]; /* synthesis vector */
+ Word16 res_fx[L_FRAME16k]; /* Residual signal for FER protection */
+ Word16 exc2_fx[L_FRAME16k]; /* enhanced excitation */
+ Word16 Es_pred_fx; /* predicited scaled innovation energy */
+ Word16 tmp_noise_fx; /* NB post-filter long-term noise energy*/
+ Word16 old_bwe_exc_fx[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer Q_new */
+ Word16 *bwe_exc_fx; /* excitation for SWB TBE Q_new */
+ Word16 mem_MA_fx[M], mem_AR_fx[M], lsp_new_bck_fx[M], /*lsf_new_bck_fx[M],*/ lsp_mid_bck_fx[M], mem_syn_bck_fx[M];
+ Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2];
+ Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx;
+
+#ifdef MSAN_FIX
+ set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 );
+ set16_fx( old_exc_fx, 0, L_EXC );
+ set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) );
+ set16_fx( syn_fx, 0, L_FRAME16k );
+#endif
+
+ Word16 tilt_code_bck_fx;
+ Word32 gc_threshold_bck_fx;
+ Word16 clip_var_bck_fx[6];
+ Word32 q_env_fx[NUM_ENV_CNG];
+#ifdef MSAN_FIX
+ set32_fx( q_env_fx, 0, NUM_ENV_CNG );
+#endif
+ Word16 exc3_fx[L_FRAME16k];
+ Word16 syn1_fx[L_FRAME16k];
+ Word16 *tdm_Pri_pitch_buf_fx;
+
+ Word16 att_fx;
+ Word16 tmpF_fx;
+
+ test();
+ IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL )
+ {
+ Scale_sig( st->hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2, sub( Q_new, st->prev_Q_new ) ); // Q_new
+ }
+ IF( st->hLPDmem )
+ {
+ Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, st->hLPDmem->q_lpd_old_exc ) ); // Q_new
+ st->hLPDmem->q_lpd_old_exc = Q_new;
+ move16();
+ Scale_sig( st->hLPDmem->syn, M + 1, sub( Q_new, st->hLPDmem->q_lpd_syn ) ); // Q_new
+ st->hLPDmem->q_lpd_syn = Q_new;
+ move16();
+ Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ move16();
+ st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
+ move16();
+ }
+
+ Scale_sig32( st->Bin_E_old_fx, L_FFT / 2, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E_old ) ); // Q_new + Q_scale - 2
+ st->q_Bin_E_old = add( Q_new, Q_SCALE - 2 );
+ move16();
+ Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E ) ); // Q_new + Q_scale - 2
+ st->q_Bin_E = add( Q_new, Q_SCALE - 2 );
+ move16();
+
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+ move32();
+
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->core_brate, SID_2k40 ) )
+ {
+ /* Core was ACELP because of DTX in MDCT-Stereo, but SID encoding for that is done in separate function */
+ return error;
+ }
+
+ push_wmops( "acelp_core_enc" );
+ /*------------------------------------------------------------------*
+ * Initialization
+ *------------------------------------------------------------------*/
+
+ hLPDmem = st->hLPDmem;
+
+ Es_pred_fx = 0;
+ move16();
+
+ exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */
+ Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); /* Q_new */
+ Scale_sig( old_exc_fx, L_EXC_MEM, sub( Q_new, hLPDmem->q_lpd_old_exc ) ); // Q_new
+ IF( st->hBWE_TD != NULL )
+ {
+ bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */
+ Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); // Q_new
+ }
+ ELSE
+ {
+ bwe_exc_fx = NULL;
+ }
+
+ st->bpf_off = 0;
+ move16();
+
+ test();
+ test();
+ test();
+ IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) )
+ {
+ /* in case of HQ->ACELP switching, do not apply BPF */
+ st->bpf_off = 1;
+ move16();
+ /* reset the GSC pre echo energy threshold in case of switching */
+ if ( st->hGSCEnc != NULL )
+ {
+ st->hGSCEnc->Last_frame_ener_fx = MAX_32;
+ move32();
+ }
+ }
+
+ /* force safety-net LSFQ in the first frames after CNG segment */
+ if ( LE_32( st->last_core_brate, SID_2k40 ) )
+ {
+ st->Nb_ACELP_frames = 0;
+ move16();
+ }
+ st->Nb_ACELP_frames = add( st->Nb_ACELP_frames, 1 );
+ move16();
+
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ int_fs = INT_FS_12k8;
+ move32();
+ }
+ ELSE
+ {
+ int_fs = INT_FS_16k;
+ move32();
+ }
+
+ tmp_noise_fx = 0;
+ move16();
+ tc_subfr = -1;
+ move16();
+ position = -1;
+ move16();
+
+ /* SC-VBR temporary variables */
+ pstreaklen = 0;
+ move16();
+ clip_var_fx = 0;
+ move16();
+ mem_w0_bck_fx = 0;
+ move16();
+ streaklimit_fx = 0;
+ move16();
+
+ /* channel-aware mode */
+ reset_rf_indices_fx( st );
+
+ /* VBR modes */
+ IF( st->Opt_SC_VBR )
+ {
+ ppp_mode = st->hSC_VBR->ppp_mode;
+ nelp_mode = st->hSC_VBR->nelp_mode;
+ }
+ ELSE
+ {
+ ppp_mode = 0;
+ nelp_mode = 0;
+ }
+ move16();
+ move16();
+
+ test();
+ /* TD stereo */
+
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
+ {
+ tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; // Q0
+ tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; // Q0
+ tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; // Q0
+ tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx; // Q6
+ move16();
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ tdm_lp_reuse_flag = 0;
+ tdm_low_rate_mode = 0;
+ move16();
+ move16();
+
+ test();
+ if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode )
+ {
+ tdm_low_rate_mode = 1;
+ move16();
+ }
+ tdm_Pitch_reuse_flag = 0;
+ move16();
+ tdm_Pri_pitch_buf_fx = NULL;
+ }
+
+ /*-----------------------------------------------------------------*
+ * ACELP@12k8 / ACELP@16k switching
+ *-----------------------------------------------------------------*/
+
+ test();
+ test();
+ IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) )
+ {
+ /* in case of switching, do not apply BPF (flag employed also in updt_enc()) */
+ st->bpf_off = 1;
+ move16();
+
+ /* force safety-net LSFQ in the first frames after ACELP@12k8/ACELP@16k switching */
+ st->Nb_ACELP_frames = 1;
+ move16();
+
+ /* convert old quantized LSP vector */
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); // Q0
+ move16();
+ }
+ ELSE
+ {
+ st->rate_switching_reset = st->rate_switching_reset_16kHz; // Q0
+ move16();
+ Copy( st->lsp_old16k_fx, st->lsp_old_fx, M ); // Q15
+ }
+
+ /* convert old quantized LSF vector */
+ lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs );
+
+ /* interpolation of unquantized ISPs */
+ IF( st->rate_switching_reset )
+ {
+ /*extrapolation in case of unstable LSP*/
+ int_lsp4_ivas_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 );
+ }
+ ELSE
+ {
+ int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 );
+ }
+
+ /* Reset LPC mem */
+ Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); // Q2.56
+ set16_fx( st->mem_MA_fx, 0, M );
+
+ /* update synthesis filter memories */
+ synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC );
+ Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); // Q_new
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); /* hLPDmem->q_mem_syn */
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M ); /* hLPDmem->q_mem_syn */
+
+ /* update Aw[] coefficients */
+ weight_a_subfr_fx( shr( st->L_frame, 6 ), A, Aw, st->gamma, M );
+ }
+ IF( st->hLPDmem )
+ {
+ st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
+ move16();
+ st->hLPDmem->q_lpd_old_exc = Q_new;
+ move16();
+ st->hLPDmem->q_lpd_syn = Q_new;
+ move16();
+ }
+
+ test();
+ test();
+ if ( st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0 )
+ {
+ st->rate_switching_reset = 1;
+ move16();
+ }
+
+ /*----------------------------------------------------------------*
+ * Encoding of CNG frames
+ *----------------------------------------------------------------*/
+ test();
+ IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA )
+ {
+ IF( st->cng_type == LP_CNG )
+ {
+ /* Run CNG post parameter update */
+ cng_params_postupd_ivas_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
+
+ /* encode CNG parameters */
+ CNG_enc_ivas_fx( st, Aq, inp, /*ener_fx,*/ lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw );
+
+ /* comfort noise generation */
+ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngEnc->Enew_fx, &st->hTdCngEnc->cng_seed, exc_fx, exc2_fx, &st->hTdCngEnc->lp_ener_fx, st->last_core_brate,
+ &st->hDtxEnc->first_CNG, &st->hTdCngEnc->cng_ener_seed, bwe_exc_fx, allow_cn_step, &st->hTdCngEnc->last_allow_cn_step, sub( st->prev_Q_new, 1 ), sub( Q_new, 1 ), st->hTdCngEnc->num_ho,
+ q_env_fx, st->hTdCngEnc->lp_env_fx, st->hTdCngEnc->old_env_fx, st->hTdCngEnc->exc_mem_fx, st->hTdCngEnc->exc_mem1_fx, &sid_bw, &st->hTdCngEnc->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, EVS_MONO );
+
+ Scale_sig( exc_fx, st->L_frame, 1 ); // Q_new + 1
+ }
+ ELSE
+ {
+ test();
+ IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ FdCng_encodeSID_ivas_fx( st );
+ st->hDtxEnc->last_CNG_L_frame = st->L_frame;
+ move16();
+ }
+
+ Word16 Q_cngNoise = Q31, zero_flag = 0;
+ move16();
+ move16();
+ FOR( Word16 j = 0; j < NPART; j++ )
+ {
+ IF( st->hFdCngEnc->hFdCngCom->cngNoiseLevel[j] != 0 )
+ {
+ zero_flag = 1;
+ move16();
+ BREAK;
+ }
+ }
+ IF( zero_flag )
+ {
+ Q_cngNoise = getScaleFactor32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART );
+ }
+ Scale_sig32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART, Q_cngNoise ); /* st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp - Q_cngNoise */
+ st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp = sub( st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp, Q_cngNoise );
+ move16();
+
+ generate_comfort_noise_enc_ivas_fx( st, Q_new, 1 );
+ st->hTcxEnc->q_Txnq = Q_new;
+ move16();
+ Scale_sig( st->hFdCngEnc->hFdCngCom->A_cng, ( M + 1 ), sub( Q12, sub( 14, norm_s( st->hFdCngEnc->hFdCngCom->A_cng[0] ) ) ) ); /* Q12 */
+ FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq, lsp_new, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
+ Copy( exc2_fx, exc3_fx, st->L_frame ); // Q_new
+
+ IF( EQ_32( st->core_brate, SID_2k40 ) )
+ {
+ IF( st->hTdCngEnc != NULL )
+ {
+ Word16 enr, enr_index;
+ enr = cng_energy_ivas_fx( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att_fx, exc_fx, st->L_frame, Q_new ); /* Q8 */
+
+ /* calculate the energy quantization index */
+ enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */
+ enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */
+
+ /* limit the energy quantization index */
+ enr_index = s_min( enr_index, 127 ); /* Q0 */
+ enr_index = s_max( enr_index, 0 );
+ st->hTdCngEnc->old_enr_index = enr_index; /* Q0 */
+ move16();
+ }
+ }
+ }
+
+ /* Reset HO counter in the first SID frame */
+ if ( st->hTdCngEnc != NULL )
+ {
+ st->hTdCngEnc->burst_ho_cnt = 0;
+ move16();
+ }
+
+ Scale_sig( st->hLPDmem->mem_syn, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ Scale_sig( st->hLPDmem->mem_syn2, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ Scale_sig( st->hLPDmem->mem_syn3, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ move16();
+ st->hLPDmem->q_mem_syn = st->Q_syn;
+ move16();
+
+ /* synthesis at 12.8kHz sampling rate */
+ syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn );
+
+ /* reset the encoder */
+ CNG_reset_enc_fx( st, hLPDmem, pitch_buf, voice_factors_fx, 0 );
+
+ /* update st->mem_syn1_flt for ACELP core switching */
+ Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn1_fx, M ); /* hLPDmem->q_mem_syn */
+
+ /* update ACELP core synthesis filter memory */
+ Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M ); /* hLPDmem->q_mem_syn */
+
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ Copy( syn1_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // st->Q_syn
+
+ /* save and delay synthesis to be used by SWB BWE */
+ IF( st->hBWE_FD != NULL )
+ {
+ st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ); /* st->Q_syn */
+ move16();
+ Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ); /* st->Q_syn */
+ save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
+ *q_old_syn_12k8_16 = st->Q_syn;
+ move16();
+ st->hBWE_FD->q_mem_deemph_old_syn = st->Q_syn;
+ move16();
+ }
+
+ Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) ); /* st->Q_syn */
+ st->hLPDmem->q_lpd_syn = st->Q_syn;
+ move16();
+
+ /*Update MODE2 core switching memory*/
+ deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) );
+ Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); /* st->Q_syn */
+ }
+
+ /*----------------------------------------------------------------*
+ * Encoding of all other frames
+ *----------------------------------------------------------------*/
+ ELSE
+ {
+
+ /*-----------------------------------------------------------------*
+ * Configure ACELP bit allocation
+ *-----------------------------------------------------------------*/
+
+ Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k );
+ Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */
+ st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp );
+ move16();
+ nb_bits = 0;
+ move16();
+ st->acelp_cfg.FEC_mode = 0;
+ move16();
+ uc_two_stage_flag = 0;
+ move16();
+
+ test();
+ IF( !nelp_mode && !ppp_mode )
+ {
+ config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+ }
+
+ /*-----------------------------------------------------------------*
+ * After inactive period, use the most up-to-date ISPs
+ *-----------------------------------------------------------------*/
+
+ test();
+ test();
+ IF( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) )
+ {
+ Copy( st->hDtxEnc->lspCNG_fx, st->lsp_old_fx, M ); // Q15
+ lsp2lsf_fx( st->hDtxEnc->lspCNG_fx, st->lsf_old_fx, M, int_fs );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Reset higher ACELP pre-quantizer in case of switching
+ *-----------------------------------------------------------------*/
+
+ IF( !st->use_acelp_preq )
+ {
+ st->mem_deemp_preQ_fx = 0;
+ move16();
+ st->mem_preemp_preQ_fx = 0;
+ move16();
+ st->last_code_preq = 0;
+ move16();
+ st->last_nq_preQ = 0;
+ move16();
+ }
+ st->use_acelp_preq = 0;
+ move16();
+
+ /*-----------------------------------------------------------------*
+ * LSF Quantization
+ * A[z] calculation
+ *-----------------------------------------------------------------*/
+
+ /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */
+ lsf_syn_mem_backup_ivas_fx( st, &tilt_code_bck_fx, &gc_threshold_bck_fx, clip_var_bck_fx, &next_force_sf_bck, lsp_new, lsp_mid, &clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, &mem_w0_bck_fx, &streaklimit_fx, &pstreaklen );
+
+ IF( !tdm_lp_reuse_flag )
+ {
+ lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new );
+ }
+ ELSE
+ {
+ const Word16 *pt_interp_2_fx;
+
+ IF( NE_16( st->active_cnt, 1 ) )
+ {
+ Word16 beta_index;
+ Word16 lsf_wgts_fx[M];
+
+ /* intra_frame prediction for the LSFs */
+ lsp2lsf_fx( lsp_new, lsf_new_fx, M, 12800 );
+
+ Unified_weighting_fx( &st->Bin_E_fx[L_FFT / 2], add( Q_new, ( QSCALE - 2 ) ), lsf_new_fx, lsf_wgts_fx, st->bwidth == NB, (Word16) EQ_16( st->coder_type, UNVOICED ), st->sr_core, M );
+
+ tdm_SCh_lsf_reuse_fx( ENC, st->element_brate, lsf_new_fx, lsp_new, tdm_lsfQ_PCh, lsf_wgts_fx, &beta_index );
+
+ push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS );
+ }
+
+ pt_interp_2_fx = interpol_frac_12k8_fx;
+
+ test();
+ if ( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) )
+ {
+ pt_interp_2_fx = interpol_frac2_fx; // Q15
+ }
+
+ IF( EQ_16( st->active_cnt, 1 ) )
+ {
+ Copy( lsp_new, st->lsp_old_fx, M ); // Q15
+ lsp2lsf_fx( lsp_new, st->lsf_old_fx, M, st->sr_core ); // Q x2.56
+ lsp2lsf_fx( lsp_new, lsf_new_fx, M, st->sr_core ); // Q x2.56
+ }
+
+ /* LSP interpolation and conversion of LSPs to A(z) */
+ int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new, Aq, M, pt_interp_2_fx, 0 );
+
+ /* Check LSF stability (distance between old LSFs and current LSFs) */
+ st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15
+ move16();
+ }
+ test();
+ IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory from last HQ frame */
+ tmpF_fx = hLPDmem->old_exc[0];
+ move16();
+ PREEMPH_FX( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx );
+ Copy( hLPDmem->old_exc + sub( st->L_frame, M ), hLPDmem->mem_syn, M ); /* Q_new */
+ Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 );
+ }
+
+ test();
+ IF( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory of old_bwe_exc */
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
+ }
+ ELSE
+ {
+ lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC );
+ }
+ }
+
+ /*---------------------------------------------------------------*
+ * Calculation of LP residual (filtering through A[z] filter)
+ *---------------------------------------------------------------*/
+
+ calc_residu_fx( st, inp, res_fx, Aq );
+ calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
+
+ IF( NE_16( att_fx, 32767 /* ONE_IN_Q15 */ ) )
+ {
+ v_multc_fixed_16_16( res_fx, att_fx, res_fx, st->L_frame );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Determine TC subframe classification
+ *-----------------------------------------------------------------*/
+
+ IF( EQ_16( st->coder_type, TRANSITION ) )
+ {
+ tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx );
+
+ config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+ }
+
+ /*---------------------------------------------------------------*
+ * Calculation of prediction for scaled innovation energy
+ * (for memory-less gain quantizer)
+ *---------------------------------------------------------------*/
+
+ IF( nb_bits > 0 )
+ {
+ Es_pred_enc_fx( &Es_pred_fx, &i, st->L_frame, res_fx, st->voicing_fx, nb_bits, uc_two_stage_flag, Q_new );
+ push_indice( hBstr, IND_ES_PRED, i, nb_bits );
+ }
+
+ /*------------------------------------------------------------*
+ * Encode excitation according to coding type
+ *------------------------------------------------------------*/
+ test();
+ test();
+ IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
+ {
+ IF( LE_16( st->coder_type, UNVOICED ) )
+ {
+ tdm_low_rate_enc( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new );
+ }
+ ELSE /* GENERIC */
+ {
+ encod_gen_2sbfr( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
+ }
+ }
+ ELSE IF( nelp_mode )
+ {
+ /* SC-VBR - NELP frames */
+ encod_nelp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
+ }
+
+ ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
+ {
+ /* UNVOICED frames (Gauss. excitation) */
+ encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
+ }
+ ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
+ {
+ encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new );
+ }
+ ELSE IF( ppp_mode )
+ {
+ /* SC-VBR - PPP frames */
+ IF( ( error = encod_ppp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ IF( st->hSC_VBR->bump_up ) /* PPP failed, bump up */
+ {
+ /* restore memories of LSF quantizer and synthesis filter */
+ lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen );
+ /* Configure ACELP bit allocation */
+ config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+
+ /* redo LSF quantization */
+ lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new );
+
+ /* recalculation of LP residual (filtering through A[z] filter) */
+ calc_residu_fx( st, inp, res_fx, Aq );
+ st->hTdCngEnc->burst_ho_cnt = 0;
+ move16();
+ /* VOICED frames in SC-VBR */
+ encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
+ }
+ }
+ ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) )
+ {
+ /* AUDIO and INACTIVE frames (coded by GSC technology) */
+ encod_audio_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
+ }
+ ELSE
+ {
+ /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
+ encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
+ }
+
+ FOR( i = 0; i < NB_SUBFR16k; i++ )
+ {
+ Scale_sig( &Aq[i * ( M + 1 )], ( M + 1 ), sub( Q12, sub( Q14, norm_s( Aq[i * ( M + 1 )] ) ) ) ); // Q12
+ }
+
+ /* update mem_syn1_flt for ACELP core switching */
+ Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M ); // Q_syn
+
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // st->Q_syn
+
+ Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn
+ /* save and delay synthesis to be used by SWB BWE */
+ IF( st->hBWE_FD != NULL )
+ {
+ st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn )
+ move16();
+ Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn )
+
+ save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
+ *q_old_syn_12k8_16 = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn );
+ move16();
+ st->hBWE_FD->q_mem_deemph_old_syn = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn );
+ move16();
+ Scale_sig( syn_fx, st->L_frame, sub( st->Q_syn, s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ) ); // st->Q_syn
+ }
+
+ /*Update MODE2 core switching memory*/
+ Copy( syn_fx, syn1_fx, st->L_frame ); // st->Q_syn
+
+ Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) ); // st->Q_syn
+ st->hLPDmem->q_lpd_syn = st->Q_syn;
+ move16();
+
+ /*Update MODE2 core switching memory*/
+ deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) );
+
+ Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); // st->Q_syn
+
+ test();
+ IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL )
+ {
+ Copy( syn1_fx + shr( st->L_frame, 1 ), st->hTcxEnc->Txnq, shr( st->L_frame, 1 ) ); // st->Q_syn
+#ifdef MSAN_FIX
+ Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 1 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) ); // st->Q_syn
+#else
+ Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 2 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) );
+#endif
+ st->hTcxEnc->q_Txnq = st->Q_syn;
+ move16();
+ }
+
+ /*--------------------------------------------------------------------------------------*
+ * Modify the excitation signal when the noise is stationary
+ *--------------------------------------------------------------------------------------*/
+ test();
+ test();
+ test();
+ test();
+ IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
+ {
+ /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */
+ Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new
+
+ stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, Q_new );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Encode supplementary information for Frame Error Concealment
+ *-----------------------------------------------------------------*/
+
+ Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) ); // min( st->Q_syn, Q_new )
+#ifdef MSAN_FIX
+ Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); // min( st->Q_syn, Q_new )
+#else
+ Scale_sig( res_fx, L_FRAME16k, sub( s_min( st->Q_syn, Q_new ), Q_new ) );
+#endif
+ FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) );
+ IF( st->hBWE_TD != NULL )
+ {
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ Copy( Aq + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
+ }
+ ELSE
+ {
+ Copy( Aq + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
+ }
+ }
+
+
+ } /* end of active inp coding */
+
+ /*-----------------------------------------------------------------*
+ * Write ACELP unused bits
+ *-----------------------------------------------------------------*/
+ test();
+ test();
+ IF( NE_32( st->core_brate, SID_2k40 ) && st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, PPP_NELP_2k80 ) )
+ {
+ nBits = st->acelp_cfg.ubits; // Q0
+ move16();
+ WHILE( nBits > 0 )
+ {
+ i = s_min( nBits, 16 ); // Q0
+ push_indice( hBstr, IND_UNUSED, 0, i );
+ nBits = sub( nBits, i ); // Q0
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Apply non linearity in case of SWB TBE
+ *-----------------------------------------------------------------*/
+
+ IF( st->hBWE_TD != NULL )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_16( st->last_Opt_SC_VBR, 1 ) && st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
+ {
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move16();
+ set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
+ {
+ /* Apply a non linearity to the SHB excitation */
+ Copy_Scale_sig_16_32( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
+ non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame );
+ Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
+ }
+
+ test();
+ if ( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA )
+ {
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move16();
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Updates
+ *-----------------------------------------------------------------*/
+
+ if ( st->hBWE_TD != NULL )
+ {
+ st->Q_exc = Q_new;
+ move16();
+ }
+
+ updt_enc_fx( st, old_exc_fx, pitch_buf, Es_pred_fx, Aq, lsf_new_fx, lsp_new, old_bwe_exc_fx );
+ st->hLPDmem->q_lpd_old_exc = Q_new;
+ move16();
+
+ test();
+ test();
+ IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && GT_32( st->core_brate, SID_2k40 ) )
+ {
+ /* update CNG parameters in active frames */
+ Word16 q_exc = st->hTdCngEnc->cng_Qexc_buf[0];
+ move16();
+ FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
+ {
+ q_exc = s_min( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] );
+ }
+ q_exc = s_min( q_exc, Q_new );
+
+ Scale_sig( exc_fx, L_EXC - L_EXC_MEM, sub( q_exc, Q_new ) ); // q_exc
+ FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
+ {
+ Scale_sig( st->hTdCngEnc->cng_exc2_buf + ii * L_FFT, L_FFT, sub( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ) ); // Q_exc
+ st->hTdCngEnc->cng_Qexc_buf[ii] = q_exc;
+ move16();
+ }
+ cng_params_upd_ivas_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx,
+ &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt,
+ st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode,
+ st->hFdCngEnc->hFdCngCom->CngBandwidth );
+
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ /* store LSPs@16k, potentially to be used in CNG@16k */
+ Copy( st->lsp_old16k_fx, &( st->hTdCngEnc->ho_lsp_circ2_fx[( st->hTdCngEnc->ho_circ_ptr ) * M] ), M ); // Q15
+ }
+
+ /* set LSP@16k flag for the first buffer */
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 0;
+ }
+ ELSE
+ {
+ st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 1;
+ }
+ move16();
+ /* efficient DTX hangover control */
+ IF( GT_16( st->hTdCngEnc->burst_ho_cnt, 1 ) )
+ {
+ dtx_hangover_control_fx( st, lsp_new );
+ }
+ }
+
+ /* SC-VBR update of average data rate */
+ IF( EQ_16( st->vad_flag, 1 ) )
+ {
+ /* reset in case of bitrate switching in EVS */
+ if ( st->hSC_VBR != NULL )
+ {
+ update_average_rate_fx( st->hSC_VBR, st->core_brate );
+ }
+ }
+ pop_wmops();
+
+ return error;
+}
diff --git a/lib_enc/acelp_core_switch_enc.c b/lib_enc/acelp_core_switch_enc.c
deleted file mode 100644
index 9d6f499db09e405ecf613f29cb1442072afc3305..0000000000000000000000000000000000000000
--- a/lib_enc/acelp_core_switch_enc.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_enc.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c
index 029e3083ea893830d663c161a859cc83aa2943f9..b09f2396642259fa5a12b049819003c2491b40e4 100644
--- a/lib_enc/acelp_core_switch_enc_fx.c
+++ b/lib_enc/acelp_core_switch_enc_fx.c
@@ -71,11 +71,11 @@ void acelp_core_switch_enc_fx(
move16(); /* pointer to excitation signal in the current frame */
Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /*now old_exc has the same scaling as st_fx->old_exc; need to change later? */
- Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 );
- Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 );
- T_op[0] = st_fx->pitch[0];
+ Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 ); /* Q12 */
+ Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 ); /* Q12 */
+ T_op[0] = st_fx->pitch[0]; /* Q0 */
move16();
- T_op[1] = st_fx->pitch[1];
+ T_op[1] = st_fx->pitch[1]; /* Q0 */
move16();
/*----------------------------------------------------------------*
@@ -84,7 +84,7 @@ void acelp_core_switch_enc_fx(
IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) /* ACELP@12k8 core */
{
- inp = inp12k8;
+ inp = inp12k8; /* Q0 */
IF( GT_32( st_fx->core_brate, ACELP_24k40 ) )
{
@@ -97,7 +97,7 @@ void acelp_core_switch_enc_fx(
}
ELSE /* ACELP@16k core */
{
- inp = inp16k;
+ inp = inp16k; /* Q0 */
IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
{
@@ -139,9 +139,9 @@ void acelp_core_switch_enc_fx(
#else
IF( NE_16( st_fx->last_L_frame, L_FRAME ) )
{
- T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[0] ), 2 ) ), 1 ), 1 );
+ T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[0] ), 2 ) ), 1 ), 1 ); /* Q0 */
move16();
- T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[1] ), 2 ) ), 1 ), 1 );
+ T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[1] ), 2 ) ), 1 ), 1 ); /* Q0 */
move16();
}
#endif
@@ -170,11 +170,11 @@ void acelp_core_switch_enc_fx(
#else
FOR( i = 0; i < 20; i++ )
{
- hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value;
+ hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value; /* Q0 */
move16();
- hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].nb_bits = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits;
+ hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].nb_bits = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits; /* Q0 */
move16();
- hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1;
+ hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1; /* Q0 */
move16();
}
#endif
@@ -218,11 +218,11 @@ void acelp_core_switch_enc_ivas_fx(
move16(); /* pointer to excitation signal in the current frame */
Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /*now old_exc has the same scaling as st_fx->old_exc; need to change later? */
- Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 );
- Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 );
- T_op[0] = st_fx->pitch[0];
+ Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 ); /* Q12 */
+ Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 ); /* Q12 */
+ T_op[0] = st_fx->pitch[0]; /* Q12 */
move16();
- T_op[1] = st_fx->pitch[1];
+ T_op[1] = st_fx->pitch[1]; /* Q12 */
move16();
/*----------------------------------------------------------------*
@@ -231,7 +231,7 @@ void acelp_core_switch_enc_ivas_fx(
IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) /* ACELP@12k8 core */
{
- inp = inp12k8;
+ inp = inp12k8; /* Q0 */
IF( GT_32( st_fx->core_brate, ACELP_24k40 ) )
{
@@ -244,7 +244,7 @@ void acelp_core_switch_enc_ivas_fx(
}
ELSE /* ACELP@16k core */
{
- inp = inp16k;
+ inp = inp16k; /* Q0 */
IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
{
@@ -256,15 +256,15 @@ void acelp_core_switch_enc_ivas_fx(
}
ELSE
{
- cbrate = L_min( st_fx->core_brate, ACELP_22k60 );
+ cbrate = L_min( st_fx->core_brate, ACELP_22k60 ); /* Q0 */
}
}
IF( NE_16( st_fx->last_L_frame, L_FRAME ) )
{
- T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[0] ), 2 ) ), 1 ), 1 );
+ T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480 /* 1.25 in Q14 */, T_op[0] ), 2 ) ), 1 ), 1 ); /* Q0 */
move16();
- T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[1] ), 2 ) ), 1 ), 1 );
+ T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480 /* 1.25 in Q14 */, T_op[1] ), 2 ) ), 1 ), 1 ); /* Q0 */
move16();
}
@@ -280,7 +280,7 @@ void acelp_core_switch_enc_ivas_fx(
* bit-stream: modify the layer of sub frame CELP
*----------------------------------------------------------------*/
- i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits );
+ i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); /* Q0 */
while ( hBstr->ind_list[i].id == TAG_ACELP_SUBFR_LOOP_START )
{
@@ -312,13 +312,13 @@ void acelp_core_switch_enc_ivas_fx(
static void encod_gen_voic_core_switch_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 inp[], /* i : input signal */
- const Word16 Aq[], /* i : LP coefficients */
- const Word16 A[], /* i : unquantized A(z) filter */
- const Word16 T_op[], /* i : open loop pitch */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- const Word32 core_bitrate, /* i : switching frame bitrate */
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 inp[], /* i : input signal Q0*/
+ const Word16 Aq[], /* i : LP coefficients Q12*/
+ const Word16 A[], /* i : unquantized A(z) filter Q12*/
+ const Word16 T_op[], /* i : open loop pitch Q0*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/
+ const Word32 core_bitrate, /* i : switching frame bitrate Q0*/
Word16 shift,
Word16 Q_new )
{
@@ -396,7 +396,7 @@ static void encod_gen_voic_core_switch_fx(
hTdCngEnc->burst_ho_cnt = 0;
move16();
- st_fx->L_frame = tmp16;
+ st_fx->L_frame = tmp16; /* Q0 */
move16();
/*------------------------------------------------------------------*
@@ -404,7 +404,7 @@ static void encod_gen_voic_core_switch_fx(
*------------------------------------------------------------------*/
- Copy( res, exc, L_SUBFR );
+ Copy( res, exc, L_SUBFR ); /* Q1 */
IF( EQ_16( L_frame, L_FRAME16k ) )
{
@@ -422,7 +422,7 @@ static void encod_gen_voic_core_switch_fx(
Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
/* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn, L_SUBFR, shift );
+ Scale_sig( xn, L_SUBFR, shift ); /* Q_new */
/*----------------------------------------------------------------*
* Close-loop pitch search and quantization
@@ -430,7 +430,7 @@ static void encod_gen_voic_core_switch_fx(
*----------------------------------------------------------------*/
set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */
pitch = pit_encode_fx( hBstr,
- st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ );
+ st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ ); /* Q6 */
/*-----------------------------------------------------------------*
* Find adaptive exitation
@@ -443,13 +443,13 @@ static void encod_gen_voic_core_switch_fx(
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
+ clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */
/*-----------------------------------------------------------------*
* LP filtering of the adaptive excitation, codebook target computation
*-----------------------------------------------------------------*/
- lp_flag = st_fx->acelp_cfg.ltf_mode;
- lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag );
+ lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */
+ lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
@@ -480,7 +480,7 @@ static void encod_gen_voic_core_switch_fx(
gp_clip_test_gain_pit_fx( st_fx->element_mode, core_bitrate, gain_pit, st_fx->clip_var_fx );
Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx( Lgcode );
+ gcode16 = round_fx( Lgcode ); /* Q0 */
hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift );
@@ -491,12 +491,12 @@ static void encod_gen_voic_core_switch_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
/* code in Q9, gain_pit in Q14 */
- L_tmp = L_mult( gcode16, code[i] );
+ L_tmp = L_mult( gcode16, code[i] ); /* Q10 */
#ifdef BASOP_NOGLOB
- L_tmp = L_shl_sat( L_tmp, 5 );
+ L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 */
L_tmp = L_mac_sat( L_tmp, exc[i], gain_pit );
- L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
- exc[i] = round_fx_sat( L_tmp );
+ L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
+ exc[i] = round_fx_sat( L_tmp ); /* Q_exc */
#else
L_tmp = L_shl( L_tmp, 5 );
L_tmp = L_mac( L_tmp, exc[i], gain_pit );
@@ -520,7 +520,7 @@ static void encod_gen_voic_core_switch_fx(
FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ )
{
#ifdef BASOP_NOGLOB
- exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) );
+ exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) ); /* Q_exc */
#else
exc[i] = round_fx( L_shl( L_mult( exc[i], gain_pit ), 1 ) );
#endif
@@ -531,13 +531,13 @@ static void encod_gen_voic_core_switch_fx(
static void encod_gen_voic_core_switch_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 inp[], /* i : input signal */
- const Word16 Aq[], /* i : LP coefficients */
- const Word16 A[], /* i : unquantized A(z) filter */
- const Word16 T_op[], /* i : open loop pitch */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- const Word32 core_bitrate, /* i : switching frame bitrate */
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 inp[], /* i : input signal Q0*/
+ const Word16 Aq[], /* i : LP coefficients Q12*/
+ const Word16 A[], /* i : unquantized A(z) filter Q12*/
+ const Word16 T_op[], /* i : open loop pitch Q0*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/
+ const Word32 core_bitrate, /* i : switching frame bitrate Q0*/
Word16 shift,
Word16 Q_new )
{
@@ -607,14 +607,14 @@ static void encod_gen_voic_core_switch_ivas_fx(
* Calculation of LP residual (filtering through A[z] filter)
*------------------------------------------------------------------*/
- tmp16 = st_fx->L_frame;
+ tmp16 = st_fx->L_frame; /* Q0 */
move16();
st_fx->L_frame = L_SUBFR;
move16();
calc_residu_fx( st_fx, inp, res, Aq );
// hTdCngEnc->burst_ho_cnt = 0;
- st_fx->L_frame = tmp16;
+ st_fx->L_frame = tmp16; /* Q0 */
move16();
/*------------------------------------------------------------------*
@@ -622,7 +622,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
*------------------------------------------------------------------*/
- Copy( res, exc, L_SUBFR );
+ Copy( res, exc, L_SUBFR ); /* Q_exc */
IF( EQ_16( L_frame, L_FRAME16k ) )
{
@@ -640,7 +640,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
/* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn, L_SUBFR, shift );
+ Scale_sig( xn, L_SUBFR, shift ); /* Q_new */
/*----------------------------------------------------------------*
* Close-loop pitch search and quantization
@@ -648,7 +648,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
*----------------------------------------------------------------*/
set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */
pitch = pit_encode_ivas_fx( hBstr,
- st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ );
+ st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ ); /* Q6 */
/*-----------------------------------------------------------------*
* Find adaptive exitation
@@ -661,13 +661,13 @@ static void encod_gen_voic_core_switch_ivas_fx(
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
+ clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */
/*-----------------------------------------------------------------*
* LP filtering of the adaptive excitation, codebook target computation
*-----------------------------------------------------------------*/
- lp_flag = st_fx->acelp_cfg.ltf_mode;
- lp_select = lp_filt_exc_enc_ivas_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag );
+ lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */
+ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
@@ -698,11 +698,11 @@ static void encod_gen_voic_core_switch_ivas_fx(
gp_clip_test_gain_pit_fx( st_fx->element_mode, core_bitrate, gain_pit, st_fx->clip_var_fx );
Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx( Lgcode );
+ gcode16 = round_fx( Lgcode ); /* Q0 */
// hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift );
// Q_new or shift ?? ->Qexc
- hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 );
+ hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); /* Q15 */
move16();
/*-----------------------------------------------------------------*
* Construct adaptive part of the excitation
@@ -711,12 +711,12 @@ static void encod_gen_voic_core_switch_ivas_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
/* code in Q9, gain_pit in Q14 */
- L_tmp = L_mult( gcode16, code[i] );
+ L_tmp = L_mult( gcode16, code[i] ); /* Q10 */
#ifdef BASOP_NOGLOB
- L_tmp = L_shl_sat( L_tmp, 5 );
+ L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 */
L_tmp = L_mac_sat( L_tmp, exc[i], gain_pit );
- L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
- exc[i] = round_fx_sat( L_tmp );
+ L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
+ exc[i] = round_fx_sat( L_tmp ); /* Q_exc */
#else
L_tmp = L_shl( L_tmp, 5 );
L_tmp = L_mac( L_tmp, exc[i], gain_pit );
@@ -741,7 +741,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ )
{
#ifdef BASOP_NOGLOB
- exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) );
+ exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) ); /* Q_exc */
#else
exc[i] = round_fx( L_shl( L_mult( exc[i], gain_pit ), 1 ) );
#endif
@@ -780,45 +780,47 @@ static void bwe_switch_enc_fx(
BSTR_ENC_HANDLE hBstr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
hBstr = st_fx->hBstr;
L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS );
/* set multiplication factor according to the sampling rate */
- tmp = extract_l( L_shr( st_fx->input_Fs, 14 ) );
- delta_fx = add( tmp, 1 );
+ tmp = extract_l( L_shr( st_fx->input_Fs, 14 ) ); /* Q0 */
+ delta_fx = add( tmp, 1 ); /* Q0 */
Fs_kHz = shl( delta_fx, 4 );
tmp = add( tmp, i_mult2( 3, ( sub( st_fx->last_L_frame, L_FRAME ) != 0 ) ) );
- ptmp = fpointers_tab[tmp];
+ ptmp = fpointers_tab[tmp]; /* Q15 */
move16();
- hp_filter_fx = ptmp;
- fdelay_fx = i_mult2( 16, delta_fx );
+ hp_filter_fx = ptmp; /* Q15 */
+ fdelay_fx = i_mult2( 16, delta_fx ); /* Q0 */
IF( EQ_16( st_fx->last_L_frame, L_FRAME ) )
{
- fdelay_fx = i_mult2( 20, delta_fx );
+ fdelay_fx = i_mult2( 20, delta_fx ); /* Q0 */
}
- n = i_mult2( N16_CORE_SW, delta_fx );
+ n = i_mult2( N16_CORE_SW, delta_fx ); /* Q0 */
set16_fx( tmp_mem_fx, 0, 2 * L_FILT48k );
set16_fx( tmp_mem2_fx, 0, 2 * L_FILT48k );
- Loverlapp_fx = i_mult2( delta_fx, SWITCH_OVERLAP_8k * 2 );
- gapsize_fx = i_mult2( delta_fx, NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) );
+ Loverlapp_fx = i_mult2( delta_fx, SWITCH_OVERLAP_8k * 2 ); /* Q0 */
+ gapsize_fx = i_mult2( delta_fx, NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) ); /* Q0 */
shift = sub( add( add( shr( L, 1 ), n ), Loverlapp_fx ), gapsize_fx );
- Copy( new_speech_fx + shift, synth_subfr_bwe_fx, add( gapsize_fx, fdelay_fx ) );
- Copy( new_speech_fx + sub( shift, fdelay_fx ), tmp_mem_fx, fdelay_fx );
+ Copy( new_speech_fx + shift, synth_subfr_bwe_fx, add( gapsize_fx, fdelay_fx ) ); /* Q0 */
+ Copy( new_speech_fx + sub( shift, fdelay_fx ), tmp_mem_fx, fdelay_fx ); /* Q0 */
- tmp = add( gapsize_fx, fdelay_fx );
- fir_fx( synth_subfr_bwe_fx, hp_filter_fx, synth_subfr_bwe_fx, tmp_mem_fx, tmp, fdelay_fx, 1, 0 );
- Copy( synth_subfr_bwe_fx + shr( fdelay_fx, 1 ), synth_subfr_bwe_fx, sub( gapsize_fx, shr( fdelay_fx, 1 ) ) );
+ tmp = add( gapsize_fx, fdelay_fx ); /* Q0 */
+ fir_fx( synth_subfr_bwe_fx, hp_filter_fx, synth_subfr_bwe_fx, tmp_mem_fx, tmp, fdelay_fx, 1, 0 ); /* Q0 */
+ Copy( synth_subfr_bwe_fx + shr( fdelay_fx, 1 ), synth_subfr_bwe_fx, sub( gapsize_fx, shr( fdelay_fx, 1 ) ) ); /* Q0 */
- tmp = i_mult2( Fs_kHz, 10 );
+ tmp = i_mult2( Fs_kHz, 10 ); /* Q0 */
fir_fx( new_speech_fx, hp_filter_fx, hb_synth_tmp_fx, tmp_mem2_fx, tmp, fdelay_fx, 1, 0 );
- min_sq_cross_fx = L_negate( 1 );
+ min_sq_cross_fx = -1;
+ move32();
Qsq = 0;
move16();
min_corr_fx = 0;
@@ -828,15 +830,15 @@ static void bwe_switch_enc_fx(
d1m_fx = 0;
move16();
- maxd1_fx = sub( tmp, add( gapsize_fx, fdelay_fx ) );
+ maxd1_fx = sub( tmp, add( gapsize_fx, fdelay_fx ) ); /* Q0 */
IF( EQ_16( delta_fx, 2 ) )
{
- maxd1_fx = shr( maxd1_fx, 1 );
+ maxd1_fx = shr( maxd1_fx, 1 ); /* Q0 */
}
ELSE IF( EQ_16( delta_fx, 3 ) )
{
- maxd1_fx = extract_h( L_mult( maxd1_fx, 10923 ) );
+ maxd1_fx = extract_h( L_mult( maxd1_fx, 10923 /* 0.333 in Q15 */ ) ); /* Q0 */
}
/* find delay */
@@ -870,21 +872,23 @@ static void bwe_switch_enc_fx(
push_indice_fx( hBstr, IND_CORE_SWITCHING_AUDIO_DELAY, d1m_fx, AUDIODELAYBITS );
- tmp = add( i_mult2( d1m_fx, delta_fx ), fdelay_fx );
- ptmp = &hb_synth_tmp_fx[tmp];
+ tmp = add( i_mult2( d1m_fx, delta_fx ), fdelay_fx ); /* Q0 */
+ ptmp = &hb_synth_tmp_fx[tmp]; /* Q0 */
move16();
E1_fx = dotprod_satcont( synth_subfr_bwe_fx, synth_subfr_bwe_fx, 0, 0, &q_tmp1, gapsize_fx, 1 );
E2_fx = dotprod_satcont( ptmp, ptmp, 0, 0, &q_tmp2, gapsize_fx, 1 );
IF( !E1_fx )
{
- E1_fx = shl( 1, 14 );
+ E1_fx = 1 << 14;
+ move16();
q_tmp1 = 14;
move16();
}
IF( !E2_fx )
{
- E2_fx = shl( 1, 14 );
+ E2_fx = 1 << 14;
+ move16();
q_tmp2 = 14;
move16();
}
@@ -898,7 +902,7 @@ static void bwe_switch_enc_fx(
#else
gain_fx = round_fx( Isqrt( L_tmp1 ) ); /*Q12 */
#endif
- ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) );
+ ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) ); /* Q0 */
push_indice_fx( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 );
return;
@@ -1052,7 +1056,15 @@ static void bwe_switch_enc_ivas_fx(
}
-static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len, Word16 delta )
+static Word16 dotprod_satcont(
+ const Word16 *x, /* qx */
+ const Word16 *y, /* qy */
+ Word16 qx,
+ Word16 qy,
+ Word16 *qo,
+ Word16 len, /* Q0 */
+ Word16 delta /* Q0 */
+)
{
Word16 tmp_tabx[L_FRAME48k], tmp_taby[L_FRAME48k];
Word16 shift, q, ener, i;
@@ -1061,8 +1073,8 @@ static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word
Flag Overflow = 0;
#endif
- Copy( x, tmp_tabx, len );
- Copy( y, tmp_taby, len );
+ Copy( x, tmp_tabx, len ); /* qx */
+ Copy( y, tmp_taby, len ); /* qy */
shift = 0;
move16();
DO
@@ -1083,9 +1095,9 @@ static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word
{
FOR( i = 0; i < len; i += delta )
{
- tmp_tabx[i] = shr( tmp_tabx[i], 2 );
+ tmp_tabx[i] = shr( tmp_tabx[i], 2 ); /* qx - 2 */
move16();
- tmp_taby[i] = shr( tmp_taby[i], 2 );
+ tmp_taby[i] = shr( tmp_taby[i], 2 ); /* qx - 2 */
move16();
}
shift = add( shift, 4 );
diff --git a/lib_enc/acelp_enc_util.c b/lib_enc/acelp_enc_util.c
deleted file mode 100644
index eb574bd70a8cd1b2a23801d28b3bc6442f2644ac..0000000000000000000000000000000000000000
--- a/lib_enc/acelp_enc_util.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------*
- * E_ACELP_toeplitz_mul()
- *
- * Multiplication of Toeplitz matrix with vector c, such that d = toeplitz(R)*c
- *-------------------------------------------------------------------*/
diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c
index 8fb74129723e6127d02c26efde383be94b41d343..9992ce6ad1a3b10d6524f2e4219b29da9238b935 100644
--- a/lib_enc/acelp_enc_util_fx.c
+++ b/lib_enc/acelp_enc_util_fx.c
@@ -34,11 +34,12 @@
* Vector length is L_SUBFR
*/
Word16 E_ACELP_toeplitz_mul_fx(
- const Word16 R[],
- const Word16 c[],
- Word16 d[],
- const Word16 L_subfr,
- const Word16 highrate )
+ const Word16 R[], /* Q9 */
+ const Word16 c[], /* Qx */
+ Word16 d[], /* exp(j) */
+ const Word16 L_subfr, /* Q0 */
+ const Word16 highrate /* Q0 */
+)
{
static const Word16 step = 4;
Word16 k, j, i;
@@ -57,20 +58,20 @@ Word16 E_ACELP_toeplitz_mul_fx(
L_maxloc = L_deposit_l( 0 );
FOR( i = k; i < L_subfr; i += step )
{
- s = L_mult( R[i], c[0] );
+ s = L_mult( R[i], c[0] ); /* Q10 + Qx */
FOR( j = 1; j < i; j++ )
{
- s = L_mac( s, R[i - j], c[j] );
+ s = L_mac( s, R[i - j], c[j] ); /* Q10 + Qx */
}
FOR( ; j < L_subfr; j++ )
{
- s = L_mac( s, R[j - i], c[j] );
+ s = L_mac( s, R[j - i], c[j] ); /* Q10 + Qx */
}
y32[i] = s;
move32();
s = L_abs( s );
- L_maxloc = L_max( s, L_maxloc );
+ L_maxloc = L_max( s, L_maxloc ); /* Q10 + Qx */
}
/* tot += 3*max / 8 */
L_maxloc = L_shr( L_maxloc, 2 );
@@ -113,16 +114,16 @@ Word16 E_ACELP_toeplitz_mul_fx(
/* Limit exponent to avoid overflows elsewhere. */
j = s_min( sub( norm_l( L_tot ), 4 + 16 ), 15 - 16 ); /* 4 -> 16 x tot */
- Copy_Scale_sig_32_16( y32, d, L_subfr, j );
+ Copy_Scale_sig_32_16( y32, d, L_subfr, j ); /* exp(j) */
return j;
}
void E_ACELP_weighted_code(
- const Word16 code[], /* i: code */
- const Word16 H[], /* i: impulse response */
- Word16 Q, /* i: Q format of H */
- Word16 y[] /* o: weighted code */
+ const Word16 code[], /* i: code Q9*/
+ const Word16 H[], /* i: impulse response Q*/
+ Word16 Q, /* i: Q format of H */
+ Word16 y[] /* o: weighted code Q9*/
)
{
Word16 i, j, k, one, n, nz[L_SUBFR];
@@ -150,8 +151,8 @@ void E_ACELP_weighted_code(
set16_fx( y, 0, j );
FOR( k = 0; k < L_SUBFR - j; k++ )
{
- L_tmp = L_mult( code[j], H[k] );
- y[j + k] = extract_h( L_shl( L_tmp, Q ) );
+ L_tmp = L_mult( code[j], H[k] ); /* Q10 + Q */
+ y[j + k] = extract_h( L_shl( L_tmp, Q ) ); /* Q9 */
}
FOR( i = 1; i < n; ++i )
@@ -161,16 +162,16 @@ void E_ACELP_weighted_code(
FOR( k = 0; k < L_SUBFR - j; k++ )
{
L_tmp = L_mult( y[j + k], one );
- L_tmp = L_mac( L_tmp, code[j], H[k] );
- y[j + k] = extract_h( L_shl( L_tmp, Q ) );
+ L_tmp = L_mac( L_tmp, code[j], H[k] ); /* Q10 + Q */
+ y[j + k] = extract_h( L_shl( L_tmp, Q ) ); /* Q9*/
}
}
}
void E_ACELP_conv(
- const Word16 xn2[], /* i */
- const Word16 h2[], /* i */
- Word16 cn2[] /* o */
+ const Word16 xn2[], /* i Qx*/
+ const Word16 h2[], /* i Q12*/
+ Word16 cn2[] /* o Q0*/
)
{
Word16 i, k;
@@ -182,25 +183,25 @@ void E_ACELP_conv(
{
/*cn2[k] = xn2[k]; */
Word64 L_tmp_64;
- L_tmp_64 = W_deposit32_l( L_mult( xn2[k], 0x800 ) );
+ L_tmp_64 = W_deposit32_l( L_mult( xn2[k], 0x800 ) ); /* 4Q11 */
FOR( i = 0; i < k; i++ )
{
/*cn2[k]-=cn2[i]*h2[k-i];*/
L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/
}
- L_tmp = W_sat_l( L_tmp_64 );
+ L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */
#ifdef BASOP_NOGLOB
- cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow );
+ cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0 */
#else
cn2[k] = round_fx( L_shl( L_tmp, 5 ) );
#endif
}
}
-void E_ACELP_conv_ivas(
- const Word16 xn2[], /* i */
- const Word16 h2[], /* i */
- Word16 cn2[] /* o */
+void E_ACELP_conv_ivas_fx(
+ const Word16 xn2[], /* i Qx*/
+ const Word16 h2[], /* i Q12*/
+ Word16 cn2[] /* o Q0*/
)
{
Word16 i, k;
@@ -212,15 +213,15 @@ void E_ACELP_conv_ivas(
{
/*cn2[k] = xn2[k]; */
Word64 L_tmp_64;
- L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) );
+ L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* 4Q11 */
FOR( i = 0; i < k; i++ )
{
/*cn2[k]-=cn2[i]*h2[k-i];*/
L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/
}
- L_tmp = W_sat_l( L_tmp_64 );
+ L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */
#ifdef BASOP_NOGLOB
- cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow );
+ cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0*/
#else
cn2[k] = round_fx( L_shl( L_tmp, 5 ) );
#endif
@@ -228,11 +229,11 @@ void E_ACELP_conv_ivas(
}
}
void E_ACELP_build_code(
- Word16 nb_pulse, /* i */
- const Word16 codvec[], /* i */
- const Word16 sign[], /* i */
- Word16 code[], /* o */
- Word16 ind[] /* o */
+ Word16 nb_pulse, /* i Q0*/
+ const Word16 codvec[], /* i Q0*/
+ const Word16 sign[], /* i Q0*/
+ Word16 code[], /* o Q9*/
+ Word16 ind[] /* o Q0*/
)
{
Word16 i, k, val, index, track, tmp, vec[4];
@@ -252,42 +253,42 @@ void E_ACELP_build_code(
FOR( k = 0; k < nb_pulse; ++k )
{
- i = codvec[k]; /* read pulse position */
+ i = codvec[k]; /* read pulse position Q0*/
move16();
- val = sign[i]; /* read sign */
+ val = sign[i]; /* read sign Q0*/
move16();
index = shr( i, 2 ); /* pos of pulse (0..15) */
track = s_and( i, 4 - 1 ); /* i % 4; */
- tmp = add( code[i], _1_Q9 );
+ tmp = add( code[i], _1_Q9 ); /* Q9 */
if ( val <= 0 )
{
- tmp = sub( code[i], _1_Q9 );
+ tmp = sub( code[i], _1_Q9 ); /* Q9 */
}
- code[i] = tmp;
+ code[i] = tmp; /* Q9 */
move16();
if ( val <= 0 )
{
- index = add( index, 16 );
+ index = add( index, 16 ); /* Q0 */
}
/* Calculate Current Store Index (we started at -1) so we increment first */
- i = add( vec[track], 1 );
+ i = add( vec[track], 1 ); /* Q0 */
/* Save Next Store Index */
- vec[track] = i;
+ vec[track] = i; /* Q0 */
move16();
- ind[i] = index;
+ ind[i] = index; /* Q0 */
move16();
}
}
void E_ACELP_setup_pulse_search_pos(
- const PulseConfig *config, /* i: pulse configuration */
- Word16 k, /* i: interation number */
- UWord8 ipos[] /* o: pulse search positions */
+ const PulseConfig *config, /* i: pulse configuration */
+ Word16 k, /* i: interation number Q0*/
+ UWord8 ipos[] /* o: pulse search positions Q0*/
)
{
Word16 restpulses, iPulse;
@@ -308,30 +309,30 @@ void E_ACELP_setup_pulse_search_pos(
/* add tracks from left */
FOR( iPulse = 0; iPulse < restpulses; iPulse++ )
{
- ipos[config->nb_pulse - restpulses + iPulse] = (UWord8) iPulse;
+ ipos[config->nb_pulse - restpulses + iPulse] = (UWord8) iPulse; /* Q0 */
move16();
}
/* Put the same track on the next position, because the 1-pulse search
* will access it to determine if this could be in any track. */
- ipos[config->nb_pulse] = ipos[config->nb_pulse - 1];
+ ipos[config->nb_pulse] = ipos[config->nb_pulse - 1]; /* Q0 */
move16();
BREAK;
case TRACKPOS_FIXED_EVEN: /* fixed track positions, odd tracks */
/* odd tracks, switch order for every iteration */
- ipos[config->nb_pulse - restpulses] = (UWord8) s_and( lshl( k, 1 ), 2 );
- move16(); /* 0 for even k, 2 for odd */
- ipos[config->nb_pulse - restpulses + 1] = (UWord8) s_xor( ipos[config->nb_pulse - restpulses], 2 );
- move16(); /* 2 for even k, 0 for odd */
+ ipos[config->nb_pulse - restpulses] = (UWord8) s_and( lshl( k, 1 ), 2 ); /* Q0 */
+ move16(); /* 0 for even k, 2 for odd */
+ ipos[config->nb_pulse - restpulses + 1] = (UWord8) s_xor( ipos[config->nb_pulse - restpulses], 2 ); /* Q0 */
+ move16(); /* 2 for even k, 0 for odd */
BREAK;
case TRACKPOS_FIXED_TWO: /* two tracks instead of four */
/* Put the next track on the next position, because the 1-pulse search
* will access it to determine if this could be in any track. */
- ipos[config->nb_pulse] = (UWord8) s_and( add( ipos[config->nb_pulse - 1], 1 ), 3 );
+ ipos[config->nb_pulse] = (UWord8) s_and( add( ipos[config->nb_pulse - 1], 1 ), 3 ); /* Q0 */
move16();
BREAK;
default: /* one or three free track positions */
/* copy an extra position from table - 1pulse search will access this */
- ipos[config->nb_pulse] = E_ROM_tipos[add( shl( k, 2 ), config->nb_pulse )];
+ ipos[config->nb_pulse] = E_ROM_tipos[add( shl( k, 2 ), config->nb_pulse )]; /* Q0 */
move16();
BREAK;
}
diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c
deleted file mode 100644
index 6056f600b461d55e0226c5ee5c53648597aabd79..0000000000000000000000000000000000000000
--- a/lib_enc/amr_wb_enc.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_enc.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-#include "prot_fx.h"
diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c
index 7b177d99a067b14fa75e57f906fe7c541ac4cb7f..69c356b5ddb3e9055f0384bf43cdc91174a83ae6 100644
--- a/lib_enc/amr_wb_enc_fx.c
+++ b/lib_enc/amr_wb_enc_fx.c
@@ -25,8 +25,8 @@
void amr_wb_enc_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 input_sp[], /* i : input signal */
- const Word16 n_samples /* i : number of input samples */
+ const Word16 input_sp[], /* i : input signal Q0*/
+ const Word16 n_samples /* i : number of input samples Q0*/
)
{
Word16 i, delay;
@@ -95,25 +95,28 @@ void amr_wb_enc_fx(
* Initialization
*------------------------------------------------------------------*/
- st->L_frame = L_FRAME;
+ st->L_frame = L_FRAME; /* Q0 */
move16();
- st->gamma = GAMMA1;
+ st->gamma = GAMMA1; /* Q15 */
move16();
- st->core = AMR_WB_CORE;
+ st->core = AMR_WB_CORE; /* Q0 */
move16();
- st->core_brate = st->total_brate;
+ st->core_brate = st->total_brate; /* Q0 */
move16();
- st->input_bwidth = st->last_input_bwidth;
+ st->input_bwidth = st->last_input_bwidth; /* Q0 */
move16();
- st->bwidth = st->last_bwidth;
+ st->bwidth = st->last_bwidth; /* Q0 */
move16();
st->coder_type = GENERIC;
move16();
input_frame = st->input_frame_fx;
move16(); /* frame length of the input signal */
st->extl = -1;
+ move16();
st->encoderPastSamples_enc = ( L_FRAME * 9 ) / 16;
+ move16();
st->encoderLookahead_enc = L_LOOK_12k8;
+ move16();
st->bpf_off = 0;
move16();
test();
@@ -140,18 +143,18 @@ void amr_wb_enc_fx(
set16_fx( old_inp, 0, L_INP_12k8 );
exc = old_exc + L_EXC_MEM; /* pointer to excitation signal in the current frame */
- Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM );
+ Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /* q_lpd_old_exc */
new_inp = old_inp + L_INP_MEM; /* pointer to new samples of the input signal */
inp = new_inp - L_LOOK_12k8; /* pointer to current frame of input signal */
wsp = old_wsp + L_WSP_MEM; /* pointer to current frame of weighted signal */
- Copy( st->old_inp_12k8_fx, old_inp, L_INP_MEM );
- Copy( st->old_wsp_fx, old_wsp, L_WSP_MEM );
+ Copy( st->old_inp_12k8_fx, old_inp, L_INP_MEM ); /* exp_old_inp_12k8 */
+ Copy( st->old_wsp_fx, old_wsp, L_WSP_MEM ); /* exp(exp_old_wsp) */
- new_inp_16k = old_inp_16k + L_INP_MEM; /* pointer to new samples of the input signal in 16kHz core */
- inp_16k = new_inp_16k - L_LOOK_16k; /* pointer to the current frame of input signal in 16kHz core */
- Copy( st->old_inp_16k_fx, old_inp_16k, L_INP_MEM );
+ new_inp_16k = old_inp_16k + L_INP_MEM; /* pointer to new samples of the input signal in 16kHz core */
+ inp_16k = new_inp_16k - L_LOOK_16k; /* pointer to the current frame of input signal in 16kHz core */
+ Copy( st->old_inp_16k_fx, old_inp_16k, L_INP_MEM ); /* q_old_inp */
/* in case of switching, reset AMR-WB BWE memories */
test();
@@ -167,14 +170,14 @@ void amr_wb_enc_fx(
/* get delay to synchronize ACELP and MDCT frame */
delay = NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS );
- Copy( st->input_fx - delay, st->old_input_signal_fx, input_frame + delay );
+ Copy( st->input_fx - delay, st->old_input_signal_fx, input_frame + delay ); /* q_inp */
/*----------------------------------------------------------------*
* Buffering of input signal
* HP filtering
*----------------------------------------------------------------*/
- Copy( input_sp, st->input_fx, n_samples );
+ Copy( input_sp, st->input_fx, n_samples ); /* Q0 */
FOR( i = n_samples; i < input_frame; i++ )
{
st->input_fx[i] = 0;
@@ -195,25 +198,25 @@ void amr_wb_enc_fx(
/* in case of switching, do not apply BPF */
st->bpf_off = 1;
move16();
- st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, L_FRAME, 1 );
+ st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, L_FRAME, 1 ); /* Q0 */
/* convert old quantized LSF vector */
lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, INT_FS_FX );
/* Reset LPC mem */
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
+ Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /* x2.56 */
set16_fx( st->mem_MA_fx, 0, M );
/* update synthesis filter memories */
synth_mem_updt2( L_FRAME, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn1_fx, hLPDmem->mem_syn, ENC );
- Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M );
+ Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M ); /* q_mem_syn */
- Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M );
+ Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /* q_lpd_old_exc */
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M ); /* q_mem_syn */
/* lsp -> isp */
Copy( stable_ISP_fx, isp_tmp, M );
- lsp2isp_fx( st->lsp_old_fx, st->lsp_old_fx, isp_tmp, M );
+ lsp2isp_fx( st->lsp_old_fx, st->lsp_old_fx, isp_tmp, M ); /* Q15 */
}
/* update buffer of old subframe pitch values */
@@ -223,17 +226,17 @@ void amr_wb_enc_fx(
IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
{
/* (float)12800/(float)32000; */
- tmp = 13107;
+ tmp = 13107; /* 0.4 in Q15 */
}
ELSE IF( EQ_16( st->last_L_frame, 512 ) )
{
/* (float)12800/(float)25600; */
- tmp = 16384;
+ tmp = 16384; /* 0.5 in Q15 */
}
ELSE /* st->last_L_frame == L_FRAME16k */
{
/* (float)12800/(float)16000; */
- tmp = 26214;
+ tmp = 26214; /* 0.8 in Q15 */
}
FOR( i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++ )
@@ -252,7 +255,7 @@ void amr_wb_enc_fx(
test();
if ( EQ_16( st->last_bwidth, NB ) && st->ini_frame != 0 )
{
- st->rate_switching_reset = 1;
+ st->rate_switching_reset = 1; /* Q0 */
move16();
}
@@ -263,8 +266,8 @@ void amr_wb_enc_fx(
modify_Fs_fx( st->input_fx, input_frame, st->input_Fs, new_inp, 12800, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size );
/* update signal buffer */
- Copy( new_inp, st->buf_speech_enc + L_FRAME, L_FRAME );
- Scale_sig( st->buf_speech_enc + L_FRAME, L_FRAME, 1 );
+ Copy( new_inp, st->buf_speech_enc + L_FRAME, L_FRAME ); /* Q0 */
+ Scale_sig( st->buf_speech_enc + L_FRAME, L_FRAME, 1 ); /* Q1 */
/*------------------------------------------------------------------*
* Perform fixed preemphasis through 1 - g*z^-1
@@ -273,7 +276,6 @@ void amr_wb_enc_fx(
Preemph_scaled( new_inp, &Q_new, &st->mem_preemph_fx, st->Q_max, PREEMPH_FAC, 0, 1, L_Q_MEM, L_FRAME, st->last_coder_type, 1 );
Q_exp = sub( Q_new, st->Q_old );
- move16();
st->Q_old = Q_new;
move16();
@@ -281,7 +283,6 @@ void amr_wb_enc_fx(
hNoiseEst->ave_enr2_fx, hNoiseEst->fr_bands1_fx, hNoiseEst->fr_bands2_fx, st->Bin_E_old_fx );
Q_exp = sub( Q_new, st->prev_Q_new );
- move16();
Scale_mem_enc( Q_exp, old_inp_16k, old_exc, hBWE_TD->old_bwe_exc_fx, &( hLPDmem->mem_w0 ), hLPDmem->mem_syn, hLPDmem->mem_syn2,
&st->mem_deemp_preQ_fx, hGSCEnc->last_exc_dct_in_fx, hBWE_FD->old_input_lp_fx );
@@ -305,7 +306,8 @@ void amr_wb_enc_fx(
*----------------------------------------------------------------*/
st->vad_flag = wb_vad_fx( st, fr_bands, &noisy_speech_HO, &clean_speech_HO, &NB_speech_HO,
- &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), Q_new, hVAD, hNoiseEst, st->lp_speech_fx, st->lp_noise_fx );
+ &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), Q_new, hVAD, hNoiseEst, st->lp_speech_fx, st->lp_noise_fx ); /* Q0 */
+ move16();
if ( st->vad_flag == 0 )
{
@@ -322,12 +324,13 @@ void amr_wb_enc_fx(
IF( NE_16( st->last_core, AMR_WB_CORE ) )
{
- st->fd_cng_reset_flag = 1;
+ st->fd_cng_reset_flag = 1; /* Q0 */
move16();
}
ELSE IF( s_and( ( st->fd_cng_reset_flag > 0 ), (Word16) ( LT_16( st->fd_cng_reset_flag, 10 ) ) ) )
{
- st->fd_cng_reset_flag = add( st->fd_cng_reset_flag, 1 );
+ st->fd_cng_reset_flag = add( st->fd_cng_reset_flag, 1 ); /* Q0 */
+ move16();
}
ELSE
{
@@ -358,14 +361,14 @@ void amr_wb_enc_fx(
IF( NE_16( st->bwidth, NB ) )
{
- lp_bckr = Mean32( hNoiseEst->bckr_fx, 10 );
+ lp_bckr = Mean32( hNoiseEst->bckr_fx, 10 ); /* q_bckr */
}
ELSE
{
- lp_bckr = Mean32( hNoiseEst->bckr_fx + 1, 9 );
+ lp_bckr = Mean32( hNoiseEst->bckr_fx + 1, 9 ); /* q_bckr */
}
#ifdef BASOP_NOGLOB
- hp_bckr = L_shr( L_add_sat( hNoiseEst->bckr_fx[st->max_band - 1], hNoiseEst->bckr_fx[st->max_band] ), 1 );
+ hp_bckr = L_shr( L_add_sat( hNoiseEst->bckr_fx[st->max_band - 1], hNoiseEst->bckr_fx[st->max_band] ), 1 ); /* q_bckr */
#else
hp_bckr = L_shr( L_add( hNoiseEst->bckr_fx[st->max_band - 1], hNoiseEst->bckr_fx[st->max_band] ), 1 );
#endif
@@ -373,11 +376,11 @@ void amr_wb_enc_fx(
{
hp_bckr = L_deposit_l( 1 );
}
- tmp = BASOP_Util_Divide3232_Scale( lp_bckr, hp_bckr, &e_tmp );
+ tmp = BASOP_Util_Divide3232_Scale( lp_bckr, hp_bckr, &e_tmp ); /* exp(e_tmp) */
Ltmp = L_shr_r( L_deposit_h( tmp ), sub( 15, e_tmp ) );
- st->bckr_tilt_lt = L_add( Mpy_32_16_r( st->bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) );
+ st->bckr_tilt_lt = L_add( Mpy_32_16_r( st->bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) ); /* Q16 */
- corr_shift = correlation_shift_fx( hNoiseEst->totalNoise_fx );
+ corr_shift = correlation_shift_fx( hNoiseEst->totalNoise_fx ); /* Q15 */
/*----------------------------------------------------------------*
* WB, SWB and FB bandwidth detector
@@ -404,7 +407,7 @@ void amr_wb_enc_fx(
/* reset the OL pitch tracker memories during inactive frames */
pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx );
}
- old_pitch1 = st->pitch[1];
+ old_pitch1 = st->pitch[1]; /* Q0 */
move16();
analy_lp_AMR_WB_fx( inp, &ener, A, epsP_h, epsP_l, isp_new, st->lsp_old1_fx,
isf_new, st->old_pitch_la, st->old_voicing_la, Q_new, Q_r );
@@ -427,9 +430,9 @@ void amr_wb_enc_fx(
move16();
}
pitch_ol_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp, st->mem_decim2_fx, relE, 0, st->bwidth, st->Opt_SC_VBR );
- st->old_pitch_la = st->pitch[2];
+ st->old_pitch_la = st->pitch[2]; /* Q0 */
move16();
- st->old_voicing_la = st->voicing_fx[2];
+ st->old_voicing_la = st->voicing_fx[2]; /* Q15 */
move16();
/* VAD parameters update */
@@ -495,16 +498,16 @@ void amr_wb_enc_fx(
CNG_reset_enc_fx( st, hLPDmem, pitch_buf, dummy_buf + L_FRAME, 0 );
/* update st->mem_syn1 for ACELP core switching */
- Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn1_fx, M );
+ Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn1_fx, M ); /* q_mem_syn */
/* update ACELP core synthesis filter memory */
- Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M );
+ Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M ); /* q_mem_syn */
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( dummy_buf + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM );
+ Copy( dummy_buf + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); /* st->Q_syn */
/* Update MODE2 core switching memory */
E_UTIL_deemph2( sub( Q_new, 1 ), dummy_buf, PREEMPH_FAC, L_FRAME, &( hLPDmem->syn[M] ) );
- Copy( dummy_buf + L_FRAME - M - 1, hLPDmem->syn, M + 1 );
+ Copy( dummy_buf + L_FRAME - M - 1, hLPDmem->syn, M + 1 ); /* st->Q_syn */
}
/*----------------------------------------------------------------*
@@ -519,7 +522,7 @@ void amr_wb_enc_fx(
test();
IF( EQ_32( st->last_core_brate, FRAME_NO_DATA ) || EQ_32( st->last_core_brate, SID_1k75 ) )
{
- Copy( hDtxEnc->lspCNG_fx, st->lsp_old_fx, M );
+ Copy( hDtxEnc->lspCNG_fx, st->lsp_old_fx, M ); /* Q15 */
E_LPC_isp_isf_conversion( hDtxEnc->lspCNG_fx, st->lsf_old_fx, M );
set16_fx( old_exc, 0, L_EXC_MEM );
}
@@ -549,14 +552,14 @@ void amr_wb_enc_fx(
encod_amr_wb_fx( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, hf_gain_fx, inp_16k, shift, Q_new );
/* update st->mem_syn1 for ACELP core switching */
- Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M );
+ Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M ); /* st->q_mem_syn */
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM );
+ Copy( syn + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); /* st->Q_syn */
/* Update MODE2 core switching memory */
E_UTIL_deemph2( sub( Q_new, 1 ), syn, PREEMPH_FAC, L_FRAME, &( hLPDmem->syn[M] ) );
- Copy( syn + L_FRAME - M - 1, hLPDmem->syn, M + 1 );
+ Copy( syn + L_FRAME - M - 1, hLPDmem->syn, M + 1 ); /* st->Q_syn */
/*--------------------------------------------------------------------------------------*
* Write VAD information into the bitstream in AMR-WB IO mode
@@ -570,27 +573,27 @@ void amr_wb_enc_fx(
*-----------------------------------------------------------------*/
/* update old weighted speech buffer - for OL pitch analysis */
- Copy( &old_wsp[L_FRAME], st->old_wsp_fx, L_WSP_MEM );
+ Copy( &old_wsp[L_FRAME], st->old_wsp_fx, L_WSP_MEM ); /* exp(exp_old_wsp) */
/* update old input signal buffer */
- Copy( &old_inp[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM );
+ Copy( &old_inp[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM ); /* exp(exp_old_inp_12k8) */
/* update old input signal @16kHz buffer */
IF( GT_32( st->input_Fs, 8000 ) )
{
- Copy( &old_inp_16k[L_FRAME16k], st->old_inp_16k_fx, L_INP_MEM );
+ Copy( &old_inp_16k[L_FRAME16k], st->old_inp_16k_fx, L_INP_MEM ); /* exp(exp_old_inp_16k) */
}
/* update of old per-band energy spectrum */
- Copy32( fr_bands + NB_BANDS, hNoiseEst->enrO_fx, NB_BANDS );
+ Copy32( fr_bands + NB_BANDS, hNoiseEst->enrO_fx, NB_BANDS ); /* Q_new */
/* update the last bandwidth */
- st->last_input_bwidth = st->input_bwidth;
- st->last_bwidth = st->bwidth;
+ st->last_input_bwidth = st->input_bwidth; /* Q0 */
+ st->last_bwidth = st->bwidth; /* Q0 */
/* update signal buffers */
- Copy( new_inp, st->buf_speech_enc_pe + L_FRAME, L_FRAME );
- Copy( wsp, st->buf_wspeech_enc + L_FRAME + L_SUBFR, L_FRAME + L_LOOK_12k8 );
+ Copy( new_inp, st->buf_speech_enc_pe + L_FRAME, L_FRAME ); /* Q0 */
+ Copy( wsp, st->buf_wspeech_enc + L_FRAME + L_SUBFR, L_FRAME + L_LOOK_12k8 ); /* exp(exp_buf_wspeech_enc) */
updt_enc_fx( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf );
/* update main codec parameters */
@@ -633,7 +636,7 @@ void amr_wb_enc_init_fx(
FOR( i = 0; i < GAIN_PRED_ORDER; i++ )
{
- hAmrwb_IO->past_qua_en_fx[i] = -14336; /* Q10gain quantization memory (used also in AMR-WB IO mode) */
+ hAmrwb_IO->past_qua_en_fx[i] = -14336; /* Q10 gain quantization memory (used also in AMR-WB IO mode) */
move16();
}
diff --git a/lib_enc/analy_lp.c b/lib_enc/analy_lp.c
deleted file mode 100644
index 2e657e155b94f2ee095cf1922c203d19c79fa7dc..0000000000000000000000000000000000000000
--- a/lib_enc/analy_lp.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------*
- * analy_lp()
- *
- * Perform LP analysis
- *
- * - autocorrelations + lag windowing
- * - Levinson-Durbin algorithm to find A(z)
- * - convert A(z) to LSPs
- * - find interpolated LSPs and convert back to A(z) for all subframes
- * - update LSPs for the next frame
- *-------------------------------------------------------------------*/
diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c
index dc0e9c545f5edc38ce7b672e543496fa11f70e67..c2f9d0585d356c513226ee2059d219e835976724 100644
--- a/lib_enc/analy_lp_fx.c
+++ b/lib_enc/analy_lp_fx.c
@@ -63,7 +63,7 @@ void analy_lp_ivas_fx(
move16();
wind = assym_window_16k_fx; /*q15*/
}
- lsp = lsp_mid;
+ lsp = lsp_mid; /* Q15 */
half_frame = shr( L_frame, 1 );
FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
@@ -105,7 +105,7 @@ void analy_lp_ivas_fx(
/* Conversion of A(z) to LSPs */
E_LPC_a_lsp_conversion( A, lsp, lsp_old, M );
- lsp = lsp_new;
+ lsp = lsp_new; /* Q15 */
}
IF( EQ_16( sec_chan_low_rate, 1 ) )
{
@@ -117,28 +117,28 @@ void analy_lp_ivas_fx(
/* LSP interpolation */
int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
}
- Copy( lsp_new, lsp_old, M );
- *ener = L_Comp( epsP_h[M], epsP_l[M] );
+ Copy( lsp_new, lsp_old, M ); /* Q15 */
+ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
move32();
return;
}
void analy_lp_fx(
- const Word16 speech[], /* i : pointer to the speech frame */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 L_look, /* i : look-ahead */
- Word32 *ener, /* o : residual energy from Levinson-Durbin */
- Word16 A[], /* o : A(z) filter coefficients */
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
- Word16 lsp_new[], /* o : current frame LSPs */
- Word16 lsp_mid[], /* o : current mid-frame LSPs */
- Word16 lsp_old[], /* i/o: previous frame unquantized LSPs */
- const Word16 Top[2], /* i : open loop pitch lag */
- const Word16 Tnc[2], /* i : open loop pitch gain */
- const Word32 Core_sr, /* i : Internal core sampling rate */
- const Word16 sec_chan_low_rate, /* i : flag to signal second channel */
+ const Word16 speech[], /* i : pointer to the speech frame Q_new*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 L_look, /* i : look-ahead Q0*/
+ Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A[], /* o : A(z) filter coefficients Q14*/
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 lsp_new[], /* o : current frame LSPs Q15*/
+ Word16 lsp_mid[], /* o : current mid-frame LSPs Q15*/
+ Word16 lsp_old[], /* i/o: previous frame unquantized LSPs Q15*/
+ const Word16 Top[2], /* i : open loop pitch lag Q0*/
+ const Word16 Tnc[2], /* i : open loop pitch gain Q15*/
+ const Word32 Core_sr, /* i : Internal core sampling rate Q0*/
+ const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/
Word16 Q_new,
Word16 *Q_r )
{
@@ -155,15 +155,15 @@ void analy_lp_fx(
{
wind_length = L_LP;
move16();
- wind = Assym_window_W16fx;
+ wind = Assym_window_W16fx; /* Q15 */
}
ELSE /* L_frame == L_FRAME16k */
{
wind_length = L_LP_16k;
move16();
- wind = assym_window_16k_fx;
+ wind = assym_window_16k_fx; /* Q15 */
}
- lsp = lsp_mid;
+ lsp = lsp_mid; /* Q15 */
half_frame = shr( L_frame, 1 );
FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
@@ -190,7 +190,7 @@ void analy_lp_fx(
/* Conversion of A(z) to LSPs */
E_LPC_a_lsp_conversion( A, lsp, lsp_old, M );
- lsp = lsp_new;
+ lsp = lsp_new; /* Q15 */
}
IF( EQ_16( sec_chan_low_rate, 1 ) )
{
@@ -202,8 +202,8 @@ void analy_lp_fx(
/* LSP interpolation */
int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
}
- Copy( lsp_new, lsp_old, M );
- *ener = L_Comp( epsP_h[M], epsP_l[M] );
+ Copy( lsp_new, lsp_old, M ); /* Q15 */
+ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
move32();
return;
@@ -223,16 +223,16 @@ void analy_lp_fx(
*-------------------------------------------------------------------*/
void analy_lp_AMR_WB_fx(
- const Word16 speech[], /* i : pointer to the speech frame */
- Word32 *ener, /* o : residual energy from Levinson-Durbin */
- Word16 A[], /* o : A(z) filter coefficients */
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
- Word16 isp_new[], /* o : current frame ISPs */
- Word16 isp_old[], /* i/o: previous frame unquantized ISPs */
- Word16 isf_new[], /* o : current frame ISPs */
- Word16 Top, /* i : open loop pitch lag */
- Word16 Tnc, /* i : open loop pitch gain */
+ const Word16 speech[], /* i : pointer to the speech frame Q_new*/
+ Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A[], /* o : A(z) filter coefficients Q14*/
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 isp_new[], /* o : current frame ISPs Q15*/
+ Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/
+ Word16 isf_new[], /* o : current frame ISPs Q15*/
+ Word16 Top, /* i : open loop pitch lag Q0*/
+ Word16 Tnc, /* i : open loop pitch gain Qx*/
Word16 Q_new,
Word16 *Q_r )
{
@@ -271,11 +271,11 @@ void analy_lp_AMR_WB_fx(
int_lsp_fx( L_FRAME, isp_old, isp_new, A, M, interpol_isp_amr_wb_fx, 1 );
/**ener = epsP[M];*/
- *ener = L_Comp( epsP_h[M], epsP_l[M] );
+ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
move32();
/* updates */
- Copy( isp_new, isp_old, M );
+ Copy( isp_new, isp_old, M ); /* Q15 */
return;
}
diff --git a/lib_enc/analy_sp.c b/lib_enc/analy_sp.c
deleted file mode 100644
index 0be76e525dda92b012f35a545e02e2cf42a331ce..0000000000000000000000000000000000000000
--- a/lib_enc/analy_sp.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_enc.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include
-#include "ivas_cnst.h"
diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c
index bcf1ae7ac5490b6abb07f7ee95cc9263bc402f9a..594bcfbabaa51d6368676e33ad6a9d94287873ab 100644
--- a/lib_enc/analy_sp_fx.c
+++ b/lib_enc/analy_sp_fx.c
@@ -18,8 +18,7 @@
*-------------------------------------------------------------------*/
static void find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot, const Word16 min_band, const Word16 max_band, const Word16 Q_new2, const Word32 e_min, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies );
-static void ivas_find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot, const Word16 min_band, const Word16 max_band, const Word16 Q_new2, const Word32 e_min, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies );
-static void ivas_find_enr1( Word16 *data, Word16 q_data, Word32 *band, Word32 *ptE, Word32 *LEtot, const Word16 min_band, const Word16 max_band, const Word16 Q_new, const Word32 e_min, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies );
+static void ivas_find_enr( Word16 *data, Word16 q_data, Word32 *band, Word16 *q_band, Word32 *ptE, Word16 *q_ptE, Word64 *LEtot, const Word16 min_band, const Word16 max_band, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies );
#ifdef IVAS_CODE_CPE
static void find_enr_dft( CPE_ENC_HANDLE hCPE, const int32_t input_Fs, float DFT_past_DMX[], float band[], float *ptE, float *Etot, const int16_t min_band, const int16_t max_band, float *Bin_E, float *band_ener );
#endif
@@ -69,44 +68,52 @@ void analy_sp_fx(
* find energy per critical frequency band and total energy in dB
*-----------------------------------------------------------------*/
- pt_bands = fr_bands;
+ pt_bands = fr_bands; /* Q_new + QSCALE */
pt_fft = fft_buff;
LEtot = L_deposit_l( 0 );
IF( NE_16( element_mode, IVAS_CPE_DFT ) )
{
FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
{
- pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2;
+ pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2; /* Q_new - preemph_bits */
if ( i_subfr != 0 )
{
- pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2;
+ pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2; /* Q_new - preemph_bits */
}
/* Clear 1st value of 1st part, copy 1st value of 2nd part */
fft_temp[0] = 0;
move16();
- fft_temp[L_FFT / 2] = pt[L_FFT / 2];
+ fft_temp[L_FFT / 2] = pt[L_FFT / 2]; /* Q_new - preemph_bits */
move16();
- Max_val = s_max( fft_temp[0], fft_temp[L_FFT / 2] );
- Min_val = s_min( fft_temp[0], fft_temp[L_FFT / 2] );
+ Max_val = s_max( fft_temp[0], fft_temp[L_FFT / 2] ); /* Q_new - preemph_bits */
+ Min_val = s_min( fft_temp[0], fft_temp[L_FFT / 2] ); /* Q_new - preemph_bits */
FOR( i = 1; i < L_FFT / 2; i++ )
{
/* 1st windowed part */
- fft_temp[i] = mult_r( pt[i], sqrt_han_window_fx[i] );
+ fft_temp[i] = mult_r( pt[i], sqrt_han_window_fx[i] ); /* Q_new - preemph_bits */
move16();
- if ( fft_temp[i] > 0 )
- Max_val = s_max( Max_val, fft_temp[i] );
- if ( fft_temp[i] < 0 )
- Min_val = s_min( Min_val, fft_temp[i] );
+ IF( fft_temp[i] > 0 )
+ {
+ Max_val = s_max( Max_val, fft_temp[i] ); /* Q_new - preemph_bits */
+ }
+ IF( fft_temp[i] < 0 )
+ {
+ Min_val = s_min( Min_val, fft_temp[i] ); /* Q_new - preemph_bits */
+ }
/* 2nd windowed part */
- fft_temp[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] );
+ fft_temp[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] ); /* Q_new - preemph_bits */
move16();
- if ( fft_temp[L_FFT - i] > 0 )
- Max_val = s_max( Max_val, fft_temp[L_FFT - i] );
- if ( fft_temp[L_FFT - i] < 0 )
- Min_val = s_min( Min_val, fft_temp[L_FFT - i] );
+ IF( fft_temp[L_FFT - i] > 0 )
+ {
+ Max_val = s_max( Max_val, fft_temp[L_FFT - i] ); /* Q_new - preemph_bits */
+ }
+ IF( fft_temp[L_FFT - i] < 0 )
+ {
+ Min_val = s_min( Min_val, fft_temp[L_FFT - i] ); /* Q_new - preemph_bits */
+ }
}
/* Combine -Min_val and Max_val into one */
@@ -115,7 +122,7 @@ void analy_sp_fx(
Scale_fac[i_subfr] = s_min( sub( norm_s( Max_val ), 1 ), 6 );
move16();
Scale_fac2 = shl( Scale_fac[i_subfr], 1 );
- Scale_sig( fft_temp, L_FRAME_12k8, Scale_fac[i_subfr] );
+ Scale_sig( fft_temp, L_FRAME_12k8, Scale_fac[i_subfr] ); /* Q_new - preemph_bits + Scale_fac */
r_fft_fx_lc( FFT_W128, SIZE_256, SIZE2_256, NUM_STAGE_256, fft_temp, pt_fft, 1 );
@@ -153,7 +160,7 @@ void analy_sp_fx(
Ltmp = Mpy_32( exp_etot, frac_etot, LG10, 0 );
/*Q8 Averaged the total energy over both half-frames in log10 */
- *Etot = extract_l( L_shr( Ltmp, 14 - 8 ) );
+ *Etot = extract_l( L_shr( Ltmp, 14 - 8 ) ); /* Q8 */
Bin_E[L_FFT / 2 - 1] = Bin_E[L_FFT / 2 - 2];
move32();
@@ -187,7 +194,7 @@ void analy_sp_fx(
/* -56783L is to substract 0.86643 in Q16 */
/* 28391 is 0.86643 in Q15 */
/* 1774 is (0.86643 in Q15) * 8 / 128 (/128 to go in Q7) */
- EspecdB[i] = mac_r( L_shl( L_msu( L_tmp2, exp, 28391 ), 3 + 7 ), exp_frac, 887 );
+ EspecdB[i] = mac_r( L_shl( L_msu( L_tmp2, exp, 28391 ), 3 + 7 ), exp_frac, 887 ); /* Q7 */
move16();
}
@@ -201,131 +208,149 @@ void analy_sp_fx(
* find input signal energy for each critical band using the DFT buffers
*------------------------------------------------------------------------*/
-static void find_enr_dft_fx(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
- Word32 DFT_past_DMX_fx[], /* i:input DFT_Dmx (Q_inp_dmx ) */
- Word32 band_fx[], /* o : per band energy */
- Word32 *ptE_fx, /* o : per bin energy for low frequencies */
- Word32 *Etot_fx, /* i/o: total energy (Q8) */
- const Word16 min_band, /* i : minimum critical band */
- const Word16 max_band, /* i : maximum critical band */
- Word32 *Bin_E_fx, /* o : Per bin energy (Q7) */
- Word32 *band_ener_fx, /* o : per band energy without E_MIN (Qout) */
- Word16 Q_inp_dmx,
- Word16 *Qout )
+
+static void find_enr_dft_ivas_fx(
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
+ Word32 DFT_past_DMX_fx[], /* i :input DFT_Dmx (Q_inp_dmx ) */
+ Word32 band_fx[], /* o : per band energy (*q_band) */
+ Word16 *q_band, /* o : Q of per band energy */
+ Word32 *ptE_fx, /* o : per bin energy for low frequencies (*q_ptE) */
+ Word16 *q_ptE, /* o : Q of per bin energy for low frequencies */
+ Word64 *Etot_fx, /* i/o: total energy (Q8) */
+ const Word16 min_band, /* i : minimum critical band Q0*/
+ const Word16 max_band, /* i : maximum critical band Q0*/
+ Word32 *Bin_E_fx, /* o : Per bin energy (Q7) */
+ Word16 *q_Bin_E, /* o : Q of Per bin energy (*q_band) */
+ Word32 *band_ener_fx, /* o : per band energy without E_MIN */
+ Word16 Q_inp_dmx )
{
- Word16 i, cnt;
- Word32 tmp_fx;
+ Word16 i;
+ Word64 tot_ener;
Word32 freq;
const Word32 *ptR_fx, *ptI_fx;
- Word32 norm_val_fx;
- Word16 bin_cnt = 0;
- move16();
- // Word32 band_ener_fx[2 * NB_BANDS];
- // Etot_fx[0] = Etot[0] * ONE_IN_Q8;
+ Word16 norm_val_fx;
+ Word16 bin_cnt;
Word32 c_fx, s_fx;
+ Word32 g_fx;
+ Word32 scaleWin_fx;
+ Word16 bin_freq;
+ Word16 temp1, temp2, exp, exp1;
+ Word16 q_norm_val;
+ Word32 BinE_fx[STEREO_DFT_N_12k8_ENC / 2]; /* NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 158 */
+ Word32 c_1_fx, s_1_fx, g_1_fx, g_2_fx;
+ Word64 band_ener;
+ Word32 BinE, tmp_fx;
+ Word32 start_freq;
+ Word32 min_ener;
+ Word16 shift = 0;
+ move16();
+
/* One window - 40ms*12.8kHz = 512 samples */
- Word32 c_1_fx = 2147321984; // cosf( PI2 / STEREO_DFT_N_12k8_ENC ) * ONE_IN_Q31;
- Word32 s_1_fx = 26352928; // sinf( PI2 / STEREO_DFT_N_12k8_ENC ) * ONE_IN_Q31;
- Word32 g_1_fx = 1570240000; // ( 1.f + 0.68f * 0.68f ) * ONE_IN_Q30;
- Word32 g_2_fx = 1460288896; // 2 * 0.68f * ONE_IN_Q30;
+ c_1_fx = 1073660991; // 0.999924719 in Q30, cosf( PI2 / STEREO_DFT_N_12k8_ENC )
+ s_1_fx = 13176464; // 0.0122715384 in Q30, sinf( PI2 / STEREO_DFT_N_12k8_ENC )
+ g_1_fx = 1570240043; // 1.4624 in Q30, ( 1.f + 0.68f * 0.68f )
+ g_2_fx = 1460288880; // 1.36 in Q30, 2 * 0.68f
move32();
move32();
move32();
move32();
- Word32 g_fx;
- Word32 scaleWin_fx;
-
- Word32 BinE_fx[STEREO_DFT_N_12k8_ENC / 2]; /* NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 158 */
- Word16 tmp16, scale = 0;
- tmp16 = BASOP_Util_Divide3216_Scale( input_Fs, hCPE->hStereoDft->NFFT, &scale );
- tmp16 = shr( tmp16, negate( add( 1, scale ) ) );
- Word16 bin_freq = tmp16; // input_Fs / (float) hCPE->hStereoDft->NFFT; /* adaptive frequency bin width */
-
- // scaleWin = 1 / ( 2 * hCPE->hStereoDft->win_ana_energy );
- // scaleWin_fx = ONE_IN_Q31/ ( hCPE->hStereoDft->win_ana_energy_fx );
- scaleWin_fx = BASOP_Util_Divide3216_Scale( ONE_IN_Q31, hCPE->hStereoDft->win_ana_energy_fx, &scale ); // q = 16-scale
- Word16 scalewin_q = sub( 16, scale );
- tmp16 = BASOP_Util_Divide3216_Scale( BIN, bin_freq, &scale );
- tmp16 = shr( tmp16, negate( add( 1, scale ) ) );
- Word16 x_fx = tmp16;
+ bin_cnt = 0;
move16();
- scaleWin_fx = L_mult0( x_fx, extract_l( scaleWin_fx ) ); // scalewin_q
- // scaleWin *= (float) BIN / bin_freq;
- // norm_val = scaleWin * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT );
- norm_val_fx = L_deposit_l( BASOP_Util_Divide3232_Scale( L_shl( scaleWin_fx, Q2 ), L_mult0( hCPE->hStereoDft->NFFT, hCPE->hStereoDft->NFFT ), &scale ) );
- norm_val_fx = L_shl( norm_val_fx, Q31 - ( scalewin_q + 15 - scale ) ); // q31
+
+ /* input_Fs / (float) hCPE->hStereoDft->NFFT;*/ /* adaptive frequency bin width */
+ bin_freq = BASOP_Util_Divide3216_Scale( input_Fs, hCPE->hStereoDft->NFFT, &exp );
+ bin_freq = shl( bin_freq, add( 1, exp ) ); // Q0
+
+ /* scaleWin = 1 / ( 2 * hCPE->hStereoDft->win_ana_energy );
+ scaleWin *= (float) BIN / bin_freq; */
+
+ temp2 = BASOP_Util_Divide3216_Scale( BIN, bin_freq, &exp );
+ temp2 = shl( temp2, add( 1, exp ) ); // Q0
+ exp = norm_s( hCPE->hStereoDft->win_ana_energy_fx );
+ temp1 = div_s( ONE_IN_Q14, shl( hCPE->hStereoDft->win_ana_energy_fx, exp ) ); // 14-(15+exp-1)+15 = 15+exp
+ scaleWin_fx = L_mult0( temp1, temp2 ); // 15+exp
+
+ /* scaleWin * 4.0f makes Q of scaleWin_fx from 15+exp to 13+exp
+ norm_val = scaleWin * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT ); */
+
+ norm_val_fx = BASOP_Util_Divide3232_Scale( scaleWin_fx, L_mult0( hCPE->hStereoDft->NFFT, hCPE->hStereoDft->NFFT ), &exp1 ); // 13+exp+15-exp1 = 28+exp-exp1
+ q_norm_val = add( 28, sub( exp, exp1 ) );
ptR_fx = &DFT_past_DMX_fx[2]; /* first real */
ptI_fx = &DFT_past_DMX_fx[3]; /* first imaginary */
- move32();
- move32();
- c_fx = c_1_fx;
- s_fx = s_1_fx;
+
+ c_fx = c_1_fx; // Q30
+ s_fx = s_1_fx; // Q30
move32();
move32();
/* for low frequency bins, save per bin energy for the use in find_tilt() */
freq = bin_freq;
move32();
+
+ *q_band = add( shl( Q_inp_dmx, 1 ), sub( q_norm_val, 48 ) );
+ move16();
+ *q_Bin_E = *q_band;
+ move16();
+
+ IF( GT_16( *q_band, 39 ) )
+ {
+ shift = sub( *q_band, 39 );
+ *q_band = 39;
+ move16();
+ }
+
+ min_ener = L_shl( E_MIN_FXQ31 /* 0.0035 in Q31 */, sub( *q_band, 31 ) );
FOR( i = 0; i < NB_BANDS - 1; i++ ) /* up to maximum allowed voiced critical band */
{
- band_fx[i] = 0;
+ band_ener = 0;
+ move64();
+ start_freq = freq;
move32();
- cnt = 0;
- move16();
+
/* bins up to crit_band 17 (<= 3700 Hz):
* bin_cnt old (bin_width 50 Hz): 74 (74 * FRAMES_PER_SEC = 3700)
* bin_cnt new (bin_width 40 Hz): 92 (92 * 40 = 3680)
*/
- tmp16 = BASOP_Util_Divide3216_Scale( L_sub( crit_bands_fx[i], freq ), bin_freq, &scale );
- tmp16 = shr( tmp16, negate( add( 1, scale ) ) );
- Word32 freq_diff = L_deposit_l( tmp16 );
- Word16 guarded_bits;
- guarded_bits = find_guarded_bits_fx( freq_diff );
- s_fx = L_shr( s_fx, guarded_bits );
- c_fx = L_shr( c_fx, guarded_bits );
+
WHILE( LE_32( freq, crit_bands_fx[i] ) )
{
- Word64 te = ( W_add( W_mult0_32_32( *ptR_fx, *ptR_fx ), W_mult0_32_32( *ptI_fx, *ptI_fx ) ) );
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Q_inp_dmx + te_exp
- BinE_fx[bin_cnt] = W_extract_h( te ); // 2 * Q_inp_dmx + te_exp - 32
- move32();
- g_fx = L_sub( L_shr( g_1_fx, guarded_bits ), Mpy_32_32( g_2_fx, c_fx ) ); // 30 - guarded_bits
- tmp_fx = L_sub( Mpy_32_32( c_fx, c_1_fx ), Mpy_32_32( s_fx, s_1_fx ) ); // 31 - guarded_bits
- s_fx = L_add( Mpy_32_32( s_fx, c_1_fx ), Mpy_32_32( c_fx, s_1_fx ) ); // 31 - guarded_bits
- c_fx = tmp_fx; // 31 - guarded_bits
+ // g_fx = L_sub( g_1_fx, L_shl( Mpy_32_32( g_2_fx, c_fx ), 1 ) ); // 30
+ g_fx = L_sub( L_shr( g_1_fx, 1 ), Mpy_32_32( g_2_fx, c_fx ) ); // 29
+ tmp_fx = Msub_32_32( Mpy_32_32( c_fx, c_1_fx ), s_fx, s_1_fx ); // 29
+ s_fx = L_shl( Madd_32_32( Mpy_32_32( s_fx, c_1_fx ), c_fx, s_1_fx ), 1 ); // 30
+ c_fx = L_shl( tmp_fx, 1 ); // 30
+
+ BinE = Madd_32_32( Mpy_32_32( *ptR_fx, *ptR_fx ), *ptI_fx, *ptI_fx ); // 2*Q_inp_dmx-31
+ BinE_fx[bin_cnt] = Mpy_32_32( BinE, Mpy_32_16_1( g_fx, norm_val_fx ) ); // (2*Q_inp_dmx-31)+(q_norm_val+29-15)-31 = 2*Q_inp_dmx+q_norm_val-48 = *q_Bin_E
move32();
- Word64 ngmult = W_mult0_32_32( norm_val_fx, g_fx ); // Q31 + Q30 - gaurded_bits
- Word16 ngmult_exp = W_norm( ngmult );
- ngmult = W_shl( ngmult, ngmult_exp ); // Q31 + Q30 - gaurded_bits + ngmult_exp
- BinE_fx[bin_cnt] = Mpy_32_32( W_extract_h( ngmult ), BinE_fx[bin_cnt] ); //(Q31 + Q31 - gaurded_bits + ngmult_exp) - Q32 + (2 * Q_inp_dmx + te_exp - 32) - 31
- move32();
- // To Be Checked
- BinE_fx[bin_cnt] = L_shl_sat( BinE_fx[bin_cnt], sub( *Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) );
- move32();
- // To Be Checked
- band_fx[i] = L_add_sat( BinE_fx[bin_cnt], band_fx[i] );
- move32();
+ /*
+ BIN_FREQ_FX = BIN, cnt = ( ( crit_bands_fx[i] - start_freq ) / bin_freq ) + 1
+ band[i] = BinE[bin_cnt];
+ band[i] *= inv_tbl[cnt]; // normalization per frequency bin
+ */
+ band_ener = W_mac_32_16( band_ener, BinE_fx[bin_cnt], inv_tbl_fx[( ( crit_bands_fx[i] - start_freq ) / bin_freq ) + 1] ); // *q_band+shift+16
+
ptR_fx += 2;
ptI_fx += 2;
- freq = L_add( freq, L_deposit_l( bin_freq ) );
- cnt = add( cnt, 1 );
+ freq = L_mac0( freq, bin_freq, 1 );
bin_cnt = add( bin_cnt, 1 );
}
- s_fx = L_shl( s_fx, guarded_bits );
- c_fx = L_shl( c_fx, guarded_bits );
- band_fx[i] = Mpy_32_16_r( band_fx[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */
+
+ /* normalization per frequency bin */
+ band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band
move32();
- band_ener_fx[i] = band_fx[i]; /* per band energy without E_MIN */
+
+ /* per band energy without E_MIN */
+ band_ener_fx[i] = band_fx[i]; // *q_band
move32();
- IF( LT_32( band_fx[i], L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) ) ) )
+
+ if ( LT_32( band_fx[i], min_ener ) )
{
- band_fx[i] = L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) );
+ band_fx[i] = min_ener; // *q_band
move32();
}
}
@@ -343,52 +368,47 @@ static void find_enr_dft_fx(
/* NB_BANDS = 24 (= 15500Hz) = highest band available for SR 32 -> bin_cnt = 387 */
/* NB_BANDS = 24 (= 15500Hz) = highest band available for SR 48 -> bin_cnt = 387 */
- for ( ; i < NB_BANDS; i++ )
+ FOR( ; i < NB_BANDS; i++ )
{
- band_fx[i] = 0;
+ band_ener = 0;
+ move64();
+ start_freq = freq;
move32();
- cnt = 0;
- move16();
- tmp16 = BASOP_Util_Divide3216_Scale( L_sub( 6399, freq ), bin_freq, &scale );
- tmp16 = shr( tmp16, negate( add( 1, scale ) ) );
- Word32 freq_diff = L_deposit_l( tmp16 );
- Word16 guarded_bits;
- guarded_bits = find_guarded_bits_fx( freq_diff );
- c_fx = L_shr( c_fx, guarded_bits );
+
WHILE( LT_32( freq, 6399 ) )
{
- Word64 te = ( W_add( W_mult0_32_32( *ptR_fx, *ptR_fx ), W_mult0_32_32( *ptI_fx, *ptI_fx ) ) );
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Q_inp_dmx + te_exp
- BinE_fx[bin_cnt] = W_extract_h( te ); // 2 * Q_inp_dmx + te_exp - 32
- move32();
- g_fx = L_sub( L_shr( g_1_fx, guarded_bits ), Mpy_32_32( g_2_fx, c_fx ) );
- Word64 ngmult = W_mult0_32_32( norm_val_fx, g_fx ); // Q31 + Q31 - gaurded_bits
- Word16 ngmult_exp = W_norm( ngmult );
- ngmult = W_shl( ngmult, ngmult_exp ); // Q31 + Q31 - gaurded_bits + ngmult_exp
- BinE_fx[bin_cnt] = Mpy_32_32( W_extract_h( ngmult ), BinE_fx[bin_cnt] ); //(Q31 + Q31 - gaurded_bits + ngmult_exp) - Q32 + (2 * Q_inp_dmx + te_exp - 32) - 31
- move32();
- // To Be Checked
- BinE_fx[bin_cnt] = L_shl_sat( BinE_fx[bin_cnt], sub( *Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) );
- move32();
- // To Be Checked
- band_fx[i] = L_add_sat( BinE_fx[bin_cnt], band_fx[i] );
+ // g_fx = L_sub( g_1_fx, L_shl( Mpy_32_32( g_2_fx, c_fx ), 1 ) ); // 30
+ g_fx = L_sub( L_shr( g_1_fx, 1 ), Mpy_32_32( g_2_fx, c_fx ) ); // 29
+
+ BinE = Madd_32_32( Mpy_32_32( *ptR_fx, *ptR_fx ), *ptI_fx, *ptI_fx ); // 2*Q_inp_dmx-31
+ BinE_fx[bin_cnt] = Mpy_32_32( BinE, Mpy_32_16_1( g_fx, norm_val_fx ) ); // (2*Q_inp_dmx-31)+(q_norm_val+29-15)-31 = 2*Q_inp_dmx+q_norm_val-48 = *q_Bin_E
move32();
+
+ /*
+ BIN_FREQ_FX = BIN, cnt = ( ( 6399 - start_freq ) / bin_freq ) + 1
+ band[i] = BinE[bin_cnt];
+ band[i] *= inv_tbl[cnt]; // normalization per frequency bin
+ */
+ band_ener = W_mac_32_16( band_ener, BinE_fx[bin_cnt], inv_tbl_fx[( ( 6399 - start_freq ) / bin_freq ) + 1] ); // *q_band+shift
+
ptR_fx += 2;
ptI_fx += 2;
- freq = L_add( freq, L_deposit_l( bin_freq ) );
- cnt = add( cnt, 1 );
+ freq = L_mac0( freq, bin_freq, 1 );
bin_cnt = add( bin_cnt, 1 );
}
- c_fx = L_shl( c_fx, guarded_bits );
- band_fx[i] = Mpy_32_16_r( band_fx[i], inv_tbl_fx[cnt] );
+
+ /* normalization per frequency bin */
+ band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band
move32();
- band_ener_fx[i] = band_fx[i];
+
+ /* per band energy without E_MIN */
+ band_ener_fx[i] = band_fx[i]; // *q_band
move32();
- IF( LT_32( band_fx[i], L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) ) ) )
+
+ if ( LT_32( band_fx[i], min_ener ) )
{
- band_fx[i] = L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) );
+ band_fx[i] = min_ener; // *q_band
move32();
}
}
@@ -396,25 +416,27 @@ static void find_enr_dft_fx(
/* put bin energies from BinE into Bin_E[L_FFT/2-1] (interpolate 40 Hz bin values to fit into 50 Hz bins) */
/* Last value of Bin_E is handled outside this function*/
assert( bin_cnt == ( STEREO_DFT_N_12k8_ENC / 2 - 1 ) );
- BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 1] = BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 2];
+ BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 1] = BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 2]; // // *q_Bin_E
move32();
- L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, Qout );
- MVR2R_WORD32( Bin_E_fx, ptE_fx, VOIC_BINS ); // Qout
+
+ L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, q_Bin_E );
+
+ MVR2R_WORD32( Bin_E_fx, ptE_fx, VOIC_BINS ); // *q_Bin_E
+ *q_ptE = *q_Bin_E;
+ move16();
/* find the total log energy */
- tmp_fx = *Etot_fx;
- move32();
+ tot_ener = *Etot_fx;
+ move64();
+
FOR( i = min_band; i <= max_band; i++ )
{
- tmp_fx = L_add( tmp_fx, band_fx[i] ); // Qout
+ tot_ener = W_mac_32_32( tot_ener, band_fx[i], 1 ); // *q_band+1
}
- *Etot_fx = tmp_fx;
- // To Be Checked
- Scale_sig32( band_fx, NB_BANDS, 2 );
- // To Be Checked
- Scale_sig32( band_ener_fx, NB_BANDS, 2 );
- move32();
+ *Etot_fx = tot_ener;
+ move64();
+
return;
}
/*-------------------------------------------------------------------*
@@ -422,38 +444,41 @@ static void find_enr_dft_fx(
*
* Spectral analysis of 12.8kHz input
*-------------------------------------------------------------------*/
-
void ivas_analy_sp_fx(
- const Word16 element_mode, /* i : element mode */
+ const Word16 element_mode, /* i : element mode Q0*/
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
Word16 *speech, /* i : speech buffer Q_new - preemph_bits */
const Word16 Q_new, /* i : current scaling exp Q0 */
- Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */
- Word32 *lf_E, /* o : per bin E for first... Q_new + QSCALE - 2*/
+ Word32 *fr_bands, /* o : energy in critical frequency bands q_fr_bands */
+ Word16 *q_fr_bands, /* o : energy in critical frequency bands Q0 */
+ Word32 *lf_E, /* o : per bin E for first... q_lf_E */
+ Word16 *q_lf_E, /* o : per bin E for first... Q0 */
Word16 *Etot, /* o : total input energy Q8 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
- const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE */
- Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */
Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */
+ Word16 *q_Bin_E, /* o : per-bin energy spectrum Q7 */
Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
- Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE */
+ Word16 *q_Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
+ Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */
+ Word16 *q_PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */
Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */
- Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE + 2)*/
- Word16 *fft_buff /* o : FFT coefficients (Q_new + QSCALE + 2) */
+ Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (q_band_energies)*/
+ Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */
+ Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */
+ Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */
)
{
Word16 *pt;
Word16 i_subfr, i;
Word32 *pt_bands;
- Word32 Ltmp, LEtot;
+ Word32 Ltmp;
Word16 *pt_fft;
- Word16 Min_val, Max_val;
- Word16 Scale_fac2;
- Word16 fft_temp[L_FFT];
-
- (void) input_Fs;
+ Word16 exp, tmp;
+ Word64 LEtot;
+ LEtot = 0;
+ move64();
/*-----------------------------------------------------------------*
* Compute spectrum
* find energy per critical frequency band and total energy in dB
@@ -461,277 +486,209 @@ void ivas_analy_sp_fx(
pt_bands = fr_bands;
pt_fft = fft_buff;
- LEtot = L_deposit_l( 0 );
+
IF( NE_16( element_mode, IVAS_CPE_DFT ) )
{
- FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
+ IF( is_zero_arr16( speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2, L_FFT + 4 * ( L_SUBFR / 2 ) ) )
{
- pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2;
- IF( i_subfr != 0 )
- {
- pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2;
- }
-
- /* Clear 1st value of 1st part, copy 1st value of 2nd part */
- fft_temp[0] = 0;
- move16();
- fft_temp[L_FFT / 2] = pt[L_FFT / 2];
+ set16_fx( pt_fft, 0, 2 * L_FFT );
+ *q_fft_buff = Q15;
move16();
- Max_val = s_max( fft_temp[0], fft_temp[L_FFT / 2] );
- Min_val = s_min( fft_temp[0], fft_temp[L_FFT / 2] );
-
- FOR( i = 1; i < L_FFT / 2; i++ )
- {
- /* 1st windowed part */
- fft_temp[i] = mult_r( pt[i], sqrt_han_window_fx[i] );
- move16();
- if ( fft_temp[i] > 0 )
- Max_val = s_max( Max_val, fft_temp[i] );
- if ( fft_temp[i] < 0 )
- Min_val = s_min( Min_val, fft_temp[i] );
-
- /* 2nd windowed part */
- fft_temp[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] );
- move16();
- if ( fft_temp[L_FFT - i] > 0 )
- Max_val = s_max( Max_val, fft_temp[L_FFT - i] );
- if ( fft_temp[L_FFT - i] < 0 )
- Min_val = s_min( Min_val, fft_temp[L_FFT - i] );
- }
- /* Combine -Min_val and Max_val into one */
- Max_val = s_max( negate( Min_val ), Max_val );
+ set32_fx( Bin_E, 0, L_FFT );
+ set32_fx( lf_E, 0, 2 * VOIC_BINS );
+ set32_fx( band_energies, 0, 2 * NB_BANDS );
+ set32_fx( fr_bands, E_MIN_FXQ31, 2 * NB_BANDS ); // Q31 (*q_fr_bands)
- Scale_fac[i_subfr] = s_min( sub( norm_s( Max_val ), 1 ), 6 );
+ LEtot = W_shl( W_mult_32_16( E_MIN_FXQ31, add( sub( max_band, min_band ), 1 ) ), 1 ); // Q32 (*q_fr_bands+1)
+ *q_fr_bands = Q31;
+ *q_lf_E = *q_fr_bands;
move16();
- Scale_fac2 = shl( Scale_fac[i_subfr], 1 );
- Scale_sig( fft_temp, L_FRAME_12k8, Scale_fac[i_subfr] );
-
- r_fft_fx_lc( FFT_W128, SIZE_256, SIZE2_256, NUM_STAGE_256, fft_temp, pt_fft, 1 );
- Scale_sig( pt_fft, L_FFT, -1 ); // Q(-1)
- /*e_min_scaled = Q_new + QSCALE + 2*/
- ivas_find_enr( pt_fft, pt_bands, lf_E + i_subfr * VOIC_BINS, &LEtot, min_band, max_band,
- add( Q_new, Scale_fac2 ), e_min_scaled, &Bin_E[i_subfr * L_FFT / 2], BIN, band_energies + i_subfr * NB_BANDS );
- pt_bands += NB_BANDS;
- pt_fft += L_FFT;
- }
- LEtot = L_shl_sat( LEtot, 2 ); // Q_new + Q_SCALE - 2
- }
- ELSE
- {
- Word16 Qout = add( Q_new, QSCALE - 2 );
- find_enr_dft_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, lf_E, &LEtot, min_band, max_band, Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ), &Qout );
- MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS );
- MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 );
- MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS );
- MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS );
- LEtot = L_shl( LEtot, 1 );
- }
- Word32 temp32_log;
- temp32_log = L_add( BASOP_Util_Log2( L_shr( LEtot, 1 ) ), L_shl( sub( Q31, add( Q_new, QSCALE - Q2 ) ), Q25 ) );
- temp32_log = Mpy_32_32( temp32_log, 1616142483 ); // log10(x) = log2(x)/log2(10)
- /* 10.0 * log10( (float) tmp )*/
- /* 10.0/log2(10) in Q29 = 1616142483*/
- *Etot = extract_l( L_shr( temp32_log, 23 - 8 ) ); // Q8
-
- Bin_E[L_FFT / 2 - 1] = Bin_E[L_FFT / 2 - 2];
- move32();
- Bin_E[L_FFT - 1] = Bin_E[L_FFT - 2];
- move32();
-
- /* Per-bin log-energy spectrum */
-
- FOR( i = 0; i < L_FFT / 2; i++ )
- {
- Bin_E_old[i] = Bin_E[i];
- move32();
- /* tmp = (input[i] + input[i+Len]+0.001f)/2.0f */
- Ltmp = L_max( L_shr( 21474, sub( Q31, add( Q_new, QSCALE ) ) ), L_add( L_shr( Bin_E[i], 1 ), L_shr( Bin_E[i + L_FFT / 2], 1 ) ) );
- if ( PS != NULL )
- {
- PS[i] = Ltmp;
- move32();
- }
- if ( EspecdB != NULL )
- {
- temp32_log = L_add( BASOP_Util_Log2( Ltmp ), L_shl( sub( Q31, Q_new + QSCALE ), Q25 ) );
- EspecdB[i] = extract_l( L_shr( Mpy_32_32( temp32_log, 1860652798 ), Q22 - Q7 ) ); /*log(x) = log2(x)*logf(2)*/
- /* 10.0*log((float)tmp) */
- /* 10.0*logf(2) in Q28 = 1860652798 */
-
move16();
}
- }
-
-
- return;
-}
-
-void ivas_analy_sp_fx_front(
- const Word16 element_mode, /* i : element mode */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
- Word16 *speech, /* i : speech buffer Q_new - preemph_bits */
- const Word16 Q_new, /* i : current scaling exp Q0 */
- Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */
- Word32 *lf_E, /* o : per bin E for first... Q_new + QSCALE - 2*/
- Word16 *Etot, /* o : total input energy Q8 */
- const Word16 min_band, /* i : minimum critical band Q0 */
- const Word16 max_band, /* i : maximum critical band Q0 */
- const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE */
- Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */
- Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */
- Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
- Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */
- Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */
- Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE)*/
- Word16 *fft_buff /* o : FFT coefficients (Q_new + Scale_fac[i_subfr]) */
-)
-{
- Word16 *pt;
- Word16 i_subfr, i;
- Word32 *pt_bands;
- Word32 Ltmp, LEtot;
- Word16 *pt_fft;
- Word32 temp32_log;
- /*-----------------------------------------------------------------*
- * Compute spectrum
- * find energy per critical frequency band and total energy in dB
- *-----------------------------------------------------------------*/
-
- pt_bands = fr_bands;
- pt_fft = fft_buff;
- LEtot = L_deposit_l( 0 );
- IF( NE_16( element_mode, IVAS_CPE_DFT ) )
- {
- FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
+ ELSE
{
- /* set pointer to the beginning of the signal for spectral analysis */
- /* set the pointer for first analysis window */
- pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2;
- IF( i_subfr != 0 )
- {
- /* set the pointer for second analysis window */
- pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2;
- }
-
- /* Clear 1st value of 1st part, copy 1st value of 2nd part */
- pt_fft[0] = 0;
- move16();
- pt_fft[L_FFT / 2] = pt[L_FFT / 2];
+ Word16 scale = norm_arr( speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2, L_FFT + 4 * ( L_SUBFR / 2 ) );
+ scale = sub( scale, LOG2_L_FFT ); // guard_bits
+ *q_fft_buff = add( Q_new, scale );
move16();
- FOR( i = 1; i < L_FFT / 2; i++ )
+ FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
{
- /* 1st windowed part */
- pt_fft[i] = mult_r( pt[i], sqrt_han_window_fx[i] );
- move16();
+ /* set pointer to the beginning of the signal for spectral analysis */
+ /* set the pointer for first analysis window */
+ pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2;
+ if ( i_subfr != 0 )
+ {
+ /* set the pointer for second analysis window */
+ pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2;
+ }
- /* 2nd windowed part */
- pt_fft[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] );
+ /* Clear 1st value of 1st part, copy 1st value of 2nd part */
+ pt_fft[0] = 0;
+ move16();
+ pt_fft[L_FFT / 2] = pt[L_FFT / 2]; // Q_new - preemph_bits
move16();
- }
- Scale_fac[i_subfr] = -2;
- move16();
- Scale_sig( pt_fft, L_FFT, Scale_fac[i_subfr] );
+ FOR( i = 1; i < L_FFT / 2; i++ )
+ {
+ /* 1st windowed part */
+ pt_fft[i] = mult_r( pt[i], sqrt_han_window_fx[i] ); // Q_new - preemph_bits
+ move16();
- /* compute the spectrum */
- fft_rel_fx( pt_fft, L_FFT, LOG2_L_FFT );
+ /* 2nd windowed part */
+ pt_fft[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] ); // Q_new - preemph_bits
+ move16();
+ }
- /* find energy per critical band */
- ivas_find_enr1( pt_fft, add( Q_new, Scale_fac[i_subfr] ), pt_bands, lf_E + i_subfr * VOIC_BINS, &LEtot, min_band, max_band,
- Q_new, e_min_scaled, &Bin_E[i_subfr * L_FFT / 2], BIN, band_energies + i_subfr * NB_BANDS );
+ scale_sig( pt_fft, L_FFT, scale );
- pt_bands += NB_BANDS;
- pt_fft += L_FFT;
+ /* compute the spectrum */
+ fft_rel_fx( pt_fft, L_FFT, LOG2_L_FFT );
+
+ /* find energy per critical band */
+ ivas_find_enr( pt_fft, *q_fft_buff, pt_bands, q_fr_bands, lf_E + i_subfr * VOIC_BINS, q_lf_E, &LEtot, min_band, max_band,
+ &Bin_E[i_subfr * L_FFT / 2], BIN, band_energies + i_subfr * NB_BANDS );
+
+ pt_bands += NB_BANDS;
+ pt_fft += L_FFT;
+ }
}
+ *q_Bin_E = *q_lf_E;
+ move16();
+
/* Average total log energy over both half-frames */
/* *Etot = 10.0f * (float)log10(0.5f * *Etot); */
*Etot = -12800 /* 10.f * logf(0.00001f) in Q8 */;
move16();
IF( LEtot != 0 )
{
- /* Q of LEtot is Q_new + Q_SCALE - 1, LEtot / 2 can be considered as LEtot in Q_new + Q_SCALE - 2*/
- temp32_log = BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q2 ) ) ); // Q25
- temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
- *Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8
+ /* Q of LEtot is q_fr_bands+1, LEtot / 2 can be considered as LEtot in q_fr_bands+2 */
+ exp = W_norm( LEtot );
+ LEtot = W_shl( LEtot, exp ); // q_fr_bands+2+exp
+ Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 61, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+2+exp-32) */ ); // Q25
+ Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
+ *Etot = extract_h( L_shl( Ltmp, Q24 - Q21 ) ); // Q8
move16();
}
}
ELSE
{
- Word16 Qout = add( Q_new, QSCALE - 2 );
- find_enr_dft_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, lf_E, &LEtot, min_band, max_band, Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ), &Qout );
- scale_sig32( lf_E, VOIC_BINS, sub( add( Q_new, QSCALE - 2 ), Qout ) );
- MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS );
- MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 );
- MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS );
- MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS );
-
- /* *Etot *= 2.f;
- *Etot = 10.0f * (float)log10(0.5f * *Etot);
- => *Etot = 10.0f * (float)log10(*Etot);
- */
+ IF( is_zero_arr( hCPE->hStereoDft->DFT_fx[0], STEREO_DFT_N_MAX_ENC ) )
+ {
+ set32_fx( Bin_E, 0, L_FFT );
+ set32_fx( lf_E, 0, 2 * VOIC_BINS );
+ set32_fx( band_energies, 0, 2 * NB_BANDS );
+ set32_fx( fr_bands, E_MIN_FXQ31, 2 * NB_BANDS ); // Q31 (*q_fr_bands)
+
+ LEtot = W_shl( W_mult_32_16( E_MIN_FXQ31, add( sub( max_band, min_band ), 1 ) ), 1 ); // Q32 (*q_fr_bands+1)
+ *q_fr_bands = Q31;
+ *q_lf_E = *q_fr_bands;
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ exp = sub( getScaleFactor32( hCPE->hStereoDft->DFT_fx[0], STEREO_DFT_N_MAX_ENC ), 1 );
+ scale_sig32( hCPE->hStereoDft->DFT_fx[0], STEREO_DFT_N_MAX_ENC, exp ); /* exp(hCPE->hStereoDft->DFT_fx_e[0] - exp) */
+ hCPE->hStereoDft->DFT_fx_e[0] = sub( hCPE->hStereoDft->DFT_fx_e[0], exp );
+ move16();
+ find_enr_dft_ivas_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, q_fr_bands, lf_E, q_lf_E, &LEtot, min_band, max_band, Bin_E, q_Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ) );
+ MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS );
+ MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 );
+ MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS );
+ MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS );
+ }
/* Average total log energy over both half-frames */
*Etot = -12800 /* 10.f * logf(0.00001f) in Q8 */;
move16();
IF( LEtot != 0 )
{
- temp32_log = BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q2 ) ) ); // Q25
- temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
- *Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8
+ exp = W_norm( LEtot );
+ LEtot = W_shl( LEtot, exp ); // q_fr_bands+exp
+ Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 62, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+1+exp-32) */ ); // Q25
+ Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
+ *Etot = extract_h( L_shl( Ltmp, Q24 - Q21 ) ); // Q8
move16();
}
}
+ *q_band_energies = *q_fr_bands;
+ move16();
+
+ exp = sub( getScaleFactor32( fr_bands, 2 * NB_BANDS ), 1 );
+ scale_sig32( fr_bands, 2 * NB_BANDS, exp ); /* q_fr_bands + exp */
+ *q_fr_bands = add( *q_fr_bands, exp );
+ move16();
+
+ exp = sub( getScaleFactor32( band_energies, 2 * NB_BANDS ), 1 );
+ scale_sig32( band_energies, 2 * NB_BANDS, exp ); /* q_band_energies + exp */
+ *q_band_energies = add( *q_band_energies, exp );
+ move16();
+
+ *q_Bin_E_old = *q_Bin_E;
+ move16();
+
+
/* Per-bin log-energy spectrum */
- Bin_E[L_FFT / 2 - 1] = Bin_E[L_FFT / 2 - 2];
+ Bin_E[L_FFT / 2 - 1] = Bin_E[L_FFT / 2 - 2]; // *q_Bin_E
move32();
- Bin_E[L_FFT - 1] = Bin_E[L_FFT - 2];
+ Bin_E[L_FFT - 1] = Bin_E[L_FFT - 2]; // *q_Bin_E
move32();
FOR( i = 0; i < L_FFT / 2; i++ )
{
- Bin_E_old[i] = Bin_E[i];
+ Bin_E_old[i] = Bin_E[i]; // *q_Bin_E
move32();
- /* tmp = (input[i] + input[i+Len]+0.001f)/2.0f */
- // Ltmp = L_max( L_shr( 21474, sub( Q31, add( Q_new, QSCALE ) ) ), L_add( L_shr( Bin_E[i], 1 ), L_shr( Bin_E[i + L_FFT / 2], 1 ) ) );
- Ltmp = L_add( L_shr( Bin_E[i], 1 ), L_shr( Bin_E[i + L_FFT / 2], 1 ) ); // average
- if ( Ltmp == 0 )
- {
- // Ltmp = L_min( L_shr( 21474, sub( Q31, add( Q_new, QSCALE - 2 ) ) ), 1 );
- Ltmp = L_max( L_shr( 21474, sub( Q31, add( Q_new, QSCALE - 2 ) ) ), 1 );
- if ( EspecdB != NULL )
- {
- // temp32_log = L_add( BASOP_Util_Log2( Ltmp ), L_shl( sub( Q31, Q_new + QSCALE ), Q25 ) );
- // EspecdB[i] = -1474; /* log(1e-5) in Q7 */
- EspecdB[i] = -14736; /* log(1e-5) in Q7 */
- move16();
- }
+ /* PS[i] = ( Bin_E[i] + 1e-5f + Bin_E[i + L_FFT / 2] + 1e-5f ) / 2.0f; */
+ PS[i] = W_extract_h( W_mac_32_32( W_mult_32_32( Bin_E[i], ONE_IN_Q30 ), Bin_E[i + L_FFT / 2], ONE_IN_Q30 ) ); // *q_Bin_E
+ move32();
+
+ /* Bin_E[i] = (float) ( 10.0f * log( PS[i] ) ); */
+ IF( EspecdB != NULL )
+ {
+ EspecdB[i] = -14736; /* ln(1e-5) in Q7 */
+ move16();
}
- else
+
+ Bin_E[i] = -482887093; /* ln(1e-5) in Q22 */
+ move32();
+
+ IF( GT_32( PS[i], L_shl_sat( 21475, sub( *q_Bin_E, Q31 ) ) ) /*1e - 5 in *q_bin_E */ )
{
+ Ltmp = L_add( BASOP_Util_Log2( PS[i] ), L_shl( sub( Q31, *q_Bin_E ), Q25 ) );
+ Bin_E[i] = Mpy_32_32( Ltmp, 1860652798 /*10.0*logf(2) in Q28 */ ); // Q22
+ move32();
+
+ tmp = extract_h( L_shl( Bin_E[i], Q23 - Q22 ) ); // Q7
if ( EspecdB != NULL )
{
- temp32_log = L_add( BASOP_Util_Log2( Ltmp ), L_shl( sub( Q31, Q_new + QSCALE - 2 ), Q25 ) );
- EspecdB[i] = extract_l( L_shr( Mpy_32_32( temp32_log, 1860652798 ), Q22 - Q7 ) ); /*log(x) = log2(x)*logf(2)*/
- /* 10.0*log((float)tmp) */
- /* 10.0*logf(2) in Q28 = 1860652798 */
-
+ EspecdB[i] = tmp; // Q7
move16();
}
}
- if ( PS != NULL )
- {
- PS[i] = Ltmp;
- move32();
- }
}
+ if ( q_PS != NULL )
+ {
+ *q_PS = *q_Bin_E;
+ move16();
+ }
+
+ exp = L_norm_arr( Bin_E, L_FFT / 2 );
+ IF( GE_16( exp, sub( *q_Bin_E, Q22 ) ) )
+ {
+ scale_sig32( Bin_E, L_FFT / 2, sub( *q_Bin_E, Q22 ) ); // *q_Bin_E
+ }
+ ELSE
+ {
+ scale_sig32( Bin_E + L_FFT / 2, L_FFT / 2, sub( Q22, *q_Bin_E ) ); // Q22
+ *q_Bin_E = Q22;
+ move16();
+ }
return;
}
@@ -743,330 +700,108 @@ void ivas_analy_sp_fx_front(
* The energy is normalized by the number of frequency bins in a channel
*------------------------------------------------------------------------*/
+/* Merge with ivas_find_enr function once analy_sp is unified */
static void ivas_find_enr(
Word16 data[], /* i : fft result */
- Word32 band[], /* o : per band energy Q_new + QSCALE */
- Word32 *ptE, /* o : per bin energy for low frequencies Q_new + QSCALE-2 */
- Word32 *LEtot, /* o : total energy Q_new + QSCALE */
+ Word16 q_data, /* i : Q of fft result */
+ Word32 band[], /* o : per band energy q_band */
+ Word16 *q_band, /* o : Q of per band energy */
+ Word32 *ptE, /* o : per bin energy for low frequencies q_ptE */
+ Word16 *q_ptE, /* o : Q of per bin energy for low frequencies Q0 */
+ Word64 *LEtot, /* o : total energy q_band+1 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
- const Word16 Q_new2, /* i : scaling factor Q0 */
- const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE */
- Word32 *Bin_E, /* o : Per bin energy Q_new + QSCALE-2 */
- Word16 BIN_FREQ_FX, /* i : Number of frequency bins */
- Word32 *band_energies /* o : per band energy without MODE2_E_MIN */
+ Word32 *Bin_E, /* o : Per bin energy q_ptE */
+ Word16 BIN_FREQ_FX, /* i : Number of frequency bins Q0 */
+ Word32 *band_energies /* o : per band energy without MODE2_E_MIN q_band */
)
{
- Word16 i, cnt, shift_to_norm;
- Word16 freq, wtmp;
- Word16 *ptR, *ptI, diff_scaleP1, diff_scaleM2;
- Word16 exp_band;
- Word32 Ltmp, Ltmp1;
+ Word16 i;
+ Word16 freq;
+ Word16 *ptR, *ptI;
Word16 voic_band;
- Word32 etot;
- Word16 exp_etot;
- Word32 *tmpptr;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
+ Word64 etot, band_ener;
+ Word16 start_freq;
+ Word32 min_ener;
+ Word16 shift = 0;
move16();
-#endif
-
ptR = &data[1]; /* first real */
ptI = &data[L_FFT - 1]; /* first imaginary */
- /*-----------------------------------------------------------------------------------*
- * Scaling needed by band and ptE output
- * Wants all energies scaled by Q_new + QSCALE to maintain maximum
- * precision on bckr noise in clean speech
- * First shift left by Q_new + QSCALE than shift right by 2*Q_new-1
- * shift left (Q_new + QSCALE - (2*Q_new -1))
- * shift left (QSCALE - Q_new + 1) == shift left by (QSCALE+1) - Q_new
- *-----------------------------------------------------------------------------------*/
-
- diff_scaleP1 = sub( QSCALE + 1 + 1, Q_new2 );
- diff_scaleM2 = sub( QSCALE + 1 - 2, Q_new2 );
-
voic_band = VOIC_BAND_8k;
move16();
assert( VOIC_BAND == VOIC_BAND_8k );
- etot = L_deposit_l( 0 );
- exp_etot = 0;
- move16();
-
/*-----------------------------------------------------------------*
* For low frequency bins, save per bin energy for the use
* in NS and find_tilt()
*-----------------------------------------------------------------*/
- freq = BIN_FREQ_FX;
+ *q_ptE = add( shl( q_data, 1 ), 14 );
+ move16();
+ *q_band = add( shl( q_data, 1 ), 14 );
move16();
- FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */
- {
- tmpptr = Bin_E;
- move16();
- Ltmp1 = L_deposit_l( 0 );
-
- FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
- {
- /*ptE = *ptR * *ptR + *ptI * *ptI */ /* energy */
- Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) ); // 2 * Qfft
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Qfft + te_exp
- Ltmp = W_extract_h( te ); // 2 * Qfft + te_exp - 32
-
- Ltmp = L_shr( Ltmp, sub( te_exp, 32 ) );
- /* *ptE *= 4.0 / (L_FFT*L_FFT) */
- /* normalization - corresponds to FFT normalization by 2/L_FFT */
- BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
-#ifdef BASOP_NOGLOB
- *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#else /* BASOP_NOGLOB */
- *ptE = L_shl( Ltmp, diff_scaleM2 );
-#endif /* BASOP_NOGLOB */
- move32(); /* scaled by Q_new + QSCALE - 2 */
- BASOP_SATURATE_WARNING_ON_EVS;
- /*band[i] += *ptE++;*/
- *Bin_E = *ptE;
- move32();
- Bin_E++;
- Ltmp1 = L_add( Ltmp1, Ltmp );
-
- ptE++;
- ptR++;
- ptI--;
- }
-
- exp_band = sub( norm_l( Ltmp1 ), 1 ); /* divide by 2 to ensure band < cnt */
- wtmp = round_fx( L_shl( Ltmp1, exp_band ) );
-
- /* band[i] /= cnt */ /* normalization per frequency bin */
- cnt = (Word16) ( Bin_E - tmpptr );
- shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
-
- exp_band = sub( exp_band, shift_to_norm );
- exp_band = sub( diff_scaleP1, exp_band );
- BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
-#ifdef BASOP_NOGLOB
- band[i] = L_shl_o( Ltmp1, exp_band, &Overflow );
-#else /* BASOP_NOGLOB */
- band[i] = L_shl( Ltmp1, exp_band );
-#endif /* BASOP_NOGLOB */
- move32(); /* band scaled by Q_new + QSCALE */
- BASOP_SATURATE_WARNING_ON_EVS;
-
- test();
- IF( GE_16( i, min_band ) && LE_16( i, max_band ) )
- {
- IF( LT_32( band[i], e_min ) )
- {
- Ltmp1 = L_shl( e_min, 0 );
- exp_band = 0;
- move16();
- }
-
- wtmp = sub( exp_band, exp_etot );
- if ( wtmp > 0 )
- {
- etot = L_shr( etot, wtmp );
- }
- exp_etot = s_max( exp_etot, exp_band );
- etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
- }
-
- band_energies[i] = band[i];
- move32();
-
- band[i] = L_max( band[i], e_min );
- move32();
- }
- IF( EQ_16( BIN_FREQ_FX, 50 ) )
+ IF( GT_16( *q_band, 39 ) )
{
- /*-----------------------------------------------------------------*
- * Continue compute the E per critical band for high frequencies
- *-----------------------------------------------------------------*/
-
- FOR( i = voic_band; i < NB_BANDS; i++ )
- {
- tmpptr = Bin_E;
- move16();
- Ltmp1 = L_deposit_l( 0 );
-
- FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
- {
- /* *ptE = *ptR * *ptR + *ptI * *ptI */
- Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) );
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp );
- Ltmp = W_extract_h( te );
- Ltmp = L_shr( Ltmp, sub( te_exp, 32 ) );
-
- /* *ptE *= 4.0 / (L_FFT*L_FFT) */
- /* normalization - corresponds to FFT normalization by 2/L_FFT */
- BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
-#ifdef BASOP_NOGLOB
- *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#else /* BASOP_NOGLOB */
- *Bin_E = L_shl( Ltmp, diff_scaleM2 );
-#endif /* BASOP_NOGLOB */
- move32(); /* scaled by Q_new + QSCALE - 2 */
- BASOP_SATURATE_WARNING_ON_EVS;
- Bin_E++;
- Ltmp1 = L_add( Ltmp1, Ltmp );
-
- ptR++;
- ptI--;
- }
-
- exp_band = sub( norm_l( Ltmp1 ), 1 ); /* divide by 2 to ensure band < cnt */
- wtmp = round_fx( L_shl( Ltmp1, exp_band ) );
-
- /* band[i] /= cnt */ /* normalization per frequency bin */
- cnt = (Word16) ( Bin_E - tmpptr );
- shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
-
- exp_band = sub( exp_band, shift_to_norm );
- exp_band = sub( diff_scaleP1, exp_band );
- BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
-#ifdef BASOP_NOGLOB
- band[i] = L_shl_o( Ltmp1, exp_band, &Overflow );
-#else /* BASOP_NOGLOB */
- band[i] = L_shl( Ltmp1, exp_band );
-#endif
- move32(); /* band scaled by Q_new + QSCALE */
- BASOP_SATURATE_WARNING_ON_EVS;
-
- test();
- IF( GE_16( i, min_band ) && LE_16( i, max_band ) )
- {
- IF( LT_32( band[i], e_min ) )
- {
- Ltmp1 = L_shl( e_min, 0 );
- exp_band = 0;
- move16();
- }
-
- wtmp = sub( exp_band, exp_etot );
- if ( wtmp > 0 )
- {
- etot = L_shr( etot, wtmp );
- }
- exp_etot = s_max( exp_etot, exp_band );
-
- etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
- }
-
- band_energies[i] = band[i];
- move32();
-
- band[i] = L_max( band[i], e_min );
- move32();
- }
+ shift = sub( *q_band, 39 );
+ *q_band = 39;
+ move16();
}
- /*-----------------------------------------------------------------*
- * Find the total energy over the input bandwidth
- *-----------------------------------------------------------------*/
-
-#ifdef BASOP_NOGLOB
- etot = L_add_sat( *LEtot, L_shl_sat( etot, sub( exp_etot, 4 ) ) );
-#else
- etot = L_add( *LEtot, L_shl( etot, sub( exp_etot, 4 ) ) );
-#endif
- *LEtot = etot;
- move32();
-
-
- return;
-}
-
-/* Merge with ivas_find_enr function once analy_sp is unified */
-static void ivas_find_enr1(
- Word16 data[], /* i : fft result */
- Word16 q_data, /* i : Q of fft result */
- Word32 band[], /* o : per band energy Q_new + QSCALE */
- Word32 *ptE, /* o : per bin energy for low frequencies Q_new + QSCALE-2 */
- Word32 *LEtot, /* o : total energy Q_new + QSCALE-1 */
- const Word16 min_band, /* i : minimum critical band Q0 */
- const Word16 max_band, /* i : maximum critical band Q0 */
- const Word16 Q_new, /* i : scaling factor Q0 */
- const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE */
- Word32 *Bin_E, /* o : Per bin energy Q_new + QSCALE-2 */
- Word16 BIN_FREQ_FX, /* i : Number of frequency bins */
- Word32 *band_energies /* o : per band energy without MODE2_E_MIN */
-)
-{
- Word16 i, cnt;
- Word16 freq;
- Word16 *ptR, *ptI;
- Word32 Ltmp;
- Word16 voic_band;
- Word32 etot;
- Word32 norm_val;
-
- norm_val = 131072 /* 4.0f / ( L_FFT * L_FFT ) in Q31 */;
- move32();
-
- ptR = &data[1]; /* first real */
- ptI = &data[L_FFT - 1]; /* first imaginary */
-
- voic_band = VOIC_BAND_8k;
- move16();
- assert( VOIC_BAND == VOIC_BAND_8k );
-
- /*-----------------------------------------------------------------*
- * For low frequency bins, save per bin energy for the use
- * in NS and find_tilt()
- *-----------------------------------------------------------------*/
+ min_ener = L_shl( E_MIN_FXQ31, sub( *q_band, Q31 ) ); // *q_band
freq = BIN_FREQ_FX;
move16();
FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */
{
- band[i] = 0;
- move32();
- cnt = 0;
+ band_ener = 0;
+ move64();
+ start_freq = freq;
move16();
- WHILE( freq <= crit_bands[i] )
+ WHILE( LE_32( freq, crit_bands_fx[i] ) )
{
- // *ptE = *ptR * *ptR + *ptI * *ptI; /* energy */
- Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) ); // 2 * Qfft
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Qfft + te_exp
- Ltmp = W_extract_h( te ); // 2 * Qfft + te_exp - 32
-
- // *ptE *= norm_val; /* normalization - corresponds to FFT normalization by 2/L_FFT */
- Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32
- *ptE = L_shl( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2
- move32();
+ /*
+ *ptE = *ptR * *ptR + *ptI * *ptI;
+
+ Overflow occurs in the above operation only when ptR and ptI values are equal to -32768.
+ In that case, energy value will be 2^31 (only one greater than max 32 bit value).
+ Hence, saturation is added.
+
+ *ptE *= norm_val;
+ norm_val = 4 / (256 * 256), As the value is in power's of 2, result can be obtained by increasing the Q factor
- *Bin_E++ = *ptE; // Q_new + QSCALE - 2
+ Q of energy = 2 * q_data + 14 = *q_ptE
+ */
+
+ *ptE = L_mac0_sat( L_mult0( *ptR, *ptR ), *ptI, *ptI ); // *q_ptE
move32();
- band[i] = L_add( band[i], *ptE++ ); // Q_new + QSCALE - 2
+
+ *Bin_E++ = *ptE; // *q_ptE
move32();
+
+ /*
+ BIN_FREQ_FX = BIN, cnt = ( ( crit_bands_fx[i] - start_freq ) / BIN ) + 1
+ band[i] += *ptE++;
+ band[i] *= inv_tbl[cnt]; // normalization per frequency bin
+ */
+ band_ener = W_mac_32_16( band_ener, *ptE, inv_tbl_fx[( ( crit_bands_fx[i] - start_freq ) / BIN ) + 1] ); // *q_band+16+shift
ptR++;
ptI--;
-
+ ptE++;
freq = add( freq, BIN_FREQ_FX );
- cnt = add( cnt, 1 );
}
- Ltmp = Mpy_32_16_1( band[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */ // Q_new + QSCALE - 2
- band[i] = L_shl( Ltmp, Q2 ); // Q_new + QSCALE
+ band[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band
move32();
- band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE
+ band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band
move32();
- if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE
+ if ( LT_32( band[i], min_ener ) ) // *q_band
{
- band[i] = e_min; // Q_new + QSCALE
+ band[i] = min_ener; // *q_band
move32();
}
}
@@ -1079,42 +814,50 @@ static void ivas_find_enr1(
FOR( i = voic_band; i < NB_BANDS; i++ )
{
- band[i] = 0;
- move32();
- cnt = 0;
+ band_ener = 0;
+ move64();
+ start_freq = freq;
move16();
- WHILE( freq <= crit_bands[i] )
+ WHILE( LE_32( freq, crit_bands_fx[i] ) )
{
- // *Bin_E = *ptR * *ptR + *ptI * *ptI;
- Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) ); // 2 * Qfft
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Qfft + te_exp
- Ltmp = W_extract_h( te ); // 2 * Qfft + te_exp - 32
-
- // *Bin_E *= norm_val;
- Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32
- *Bin_E = L_shl( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2
- move32();
+ /*
+ *Bin_E = *ptR * *ptR + *ptI * *ptI;
+
+ Overflow occurs in the below operation only when ptR and ptI values are equal to - 32768.
+ In that case, energy value will be 2 ^ 31 (only one greater than max 32 bit value).
+ Hence, saturation is added.
- band[i] = L_add( band[i], *Bin_E++ ); // Q_new + QSCALE - 2
+ *Bin_E *= norm_val;
+ norm_val = 4 / (256 * 256), As the value is in power's of 2, result can be obtained by increasing the Q factor
+
+ Q of energy = 2 * q_data + 14 = *q_ptE
+ */
+
+ *Bin_E = L_mac0_sat( L_mult0( *ptR, *ptR ), *ptI, *ptI ); // 2*q_data+14 = *q_ptE
move32();
+
+ /*
+ BIN_FREQ_FX = BIN, cnt = ( ( crit_bands_fx[i] - start_freq ) / BIN ) + 1
+ band[i] += *ptE++;
+ band[i] *= inv_tbl[cnt]; // normalization per frequency bin
+ */
+ band_ener = W_mac_32_16( band_ener, *Bin_E, inv_tbl_fx[( ( crit_bands_fx[i] - start_freq ) / BIN ) + 1] ); // *q_band+16+shift
ptR++;
ptI--;
+ Bin_E++;
freq = add( freq, BIN_FREQ_FX );
- cnt = add( cnt, 1 );
}
- Ltmp = Mpy_32_16_1( band[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */ // Q_new + QSCALE - 2
- band[i] = L_shl( Ltmp, Q2 ); // Q_new + QSCALE
+ band[i] = W_extract_h( W_shl_nosat( band_ener, sub( Q16, shift ) ) ); // *q_band
move32();
- band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE
+ band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band
move32();
- if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE
+ if ( LT_32( band[i], min_ener ) ) // *q_band
{
- band[i] = e_min; // Q_new + QSCALE
+ band[i] = min_ener; // *q_band
move32();
}
}
@@ -1124,14 +867,14 @@ static void ivas_find_enr1(
* Find the total energy over the input bandwidth
*-----------------------------------------------------------------*/
- etot = *LEtot;
- move32();
+ etot = *LEtot; // *q_band
+ move64();
FOR( i = min_band; i <= max_band; i++ )
{
- etot = L_add_sat( etot, L_shr( band[i], Q1 ) ); // Q_new + QSCALE - 1
+ etot = W_mac_32_32( etot, band[i], 1 ); // *q_band+1
}
- *LEtot = etot;
- move32();
+ *LEtot = etot; // *q_band+1
+ move64();
return;
}
@@ -1146,7 +889,7 @@ static void find_enr(
const Word16 Q_new2, /* i : scaling factor Q0 */
const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE */
Word32 *Bin_E, /* o : Per bin energy Q_new + QSCALE-2 */
- Word16 BIN_FREQ_FX, /* i : Number of frequency bins */
+ Word16 BIN_FREQ_FX, /* i : Number of frequency bins Q0 */
Word32 *band_energies /* o : per band energy without MODE2_E_MIN */
)
{
@@ -1161,7 +904,7 @@ static void find_enr(
Word32 *tmpptr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
- move16();
+ move32();
#endif
@@ -1197,11 +940,11 @@ static void find_enr(
move16();
FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */
{
- tmpptr = Bin_E;
+ tmpptr = Bin_E; /* Q_new + QSCALE - 2 */
move16();
Ltmp1 = L_deposit_l( 0 );
- FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
+ FOR( ; LE_32( freq, crit_bands_fx[i] ); freq += BIN_FREQ_FX )
{
/*ptE = *ptR * *ptR + *ptI * *ptI */ /* energy */
Ltmp = L_mult( *ptI, *ptI );
@@ -1211,11 +954,11 @@ static void find_enr(
/* normalization - corresponds to FFT normalization by 2/L_FFT */
BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
#ifdef BASOP_NOGLOB
- *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#else /* BASOP_NOGLOB */
+ *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */
+#else /* BASOP_NOGLOB */
*ptE = L_shl( Ltmp, diff_scaleM2 );
-#endif /* BASOP_NOGLOB */
- move32(); /* scaled by Q_new + QSCALE - 2 */
+#endif /* BASOP_NOGLOB */
+ move32(); /* scaled by Q_new + QSCALE - 2 */
BASOP_SATURATE_WARNING_ON_EVS;
/*band[i] += *ptE++;*/
*Bin_E = *ptE;
@@ -1234,18 +977,18 @@ static void find_enr(
/* band[i] /= cnt */ /* normalization per frequency bin */
cnt = (Word16) ( Bin_E - tmpptr );
shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
+ wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) ); /* Q15 */
+ Ltmp1 = L_deposit_l( wtmp ); /* Q15 */
exp_band = sub( exp_band, shift_to_norm );
exp_band = sub( diff_scaleP1, exp_band );
BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
#ifdef BASOP_NOGLOB
- band[i] = L_shl_o( Ltmp1, exp_band, &Overflow );
-#else /* BASOP_NOGLOB */
+ band[i] = L_shl_o( Ltmp1, exp_band, &Overflow ); /* Q15 + exp_band */
+#else /* BASOP_NOGLOB */
band[i] = L_shl( Ltmp1, exp_band );
-#endif /* BASOP_NOGLOB */
- move32(); /* band scaled by Q_new + QSCALE */
+#endif /* BASOP_NOGLOB */
+ move32(); /* band scaled by Q_new + QSCALE */
BASOP_SATURATE_WARNING_ON_EVS;
test();
@@ -1267,7 +1010,7 @@ static void find_enr(
etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
}
- band_energies[i] = band[i];
+ band_energies[i] = band[i]; /* Q_new + QSCALE */
move32();
band[i] = L_max( band[i], e_min );
@@ -1286,7 +1029,7 @@ static void find_enr(
move16();
Ltmp1 = L_deposit_l( 0 );
- FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
+ FOR( ; LE_32( freq, crit_bands_fx[i] ); freq += BIN_FREQ_FX )
{
/* *ptE = *ptR * *ptR + *ptI * *ptI */
Ltmp = L_mult( *ptI, *ptI );
@@ -1296,11 +1039,11 @@ static void find_enr(
/* normalization - corresponds to FFT normalization by 2/L_FFT */
BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
#ifdef BASOP_NOGLOB
- *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#else /* BASOP_NOGLOB */
+ *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE */
+#else /* BASOP_NOGLOB */
*Bin_E = L_shl( Ltmp, diff_scaleM2 );
-#endif /* BASOP_NOGLOB */
- move32(); /* scaled by Q_new + QSCALE - 2 */
+#endif /* BASOP_NOGLOB */
+ move32(); /* scaled by Q_new + QSCALE - 2 */
BASOP_SATURATE_WARNING_ON_EVS;
Bin_E++;
Ltmp1 = L_add( Ltmp1, Ltmp );
@@ -1372,396 +1115,3 @@ static void find_enr(
return;
}
-
-#ifdef IVAS_FLOAT_FIXED1
-/*------------------------------------------------------------------------*
- * ivas_find_enr()
- *
- * find input signal energy for each critical band and first 74 LF bins
- * The energy is normalized by the number of frequency bins in a channel
- *------------------------------------------------------------------------*/
-
-static void ivas_find_enr(
- Word16 data[], /* i : fft result */
- Word32 band[], /* o : per band energy Q_new + QSCALE */
- Word32 *ptE, /* o : per bin energy for low frequencies Q_new + QSCALE-2 */
- Word32 *LEtot, /* o : total energy Q_new + QSCALE */
- const Word16 min_band, /* i : minimum critical band Q0 */
- const Word16 max_band, /* i : maximum critical band Q0 */
- const Word16 Q_new2, /* i : scaling factor Q0 */
- const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE */
- Word32 *Bin_E, /* o : Per bin energy Q_new + QSCALE-2 */
- Word16 BIN_FREQ_FX, /* i : Number of frequency bins */
- Word32 *band_energies /* o : per band energy without MODE2_E_MIN */
-)
-{
- Word16 i, cnt, shift_to_norm;
- Word16 freq, wtmp;
- Word16 *ptR, *ptI, diff_scaleP1, diff_scaleM2;
- Word16 exp_band;
- Word32 Ltmp, Ltmp1;
- Word16 voic_band;
- Word32 etot;
- Word16 exp_etot;
- Word32 *tmpptr;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
-#endif
-
-
- ptR = &data[1]; /* first real */
- ptI = &data[L_FFT - 1]; /* first imaginary */
-
- /*-----------------------------------------------------------------------------------*
- * Scaling needed by band and ptE output
- * Wants all energies scaled by Q_new + QSCALE to maintain maximum
- * precision on bckr noise in clean speech
- * First shift left by Q_new + QSCALE than shift right by 2*Q_new-1
- * shift left (Q_new + QSCALE - (2*Q_new -1))
- * shift left (QSCALE - Q_new + 1) == shift left by (QSCALE+1) - Q_new
- *-----------------------------------------------------------------------------------*/
-
- diff_scaleP1 = sub( QSCALE + 1 + 1, Q_new2 );
- diff_scaleM2 = sub( QSCALE + 1 - 2, Q_new2 );
-
- voic_band = VOIC_BAND_8k;
- move16();
- assert( VOIC_BAND == VOIC_BAND_8k );
-
- etot = L_deposit_l( 0 );
- exp_etot = 0;
- move16();
-
- /*-----------------------------------------------------------------*
- * For low frequency bins, save per bin energy for the use
- * in NS and find_tilt()
- *-----------------------------------------------------------------*/
-
- freq = BIN_FREQ_FX;
- move16();
- FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */
- {
- tmpptr = Bin_E;
- move16();
- Ltmp1 = L_deposit_l( 0 );
-
- FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
- {
- /*ptE = *ptR * *ptR + *ptI * *ptI */ /* energy */
- Ltmp = L_mult( *ptI, *ptI );
- Ltmp = L_mac( Ltmp, *ptR, *ptR );
-
- /* *ptE *= 4.0 / (L_FFT*L_FFT) */
- /* normalization - corresponds to FFT normalization by 2/L_FFT */
- BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
-#ifdef BASOP_NOGLOB
- *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#else /* BASOP_NOGLOB */
- *ptE = L_shl( Ltmp, diff_scaleM2 );
-#endif /* BASOP_NOGLOB */
- move32(); /* scaled by Q_new + QSCALE - 2 */
- BASOP_SATURATE_WARNING_ON_EVS;
- /*band[i] += *ptE++;*/
- *Bin_E = *ptE;
- move32();
- Bin_E++;
- Ltmp1 = L_add_sat( Ltmp1, Ltmp );
-
- ptE++;
- ptR++;
- ptI--;
- }
-
- exp_band = sub( norm_l( Ltmp1 ), 1 ); /* divide by 2 to ensure band < cnt */
- wtmp = round_fx( L_shl( Ltmp1, exp_band ) );
-
- /* band[i] /= cnt */ /* normalization per frequency bin */
- cnt = (Word16) ( Bin_E - tmpptr );
- shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
-
- exp_band = sub( exp_band, shift_to_norm );
- exp_band = sub( diff_scaleP1, exp_band );
- BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
-#ifdef BASOP_NOGLOB
- band[i] = L_shl_o( Ltmp1, exp_band, &Overflow );
-#else /* BASOP_NOGLOB */
- band[i] = L_shl( Ltmp1, exp_band );
-#endif /* BASOP_NOGLOB */
- move32(); /* band scaled by Q_new + QSCALE */
- BASOP_SATURATE_WARNING_ON_EVS;
-
- test();
- IF( GE_16( i, min_band ) && LE_16( i, max_band ) )
- {
- IF( LT_32( band[i], e_min ) )
- {
- Ltmp1 = L_shl( e_min, 0 );
- exp_band = 0;
- move16();
- }
-
- wtmp = sub( exp_band, exp_etot );
- if ( wtmp > 0 )
- {
- etot = L_shr( etot, wtmp );
- }
- exp_etot = s_max( exp_etot, exp_band );
- etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
- }
-
- band_energies[i] = band[i];
- move32();
-
- band[i] = L_max( band[i], e_min );
- move32();
- }
-
- IF( EQ_16( BIN_FREQ_FX, 50 ) )
- {
- /*-----------------------------------------------------------------*
- * Continue compute the E per critical band for high frequencies
- *-----------------------------------------------------------------*/
-
- FOR( i = voic_band; i < NB_BANDS; i++ )
- {
- tmpptr = Bin_E;
- move16();
- Ltmp1 = L_deposit_l( 0 );
-
- FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
- {
- /* *ptE = *ptR * *ptR + *ptI * *ptI */
- Ltmp = L_mult( *ptI, *ptI );
- Ltmp = L_mac_sat( Ltmp, *ptR, *ptR );
-
- /* *ptE *= 4.0 / (L_FFT*L_FFT) */
- /* normalization - corresponds to FFT normalization by 2/L_FFT */
- BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
-#ifdef BASOP_NOGLOB
- *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#else /* BASOP_NOGLOB */
- *Bin_E = L_shl( Ltmp, diff_scaleM2 );
-#endif /* BASOP_NOGLOB */
- move32(); /* scaled by Q_new + QSCALE - 2 */
- BASOP_SATURATE_WARNING_ON_EVS;
- Bin_E++;
- Ltmp1 = L_add_sat( Ltmp1, Ltmp );
-
- ptR++;
- ptI--;
- }
-
- exp_band = sub( norm_l( Ltmp1 ), 1 ); /* divide by 2 to ensure band < cnt */
- wtmp = round_fx( L_shl( Ltmp1, exp_band ) );
-
- /* band[i] /= cnt */ /* normalization per frequency bin */
- cnt = (Word16) ( Bin_E - tmpptr );
- shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
-
- exp_band = sub( exp_band, shift_to_norm );
- exp_band = sub( diff_scaleP1, exp_band );
- BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
-#ifdef BASOP_NOGLOB
- band[i] = L_shl_o( Ltmp1, exp_band, &Overflow );
-#else /* BASOP_NOGLOB */
- band[i] = L_shl( Ltmp1, exp_band );
-#endif
- move32(); /* band scaled by Q_new + QSCALE */
- BASOP_SATURATE_WARNING_ON_EVS;
-
- test();
- IF( GE_16( i, min_band ) && LE_16( i, max_band ) )
- {
- IF( LT_32( band[i], e_min ) )
- {
- Ltmp1 = L_shl( e_min, 0 );
- exp_band = 0;
- move16();
- }
-
- wtmp = sub( exp_band, exp_etot );
- if ( wtmp > 0 )
- {
- etot = L_shr( etot, wtmp );
- }
- exp_etot = s_max( exp_etot, exp_band );
-
- etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
- }
-
- band_energies[i] = band[i];
- move32();
-
- band[i] = L_max( band[i], e_min );
- move32();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Find the total energy over the input bandwidth
- *-----------------------------------------------------------------*/
-
-#ifdef BASOP_NOGLOB
- etot = L_add_sat( *LEtot, L_shl_sat( etot, sub( exp_etot, 4 ) ) );
-#else
- etot = L_add( *LEtot, L_shl( etot, sub( exp_etot, 4 ) ) );
-#endif
- *LEtot = etot;
- move32();
-
-
- return;
-}
-#endif
-#ifdef IVAS_CODE_CPE
-/*------------------------------------------------------------------------*
- * find_enr_dft()
- *
- * find input signal energy for each critical band using the DFT buffers
- *------------------------------------------------------------------------*/
-
-static void find_enr_dft(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const int32_t input_Fs, /* i : input sampling rate */
- float DFT_past_DMX[],
- float band[], /* o : per band energy */
- float *ptE, /* o : per bin energy for low frequencies */
- float *Etot, /* i/o: total energy */
- const int16_t min_band, /* i : minimum critical band */
- const int16_t max_band, /* i : maximum critical band */
- float *Bin_E, /* o : Per bin energy */
- float *band_ener /* o : per band energy without E_MIN */
-)
-{
- int16_t i, cnt;
- float freq, tmp;
- const float *ptR, *ptI;
- float norm_val;
- int16_t bin_cnt = 0;
-
- float c, s;
- /* One window - 40ms*12.8kHz = 512 samples */
- float c_1 = cosf( PI2 / STEREO_DFT_N_12k8_ENC );
- float s_1 = sinf( PI2 / STEREO_DFT_N_12k8_ENC );
- float g_1 = 1.f + 0.68f * 0.68f;
- float g_2 = 2 * 0.68f;
- float g;
- float scaleWin;
-
- float BinE[STEREO_DFT_N_12k8_ENC / 2]; /* NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 158 */
- float bin_freq = input_Fs / (float) hCPE->hStereoDft->NFFT; /* adaptive frequency bin width */
-
- scaleWin = 1 / ( 2 * hCPE->hStereoDft->win_ana_energy );
- scaleWin *= (float) BIN / bin_freq;
- norm_val = scaleWin * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT );
-
- ptR = &DFT_past_DMX[2]; /* first real */
- ptI = &DFT_past_DMX[3]; /* first imaginary */
- c = c_1;
- s = s_1;
-
- /* for low frequency bins, save per bin energy for the use in find_tilt() */
- freq = bin_freq;
- for ( i = 0; i < NB_BANDS - 1; i++ ) /* up to maximum allowed voiced critical band */
- {
- band[i] = 0.0f;
- cnt = 0;
-
- /* bins up to crit_band 17 (<= 3700 Hz):
- * bin_cnt old (bin_width 50 Hz): 74 (74 * FRAMES_PER_SEC = 3700)
- * bin_cnt new (bin_width 40 Hz): 92 (92 * 40 = 3680)
- */
-
- while ( freq <= crit_bands[i] )
- {
- BinE[bin_cnt] = *ptR * *ptR + *ptI * *ptI; /* energy */
- g = g_1 - g_2 * c;
- tmp = c * c_1 - s * s_1;
- s = s * c_1 + c * s_1;
- c = tmp;
- BinE[bin_cnt] *= norm_val * g; /* normalization - corresponds to FFT normalization by 2/L_FFT */
- band[i] += BinE[bin_cnt];
- ptR += 2;
- ptI += 2;
-
- freq += bin_freq;
- cnt++;
- bin_cnt++;
- }
-
- band[i] *= inv_tbl[cnt]; /* normalization per frequency bin */
-
- band_ener[i] = band[i]; /* per band energy without E_MIN */
-
- if ( band[i] < E_MIN )
- {
- band[i] = E_MIN;
- }
- }
-
- /* continue computing the energy per critical band for higher frequencies */
-
- /* old version, FFT 256 @ SR12.8 (-> bin_width = 50 Hz):
- NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 127 = L_FFT/2-1*/
-
- /* new version: DFT (1200/800/400) @ input SR (48/32/16) (-> bin_width = 40 Hz):
- *
- */
- /* NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 158 */
- /* NB_BANDS = 21 (= 7700Hz) = highest band available for SR 16 -> bin_cnt = 192 */
- /* NB_BANDS = 24 (= 15500Hz) = highest band available for SR 32 -> bin_cnt = 387 */
- /* NB_BANDS = 24 (= 15500Hz) = highest band available for SR 48 -> bin_cnt = 387 */
-
- for ( ; i < NB_BANDS; i++ )
- {
- band[i] = 0.0f;
- cnt = 0;
- while ( freq < 6399.0f )
- {
- BinE[bin_cnt] = *ptR * *ptR + *ptI * *ptI;
- g = g_1 - g_2 * c;
- BinE[bin_cnt] *= norm_val * g;
- band[i] += BinE[bin_cnt];
- ptR += 2;
- ptI += 2;
-
- freq += bin_freq;
- cnt++;
- bin_cnt++;
- }
-
- band[i] *= inv_tbl[cnt]; /* normalization per frequency bin */
-
- band_ener[i] = band[i]; /* per band energy without E_MIN */
-
- if ( band[i] < E_MIN )
- {
- band[i] = E_MIN;
- }
- }
-
- /* put bin energies from BinE into Bin_E[L_FFT/2-1] (interpolate 40 Hz bin values to fit into 50 Hz bins) */
- /* Last value of Bin_E is handled outside this function*/
- assert( bin_cnt == ( STEREO_DFT_N_12k8_ENC / 2 - 1 ) );
- BinE[STEREO_DFT_N_12k8_ENC / 2 - 1] = BinE[STEREO_DFT_N_12k8_ENC / 2 - 2];
- lerp( BinE, Bin_E, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2 );
- mvr2r( Bin_E, ptE, VOIC_BINS );
-
-
- /* find the total log energy */
- tmp = *Etot;
- for ( i = min_band; i <= max_band; i++ )
- {
- tmp += band[i];
- }
-
- *Etot = tmp;
-
- return;
-}
-
-#endif
diff --git a/lib_enc/ari_enc.c b/lib_enc/ari_enc.c
index 733e3e72a10274c2ce2627330e37b3aa5e46c0cf..cda9d3c8270527bb9da7675dff645599620770bd 100644
--- a/lib_enc/ari_enc.c
+++ b/lib_enc/ari_enc.c
@@ -80,6 +80,9 @@ void ari_start_encoding_14bits(
s->low = 0;
s->high = ari_q4new;
s->bits_to_follow = 0;
+ move32();
+ move32();
+ move32();
return;
}
@@ -98,18 +101,21 @@ void ari_start_encoding_14bits_ivas_fx(
}
/*---------------------------------------------------------------
- * ari_done_encoding_14bits()
+ * ari_done_encoding_14bits_ivas_fx()
*
* Finish ArCo encoding
*-------------------------------------------------------------*/
-Word16 ari_done_encoding_14bits( Word16 *ptr, Word16 bp, Tastat *s )
+Word16 ari_done_encoding_14bits_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Tastat *s )
{
Word16 bit;
bit = 0;
move16();
- if ( GE_32( s->low, ari_q1new ) )
+ IF( GE_32( s->low, ari_q1new ) )
{
bit = s_xor( bit, 1 );
}
@@ -118,17 +124,18 @@ Word16 ari_done_encoding_14bits( Word16 *ptr, Word16 bp, Tastat *s )
/*---------------------------------------------------------------
- * ari_encode_14bits_ext()
+ * ari_encode_14bits_ext_ivas_fx()
*
* encode function for extended proba tables: less branches needed for coding
*
*-------------------------------------------------------------*/
-Word16 ari_encode_14bits_ext(
- Word16 *ptr,
- Word16 bp,
+Word16 ari_encode_14bits_ext_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
Tastat *s,
- Word32 symbol,
- UWord16 const *cum_freq )
+ Word32 symbol, /* Q0 */
+ UWord16 const *cum_freq /* Q0 */
+)
{
Word32 low;
Word32 high;
@@ -140,7 +147,7 @@ Word16 ari_encode_14bits_ext(
high = L_add( s->high, 0 );
low = L_add( s->low, 0 );
- range = L_add( L_sub( high, low ), 1 );
+ range = L_add( L_sub( high, low ), 1 ); /* Q0 */
L_temp1 = L_shl( range, 15 - stat_bitsnew /*both are constants*/ );
Mpy_32_16_ss( L_temp1, cum_freq[symbol + 1], &L_temp2, &temp );
@@ -148,23 +155,23 @@ Word16 ari_encode_14bits_ext(
{
Mpy_32_16_ss( L_temp1, cum_freq[symbol], &range, &temp );
}
- high = L_sub( L_add( low, range ), 1 );
- low = L_add( low, L_temp2 );
+ high = L_sub( L_add( low, range ), 1 ); /* Q0 */
+ low = L_add( low, L_temp2 ); /* Q0 */
assert( s->bits_to_follow <= MAX_16 );
- bits_to_follow = extract_l( s->bits_to_follow );
+ bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */
FOR( i = 0; i < 0x7FFF; i++ )
{
IF( LT_32( high, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
bits_to_follow = 0;
move16();
}
ELSE IF( GE_32( low, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
bits_to_follow = 0;
move16();
low = L_sub( low, ari_q2new );
@@ -177,8 +184,8 @@ Word16 ari_encode_14bits_ext(
{
/* Output an opposite bit */
/* later if in middle half. */
- bits_to_follow = add( bits_to_follow, 1 );
- low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
+ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
+ low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
high = L_sub( high, ari_q1new );
}
ELSE
@@ -186,15 +193,15 @@ Word16 ari_encode_14bits_ext(
BREAK; /* Otherwise exit loop. */
}
}
- low = L_add( low, low );
- high = L_add( L_add( high, high ), 1 ); /* Scale up code range. */
+ low = L_add( low, low ); /* Q0 */
+ high = L_add( L_add( high, high ), 1 ); /* Scale up code range. Q0*/
}
- s->low = low;
+ s->low = low; /* Q0 */
move32();
- s->high = high;
+ s->high = high; /* Q0 */
move32();
- s->bits_to_follow = bits_to_follow;
+ s->bits_to_follow = bits_to_follow; /* Q0 */
move32();
return bp;
@@ -202,39 +209,41 @@ Word16 ari_encode_14bits_ext(
/*------------------------------------------------------------------------
- * Function: ari_encode_14bits_range()
+ * Function: ari_encode_14bits_high_low_fx()
*
- * Encode an cumulative frequency interval.
*-------------------------------------------------------------------------*/
-/*------------------------------------------------------------------------
- * Function: ari_encode_14bits_sign()
- *
- * Encode a sign with equal probabilities.
- *-------------------------------------------------------------------------*/
-static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, Tastat *s, Word32 high, Word32 low )
+
+static Word16 ari_encode_14bits_high_low_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ Tastat *s,
+ Word32 high, /* Q0 */
+ Word32 low /* Q0 */
+)
{
Word16 bits_to_follow, tmp;
- bits_to_follow = extract_l( s->bits_to_follow );
+ bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */
move16();
/* while there are more than 16 bits left */
- tmp = sub( 16, bits );
+ tmp = sub( 16, bits ); /* Q0 */
WHILE( add( add( bp, bits_to_follow ), tmp ) < 0 )
{
IF( LE_32( high, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
bits_to_follow = 0;
move16();
}
ELSE IF( GE_32( low, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
bits_to_follow = 0;
move16();
- low = L_sub( low, ari_q2new );
- high = L_sub( high, ari_q2new ); /* Subtract offset to top. */
+ low = L_sub( low, ari_q2new ); /* Q0 */
+ high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/
}
ELSE
{
@@ -243,9 +252,9 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
{
/* Output an opposite bit */
/* later if in middle half. */
- bits_to_follow = add( bits_to_follow, 1 );
- low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
- high = L_sub( high, ari_q1new );
+ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
+ low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/
+ high = L_sub( high, ari_q1new ); /* Q0 */
}
ELSE
{
@@ -257,35 +266,47 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
high = L_add( high, high ); /* Scale up code range. */
}
- s->low = low;
+ s->low = low; /* Q0 */
move32();
- s->high = L_sub( high, 1 );
+ s->high = L_sub( high, 1 ); /* Q0 */
move32();
- s->bits_to_follow = bits_to_follow;
+ s->bits_to_follow = bits_to_follow; /* Q0 */
move16();
return bp;
}
-Word16 ari_encode_14bits_sign( Word16 *ptr, Word16 bp, Word32 bits, Tastat *s, Word16 sign )
+
+/*------------------------------------------------------------------------
+ * Function: ari_encode_14bits_sign_ivas_fx()
+ *
+ * Encode a sign with equal probabilities.
+ *-------------------------------------------------------------------------*/
+Word16 ari_encode_14bits_sign_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word32 bits, /* Q0 */
+ Tastat *s,
+ Word16 sign /* Q0 */
+)
{
Word32 low, high, range;
Word32 L_tmp;
high = L_add( s->high, 1 );
low = L_add( s->low, 0 );
- range = L_sub( high, low );
+ range = L_sub( high, low ); /* Q0 */
L_tmp = L_shr( range, 1 );
if ( sign != 0 )
{
- high = L_add( low, L_tmp );
+ high = L_add( low, L_tmp ); /* Q0 */
}
if ( sign == 0 )
{
- low = L_add( low, L_tmp );
+ low = L_add( low, L_tmp ); /* Q0 */
}
- return ari_encode_14bits_high_low( ptr, bp, extract_l( bits ), s, high, low );
+ return ari_encode_14bits_high_low_fx( ptr, bp, extract_l( bits ), s, high, low );
}
/*------------------------------------------------------------------------
diff --git a/lib_enc/ari_enc_fx.c b/lib_enc/ari_enc_fx.c
index 872b6a1f3b6acb78d4db2987de223500ef45b48f..0ef053edd75ef58434abdc6fab944cb0851964de 100644
--- a/lib_enc/ari_enc_fx.c
+++ b/lib_enc/ari_enc_fx.c
@@ -56,19 +56,19 @@ void ari_start_encoding_14bits_fx( TastatEnc *s )
* Returns: new bit-stream position
*-------------------------------------------------------------*/
Word16 ari_put_bit_plus_follow(
- Word16 ptr[], /* o: bit-stream */
- Word16 bp, /* i: bit-stream position */
- Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' */
- Word16 bit /* i: bit to send */
+ Word16 ptr[], /* o: bit-stream Q0*/
+ Word16 bp, /* i: bit-stream position Q0*/
+ Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' Q0*/
+ Word16 bit /* i: bit to send Q0*/
)
{
assert( bit == 0 || bit == 1 );
- ptr[bp++] = bit; /* send initially a zero or one */
+ ptr[bp++] = bit; /* send initially a zero or one Q0*/
move16();
bit = s_xor( bit, 1 ); /* invert bit to send */
FOR( ; bits_to_follow > 0; bits_to_follow-- )
{
- ptr[bp++] = bit; /* send inverted bit */
+ ptr[bp++] = bit; /* send inverted bit Q0*/
move16();
}
return bp;
@@ -84,7 +84,10 @@ Word16 ari_put_bit_plus_follow(
*
* \return bit consumption
* ------------------------------------------------------------ - */
-Word16 ari_done_encoding_14bits_fx( Word16 *ptr, Word16 bp, TastatEnc *s )
+Word16 ari_done_encoding_14bits_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ TastatEnc *s )
{
Word16 bit;
@@ -113,11 +116,12 @@ Word16 ari_done_encoding_14bits_fx( Word16 *ptr, Word16 bp, TastatEnc *s )
* \return bit consumption
* ------------------------------------------------------------ - */
Word16 ari_encode_14bits_ext_fx(
- Word16 *ptr,
- Word16 bp,
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
TastatEnc *s,
- Word32 symbol,
- UWord16 const *cum_freq )
+ Word32 symbol, /* Q0 */
+ UWord16 const *cum_freq /* Q0 */
+)
{
Word32 low;
Word32 high;
@@ -129,7 +133,7 @@ Word16 ari_encode_14bits_ext_fx(
high = L_add( s->high, 0 );
low = L_add( s->low, 0 );
- range = L_sub( high, low );
+ range = L_sub( high, low ); /* Q0 */
L_temp1 = L_shl( range, 15 - stat_bitsnew /*both are constants*/ );
Mpy_32_16_ss( L_temp1, cum_freq[symbol + 1], &L_temp2, &temp );
@@ -137,27 +141,27 @@ Word16 ari_encode_14bits_ext_fx(
{
Mpy_32_16_ss( L_temp1, cum_freq[symbol], &range, &temp );
}
- high = L_add( low, range );
- low = L_add( low, L_temp2 );
+ high = L_add( low, range ); /* Q0 */
+ low = L_add( low, L_temp2 ); /* Q0 */
- bits_to_follow = s->value;
+ bits_to_follow = s->value; /* Q0 */
move16();
FOR( i = 0; i < 0x7FFF; i++ )
{
IF( LE_32( high, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
bits_to_follow = 0;
move16();
}
ELSE IF( GE_32( low, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
bits_to_follow = 0;
move16();
- low = L_sub( low, ari_q2new );
- high = L_sub( high, ari_q2new ); /* Subtract offset to top. */
+ low = L_sub( low, ari_q2new ); /* Q0 */
+ high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/
}
ELSE
{
@@ -166,9 +170,9 @@ Word16 ari_encode_14bits_ext_fx(
{
/* Output an opposite bit */
/* later if in middle half. */
- bits_to_follow = add( bits_to_follow, 1 );
- low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
- high = L_sub( high, ari_q1new );
+ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
+ low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/
+ high = L_sub( high, ari_q1new ); /* Q0 */
}
ELSE
{
@@ -176,15 +180,15 @@ Word16 ari_encode_14bits_ext_fx(
}
}
- low = L_add( low, low );
- high = L_add( high, high ); /* Scale up code range. */
+ low = L_add( low, low ); /* Q0 */
+ high = L_add( high, high ); /* Scale up code range. Q0*/
}
- s->low = low;
+ s->low = low; /* Q0 */
move32();
- s->high = high;
+ s->high = high; /* Q0 */
move32();
- s->value = bits_to_follow;
+ s->value = bits_to_follow; /* Q0 */
move16();
return bp;
@@ -204,7 +208,14 @@ Word16 ari_encode_overflow_fx( TastatEnc *s )
*
*
*-------------------------------------------------------------------------*/
-static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word32 high, Word32 low )
+static Word16 ari_encode_14bits_high_low(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word32 high, /* Q0 */
+ Word32 low /* Q0 */
+)
{
Word16 bits_to_follow, tmp;
@@ -212,22 +223,22 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
move16();
/* while there are more than 16 bits left */
- tmp = sub( 16, bits );
+ tmp = sub( 16, bits ); /* Q0 */
WHILE( add( add( bp, bits_to_follow ), tmp ) < 0 )
{
IF( LE_32( high, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
bits_to_follow = 0;
move16();
}
ELSE IF( GE_32( low, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
bits_to_follow = 0;
move16();
- low = L_sub( low, ari_q2new );
- high = L_sub( high, ari_q2new ); /* Subtract offset to top. */
+ low = L_sub( low, ari_q2new ); /* Q0 */
+ high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/
}
ELSE
{
@@ -236,9 +247,9 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
{
/* Output an opposite bit */
/* later if in middle half. */
- bits_to_follow = add( bits_to_follow, 1 );
- low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
- high = L_sub( high, ari_q1new );
+ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
+ low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/
+ high = L_sub( high, ari_q1new ); /* Q0 */
}
ELSE
{
@@ -246,15 +257,15 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
}
}
- low = L_add( low, low );
- high = L_add( high, high ); /* Scale up code range. */
+ low = L_add( low, low ); /* Q0 */
+ high = L_add( high, high ); /* Scale up code range. Q0*/
}
- s->low = low;
+ s->low = low; /* Q0 */
move32();
- s->high = high;
+ s->high = high; /* Q0 */
move32();
- s->value = bits_to_follow;
+ s->value = bits_to_follow; /* Q0 */
move16();
return bp;
@@ -266,14 +277,21 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
* Encode an cumulative frequency interval.
*-------------------------------------------------------------------------*/
-Word16 ari_encode_14bits_range_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 cum_freq_low, Word16 cum_freq_high )
+Word16 ari_encode_14bits_range_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word16 cum_freq_low, /* Q0 */
+ Word16 cum_freq_high /* Q0 */
+)
{
Word32 low, high, range;
- range = L_sub( s->high, s->low );
+ range = L_sub( s->high, s->low ); /* Q0 */
- high = L_add( s->low, mul_sbc_14bits( range, cum_freq_high ) );
- low = L_add( s->low, mul_sbc_14bits( range, cum_freq_low ) );
+ high = L_add( s->low, mul_sbc_14bits( range, cum_freq_high ) ); /* Q0 */
+ low = L_add( s->low, mul_sbc_14bits( range, cum_freq_low ) ); /* Q0 */
return ari_encode_14bits_high_low( ptr, bp, bits, s, high, low );
}
@@ -284,23 +302,29 @@ Word16 ari_encode_14bits_range_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEn
*
* Encode a sign with equal probabilities.
*-------------------------------------------------------------------------*/
-Word16 ari_encode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 sign )
+Word16 ari_encode_14bits_sign_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word16 sign /* Q0 */
+)
{
Word32 low, high, range;
Word32 L_tmp;
high = L_add( s->high, 0 );
low = L_add( s->low, 0 );
- range = L_sub( high, low );
+ range = L_sub( high, low ); /* Q0 */
L_tmp = L_shr( range, 1 );
if ( sign != 0 )
{
- high = L_add( low, L_tmp );
+ high = L_add( low, L_tmp ); /* Q0 */
}
if ( sign == 0 )
{
- low = L_add( low, L_tmp );
+ low = L_add( low, L_tmp ); /* Q0 */
}
return ari_encode_14bits_high_low( ptr, bp, bits, s, high, low );
@@ -311,25 +335,29 @@ Word16 ari_encode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc
*
* Finish up encoding in CBR mode.
*-------------------------------------------------------------------------*/
-Word16 ari_done_cbr_encoding_14bits_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s )
+Word16 ari_done_cbr_encoding_14bits_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s )
{
Word16 high, tmp, k;
- tmp = sub( bits, 16 );
+ tmp = sub( bits, 16 ); /* Q0 */
WHILE( GT_16( sub( tmp, bp ), s->value ) )
{
- bp = ari_encode_14bits_sign_fx( ptr, bp, bits, s, 0 );
+ bp = ari_encode_14bits_sign_fx( ptr, bp, bits, s, 0 ); /* Q0 */
}
- high = extract_l( L_sub( s->high, 1 ) );
+ high = extract_l( L_sub( s->high, 1 ) ); /* Q0 */
- bp = ari_put_bit_plus_follow( ptr, bp, s->value, lshr( high, 15 ) );
+ bp = ari_put_bit_plus_follow( ptr, bp, s->value, lshr( high, 15 ) ); /* Q0 */
high = lshl( high, 1 );
tmp = s_min( 15, sub( bits, bp ) );
FOR( k = 0; k < tmp; ++k )
{
- ptr[bp++] = lshr( high, 15 );
+ ptr[bp++] = lshr( high, 15 ); /* Q0 */
move16();
high = lshl( high, 1 );
}
diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c
index 3e6519a3b5fece3f0303e3cece17091315d6df23..66b53bc6de886a29c6408454101990cdea9d85ac 100644
--- a/lib_enc/ari_hm_enc_fx.c
+++ b/lib_enc/ari_hm_enc_fx.c
@@ -87,7 +87,7 @@ Word16 EncodeIndex_ivas_fx(
*
*-------------------------------------------------------------------*/
static Word16 SearchPeriodicityIndex_Single(
- const Word16 AbsMdct3[],
+ const Word16 AbsMdct3[], // Qx
const Word16 NumToConsider,
const Word32 Lag,
const Word16 FractionalResolution )
@@ -131,7 +131,7 @@ static Word16 SearchPeriodicityIndex_Single(
*
*-------------------------------------------------------------------*/
static void SearchPeriodicityIndex_Range(
- const Word16 AbsMdct3[],
+ const Word16 AbsMdct3[], // Qx
const Word16 NumToConsider,
const Word16 Lo,
const Word16 Hi,
@@ -139,7 +139,8 @@ static void SearchPeriodicityIndex_Range(
const Word16 Adj,
const Word16 Spacing,
Word16 *PeriodicityIndex,
- Word16 *Score )
+ Word16 *Score // Q0
+)
{
Word16 Index, BestIndex;
Word16 CurrentScore, BestScore;
@@ -194,7 +195,7 @@ static void SearchPeriodicityIndex_Range(
B = add( BestIndex, shr( Spacing, 1 ) );
- FOR( Index = add( BestIndex, 1 ); Index <= B; ++Index )
+ FOR( Index = BestIndex + 1; Index <= B; ++Index )
{
CurrentScore = SearchPeriodicityIndex_Single(
AbsMdct3,
@@ -225,7 +226,7 @@ Word16 SearchPeriodicityIndex_fx(
Word16 NumToConsider, /* i : Number of coefficients */
const Word16 TargetBits, /* i : Target bit budget (excl. Done flag) */
const Word16 LtpPitchLag, /* i : TCX-LTP pitch */
- const Word16 LtpGain, /* i : LTP gain */
+ const Word16 LtpGain, /* i : LTP gain Q15 */
Word16 *RelativeScore /* o : Energy concentration factor (2Q13) */
)
{
@@ -244,11 +245,12 @@ Word16 SearchPeriodicityIndex_fx(
Word32 tmp32;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Debug init (not instrumented) */
C = -3000;
-
+ move32();
PeriodicityIndex = 0;
move16();
Score = -1;
@@ -264,18 +266,22 @@ Word16 SearchPeriodicityIndex_fx(
{
C = L_shl( L_abs( Mdct[i + 1] ), s );
AbsMdct3[i] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
A = L_shl( L_abs( Mdct[i + 2] ), s );
AbsMdct3[i + 1] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
B = L_shl( L_abs( Mdct[i + 3] ), s );
AbsMdct3[i + 2] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
}
IF( LT_16( i, sub( NumToConsider, 1 ) ) )
{
C = L_shl( L_abs( Mdct[i + 1] ), s );
AbsMdct3[i] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
}
IF( LT_16( i, sub( NumToConsider, 2 ) ) )
@@ -283,6 +289,7 @@ Word16 SearchPeriodicityIndex_fx(
A = L_shl( L_abs( Mdct[i + 2] ), s );
assert( C != -3000 );
AbsMdct3[i + 1] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
}
AbsTotal = L_deposit_l( 0 );
@@ -479,8 +486,8 @@ Word16 SearchPeriodicityIndex_fx(
*-------------------------------------------------------------------*/
static void PeakFilter(
- const Word32 x[], /* i : absolute spectrum */
- Word32 y[], /* O : filtered absolute spectrum, must not alias x[] */
+ const Word32 x[], /* i : absolute spectrum Qx */
+ Word32 y[], /* O : filtered absolute spectrum, must not alias x[] Q(x-4)*/
const Word16 L_frame /* i : number of spectral lines */
)
{
@@ -491,7 +498,7 @@ static void PeakFilter(
flen = shr( L_frame, 4 );
/* m = kPeakElevationThreshold / (float)(2*flen + 1); */
- m = shr( div_s( 8 /*kPeakElevationThreshold Q3*/, add( shl( flen, 1 ), 1 ) ), 3 );
+ m = shr( div_s( 8 /*kPeakElevationThreshold Q3*/, add( shl( flen, 1 ), 1 ) ), 3 ); // Q15
a = L_deposit_l( 0 );
FOR( i = 0; i < flen; ++i )
@@ -501,14 +508,14 @@ static void PeakFilter(
FOR( i = 0; i < flen; ++i )
{
- y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) );
+ y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) ); // Q(x-4)
move32();
a = L_add( a, L_shr( x[i + flen], 4 ) );
}
sub( 0, 0 );
FOR( ; i < L_frame - flen; ++i )
{
- y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) );
+ y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) ); // Q(x-4)
move32();
a = L_sub( a, L_shr( x[i - flen], 4 ) );
a = L_add( a, L_shr( x[i + flen], 4 ) );
@@ -516,7 +523,7 @@ static void PeakFilter(
FOR( ; i < L_frame; ++i )
{
- y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) );
+ y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) ); // Q(x-4)
move32();
a = L_sub( a, L_shr( x[i - flen], 4 ) );
}
@@ -598,7 +605,7 @@ static Word32 tcx_hm_get_re(
*-------------------------------------------------------------------*/
static void tcx_hm_quantize_gain(
- const Word32 x[], /* i: absolute spectrum Q31-e */
+ const Word32 x[], /* i: absolute spectrum Q31-x_e */
const Word16 *x_e, /* i: absolute spectrum exponent Q0 */
const Word32 env[], /* i: envelope Q16 */
const Word32 lag, /* i: pitch lag Q0 */
@@ -645,6 +652,7 @@ static void tcx_hm_quantize_gain(
FOR( i = 0; i < L_frame; ++i )
{
x16[i] = extract_h( L_shl( x[i], s_x ) );
+ move16();
}
be = tcx_hm_get_re( x16, *gain, lag, fract_res, p, env, L_frame );
@@ -698,7 +706,8 @@ static void tcx_hm_quantize_gain(
/* Minimum selection, pe is Q14 */
IF( LT_32( L_shl( Mpy_32_16_1( e, pe ), 1 ), be ) )
{
- be = L_add( e, 0 );
+ be = e;
+ move32();
*gain_idx = g;
move16();
*gain = qGains[s][g];
diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c
index 6b137f31e1b30c7a61fc9386be150537360c3a62..40c1c6b7b73893959e64e400f7325072f4534f47 100644
--- a/lib_enc/arith_coder_enc_fx.c
+++ b/lib_enc/arith_coder_enc_fx.c
@@ -50,6 +50,7 @@ static Word16 tcx_arith_estimate_scale(
Word32 L_tmp, accu;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -195,19 +196,21 @@ static Word16 tcx_arith_find_max_scale( /* Q15-e *
Heap heap = { { { 0, 0 } }, 0 }; /* silence a compiler warning */
Word16 tmpi1, tmpi2;
const Word32 limit = -325614240l /*-9.70406052784f Q25*/; /* = ln(1/16384): log of smallest allowed probability */
-
+ move32();
/* Find the top most offending lines according to probability estimates */
FOR( i = 0; i < kMaxNumHeapElems; i++ )
{
heap.mElem[i].mIndex = 0;
move16();
heap.mElem[i].mScore = L_deposit_l( 0 );
+ move32();
}
tmp = add( shl( kMaxNumHeapElems, 1 ), 1 );
FOR( ; i < tmp; i++ )
{
heap.mElem[i].mScore = L_deposit_h( 0x7FFF );
+ move32();
}
FOR( k = 0; k < L_frame; k++ )
@@ -374,6 +377,7 @@ static Word16 tcx_arith_rateloop(
Word32 tmp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -414,13 +418,14 @@ static Word16 tcx_arith_rateloop(
L_tmp = L_mac( 0x7FFFFFFF, exps[k], (Word16) 0x8000 ); /* Q31 */
L_tmp = L_negate( BASOP_Util_Log2( L_tmp ) ); /* Q25 */
fixed_bits[0][k] = round_fx( L_tmp ); /* Q9 */
-
+ move16();
/* fixed_bits[1][k] = 1 - s*0.5f*LOG2_E - log2f(1 - (exps[k]/65536.0f) * (exps[k]/65536.0f)); */
L_tmp = L_msu( 0x7FFFFFFF, exps[k], exps[k] ); /* Q31 */
L_tmp = BASOP_Util_Log2( L_tmp ); /* Q25 */
L_tmp = L_sub( 1 << 25, L_tmp );
L_tmp = L_sub( L_tmp, L_shl( L_mult0( mult_r( envelope[k], LOG2_E ), 1 << 10 ), envelope_e ) );
fixed_bits[1][k] = round_fx( L_tmp ); /* Q9 */
+ move16();
}
tmp2 = L_msu0( L_sub( max_complexity, 48 ), L_frame, 11 );
@@ -708,6 +713,8 @@ void tcx_arith_encode_envelope_fx(
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
Flag Carry = 0;
+ move32();
+ move32();
#endif
assert( L_spec <= N_MAX_ARI );
@@ -730,6 +737,7 @@ void tcx_arith_encode_envelope_fx(
FOR( k = 0; k < L_spec; k++ )
{
signs[k] = extract_l( L_lshr( spectrum[k], 31 ) );
+ move16();
if ( spectrum[k] < 0 )
{
spectrum[k] = L_abs( spectrum[k] );
@@ -767,6 +775,7 @@ void tcx_arith_encode_envelope_fx(
FOR( k = 0; k < L_spec; k++ )
{
exponents[k] = round_fx( expfp( envelope[k], tmp ) );
+ move16();
}
scale = tcx_arith_rateloop( spectrum, *spectrum_e, L_spec, envelope, envelope_e, exponents, target_bits, deadzone, deadzone_flags, &( hTcxEnc->tcx_target_bits_fac ), &scale_e );
@@ -782,10 +791,12 @@ void tcx_arith_encode_envelope_fx(
{
/* quantise using dead-zone */
q_spectrum[k] = extract_h( L_add( L_shl( Mpy_32_16_1( spectrum[k], scale ), tmp ), L_tmp ) );
+ move16();
}
/* Final encoding */
*arith_bits = tcx_arith_encode( q_spectrum, signs, kMax, L_spec, exponents, target_bits, prm );
+ move16();
/* Multiply back the signs */
L_tmp2 = L_deposit_l( 0 );
@@ -810,4 +821,5 @@ void tcx_arith_encode_envelope_fx(
/* noise filling seed */
*nf_seed = extract_l( L_tmp2 );
+ move16();
}
diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c
index 094d3fd78340282c0991914c8ee18a9216c1a0b1..c5a10198185b879db16dbafdbf9168682e7e173f 100644
--- a/lib_enc/avq_cod_fx.c
+++ b/lib_enc/avq_cod_fx.c
@@ -16,7 +16,7 @@
* Local prototypes
*-------------------------------------------------------------------*/
static void wrte_cv( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i_ind, const Word16 kv_ind, UWord16 I, Word16 kv[], Word16 *bits );
-static void wrte_cv_ivas( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i_ind, const Word16 kv_ind, UWord16 I, Word16 kv[], Word16 *bits );
+static void wrte_cv_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i_ind, const Word16 kv_ind, UWord16 I, Word16 kv[], Word16 *bits );
/*-------------------------------------------------------------------*
* Function AVQ_cod() *
@@ -25,7 +25,7 @@ static void wrte_cv_ivas( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i
*-------------------------------------------------------------------*/
void AVQ_cod_fx( /* o: comfort noise gain factor */
- const Word16 xri[], /* i: vector to quantize */
+ const Word16 xri[], /* i: vector to quantize Qx*/
Word16 xriq[], /* o: quantized normalized vector (assuming the bit budget is enough) */
const Word16 NB_BITS, /* i: number of allocated bits */
const Word16 Nsv, /* i: number of subvectors (lg=Nsv*8) */
@@ -72,7 +72,8 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
Ltmp = L_mac( Ltmp, f_ebits, 1 );
Ltmp = L_add( L_shl( Ltmp, 6 ), L_shl( Ltmp, 4 ) ); /* Mult by 5.0 and then by 16 (To go to Q4). Do it using Mult by 80 (which is 64+16) */
ebits[l] = round_fx( Ltmp ); /*Q4*/
- tot_est_bits = add( tot_est_bits, shr( ebits[l], 4 ) );
+ move16();
+ tot_est_bits = add( tot_est_bits, shr( ebits[l], 4 ) ); // Q0
}
test();
test();
@@ -89,12 +90,12 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
/* estimate gain according to number of bits allowed */
/* start at the middle (offset range = 0 to 255.75) Q6 */
- fac = 2048;
+ fac = 2048; // 128.0f in Q4
move16();
offset = 0;
move16();
- Ltmp = L_mult( 31130, sub( NB_BITS, Nsv ) ); /* (1810 - 8 - 1152/8)*.95*/
+ Ltmp = L_mult( 31130 /*.95f in Q15*/, sub( NB_BITS, Nsv ) ); /* (1810 - 8 - 1152/8)*.95*/
nbits_max = round_fx( L_shl( Ltmp, 4 ) );
/* tree search with 10 iterations : offset with step of 0.25 bits (0.3 dB) */
@@ -115,7 +116,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
{
offset = sub( offset, fac );
}
- fac = mult( fac, 16384 );
+ fac = mult( fac, 16384 /*.5 in Q15*/ );
}
Ltmp = L_shr( L_mult( offset, 13107 ), 6 ); /* offset((2^21)/160 */
@@ -141,7 +142,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
l_8 = shl( l, 3 );
FOR( i = 0; i < 8; i++ )
{
- x1[i] = L_shl( L_mult( xri[l_8 + i], gain_inv ), e_tmp );
+ x1[i] = L_shl( L_mult( xri[l_8 + i], gain_inv ), e_tmp ); // Q15
move32();
}
@@ -149,7 +150,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
FOR( i = 0; i < 8; i++ )
{
- xriq[l_8 + i] = c[i];
+ xriq[l_8 + i] = c[i]; // Q0
move16();
}
}
@@ -157,7 +158,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
/* round_fx bit allocations and save */
FOR( i = 0; i < Nsv; i++ )
{
- xriq[( Nsv * 8 ) + i] = shl( ebits[i], 7 - 4 );
+ xriq[( Nsv * 8 ) + i] = shl( ebits[i], 7 - 4 ); // Q0
move16();
}
@@ -229,8 +230,8 @@ void AVQ_encmux_fx(
/* sort subvectors by estimated bit allocations in decreasing order */
t = kv;
- move16(); /* reuse vector to save memory */
- move16(); /*ptr init*/
+ /* reuse vector to save memory */
+ /*ptr init*/
FOR( i = 0; i < Nsv; i++ )
{
t[i] = xriq[8 * Nsv + i];
@@ -325,11 +326,12 @@ void AVQ_encmux_fx(
move16();
move16();
move16();
+ move16();
if ( EQ_16( avq_bit_sFlag, 2 ) )
{
j = add( i, 1 );
}
- WHILE( LT_16( i, Nsvm1 ) )
+ WHILE( i < Nsvm1 )
{
svOrder[i] = j;
move16();
@@ -414,7 +416,7 @@ void AVQ_encmux_fx(
} /* for */
/* Bit Saving Solution */
test();
- IF( avq_bit_sFlag > 0 && bits > 8 )
+ IF( avq_bit_sFlag > 0 && GT_16( bits, 8 ) )
{
// PMT("code not validated yet")
bitsMod = s_and( bits, 4 /*bits%5*/ );
@@ -453,7 +455,7 @@ void AVQ_encmux_fx(
bitsMod = 0;
move16();
}
- ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && nullVec > 3 && nullVec < 6 ) || ( bitsMod == 4 && nullVec == 5 ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/
+ ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && GT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/
{
overflow = 0;
move16();
@@ -627,8 +629,8 @@ void AVQ_encmux_ivas_fx(
/* sort subvectors by estimated bit allocations in decreasing order */
t = kv;
- move16(); /* reuse vector to save memory */
- move16(); /*ptr init*/
+ /* reuse vector to save memory */
+ /*ptr init*/
FOR( i = 0; i < Nsv; i++ )
{
t[i] = xriq[8 * Nsv + i];
@@ -723,6 +725,7 @@ void AVQ_encmux_ivas_fx(
move16();
move16();
move16();
+ move16();
if ( EQ_16( avq_bit_sFlag, 2 ) )
{
j = add( i, 1 );
@@ -814,17 +817,18 @@ void AVQ_encmux_ivas_fx(
bits = sub( bits, 1 );
}
- wrte_cv_ivas( hBstr, nq[k], i_ind, kv_ind, I[k], &kv[k * 8], &bits );
+ wrte_cv_ivas_fx( hBstr, nq[k], i_ind, kv_ind, I[k], &kv[k * 8], &bits );
}
} /* for */
/* Bit Saving Solution */
test();
- IF( avq_bit_sFlag > 0 && bits > 8 )
+ IF( avq_bit_sFlag > 0 && GT_16( bits, 8 ) )
{
// PMT("code not validated yet")
// bitsMod = bits%5;
bitsMod = bits;
- WHILE( GE_16( bitsMod, 5 ) )
+ move16();
+ WHILE( bitsMod >= 5 )
{
bitsMod = sub( bitsMod, 5 );
}
@@ -837,13 +841,13 @@ void AVQ_encmux_ivas_fx(
move16();
FOR( j = i; j < Nsv - 1; j++ )
{
- if ( nq[svOrder[j]] == 0 )
+ IF( nq[svOrder[j]] == 0 )
{
nullVec = add( nullVec, 1 );
}
}
/*nq_est = bits / 5;*/
- nq_est = mult( bits, 6554 );
+ nq_est = mult( bits, 6554 /*1/5 in Q15*/ );
assert( nq_est == bits / 5 );
test();
@@ -856,7 +860,7 @@ void AVQ_encmux_ivas_fx(
test();
test();
test();
- test();
+
IF( ( bitsMod > 0 || ( EQ_16( nullVec, 4 ) && EQ_16( nq_est, 5 ) ) ) && NE_16( bitsMod, 4 ) && GE_16( add( bits, nullVec ), add( add( shl( nq_est, 2 ), nq_est ), 4 ) ) /*5 * nq_est + 4*/ && nq[svOrder[Nsvm2]] == 0 ) /* detect need for dummy bits */
{
dummy_bits = sub( 5, bitsMod );
@@ -864,12 +868,12 @@ void AVQ_encmux_ivas_fx(
bitsMod = 0;
move16();
}
- ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && nullVec > 3 && nullVec < 6 ) || ( bitsMod == 4 && nullVec == 5 ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/
+ ELSE IF( GT_16( nq_est, 4 ) && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && LT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/
{
overflow = 0;
move16();
tmp = add( bitsMod, nullVec );
- WHILE( GE_16( tmp, 5 ) )
+ WHILE( tmp >= 5 )
{
tmp = sub( tmp, 5 );
}
@@ -896,18 +900,18 @@ void AVQ_encmux_ivas_fx(
}
bits = add( bits, overflow ); /*add fake bit */
unused_bits = sub( bits, add( shl( nq[i], 2 ), nq[i] ) );
- if ( nq[i] == 0 ) /*no bit savings*/
+ IF( nq[i] == 0 ) /*no bit savings*/
{
unused_bits = sub( unused_bits, 1 ); /*Stop Bit*/
}
/*unused_bits_idx = (int16_t)unused_bits / 5;*/
IF( unused_bits >= 0 )
{
- unused_bits_idx = mult( unused_bits, 6554 );
+ unused_bits_idx = mult( unused_bits, 6554 /*1/5 in Q15*/ );
}
ELSE
{
- unused_bits_idx = negate( mult( negate( unused_bits ), 6554 ) );
+ unused_bits_idx = negate( mult( negate( unused_bits ), 6554 /*1/5 in Q15*/ ) );
}
assert( unused_bits_idx == unused_bits / 5 );
unusedbitsFlag = 0;
@@ -951,7 +955,7 @@ void AVQ_encmux_ivas_fx(
/*Compute AVQ code book number from unused Bits */
bit_tmp = add( unusedbitsFlag, unused_bits_idx );
/*nq_est = (int16_t)ceil(0.2f * (bits - 5 * (unusedbitsFlag + unused_bits_idx)));*/
- nq_est = mult( 6554, sub( bits, add( shl( bit_tmp, 2 ), bit_tmp ) ) );
+ nq_est = mult( 6554 /*.2 in Q15*/, sub( bits, add( shl( bit_tmp, 2 ), bit_tmp ) ) );
assert( (int16_t) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est );
if ( EQ_16( nq_est, 1 ) )
@@ -963,7 +967,7 @@ void AVQ_encmux_ivas_fx(
bits = sub( bits, j );
- if ( nq_est != 0 )
+ IF( nq_est != 0 )
{
bits = sub( bits, 1 );
}
@@ -971,11 +975,11 @@ void AVQ_encmux_ivas_fx(
move16();
/* write codebook indices (rank I and event. Voronoi index kv) */
- wrte_cv_ivas( hBstr, nq[i], i_ind, kv_ind, I[i], &kv[i * 8], &bits );
+ wrte_cv_ivas_fx( hBstr, nq[i], i_ind, kv_ind, I[i], &kv[i * 8], &bits );
bits = sub( bits, dummy_bits );
- if ( NE_16( bitsMod, 4 ) )
+ IF( NE_16( bitsMod, 4 ) )
{
bits = add( bits, bitsMod );
}
@@ -1141,7 +1145,7 @@ static void wrte_cv(
return;
}
-static void wrte_cv_ivas(
+static void wrte_cv_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 nq, /* i : AVQ nq index */
const Word16 i_ind, /* i : Base Bitstream index */
diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c
index df52213c2bdc3d56ff7cbb9302ceaae8b3d78479..e43fa6bc6354df3ea507a887d5e635d903dbf21e 100644
--- a/lib_enc/bass_psfilter_enc_fx.c
+++ b/lib_enc/bass_psfilter_enc_fx.c
@@ -38,6 +38,7 @@ Word16 bass_pf_enc_fx(
Word32 ener2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -69,10 +70,12 @@ Word16 bass_pf_enc_fx(
move16();
s3 = s4 = 0; /* initialization of s3 and s4 to suppress compiler warnings;
s3 and s4 get initialized for i_subfr == 0 */
-
+ move16();
+ move16();
nrg1 = nrg2 = 0; /* initialization fo nrg1 and nrg2 to suppress compiler warnings;
nrg1 and nrg1 get initialized for i_subfr == 0 */
-
+ move32();
+ move32();
FOR( i_subfr = 0; i_subfr < l_frame; i_subfr += l_subfr )
{
T = T_sf[sf];
@@ -218,7 +221,7 @@ Word16 bass_pf_enc_fx(
}
mem_bpf->lp_error_ener = L_add( Mpy_32_16_1( L_sub( mem_bpf->lp_error_ener, ener2 ), 32440 /*0.99f Q15*/ ), ener2 ); /* 15Q16 */
-
+ move32();
st = add( st, 6 );
ener2 = L_sub( mem_bpf->lp_error_ener, L_deposit_h( sub( 31, st ) ) );
IF( ener2 >= 0 )
@@ -282,6 +285,7 @@ Word16 bass_pf_enc_fx(
tmp32 = L_mult0( tmp16, syn[i + i_subfr] );
tmp32 = L_msu0( tmp32, tmp16, syn[i + i_subfr - T] );
noise_in[i] = round_fx( L_shl( tmp32, s2 ) ); /* Q0+s2 */
+ move16();
#ifdef BASOP_NOGLOB
error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/
@@ -298,6 +302,7 @@ Word16 bass_pf_enc_fx(
set16_fx( noise_in, 0, l_subfr );
set16_fx( error_in, 0, l_subfr );
s2 = s2_old;
+ move16();
}
tmp16 = shl( l_filt, 1 );
diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c
index f572f4be37c41448fc990d70d53adac98cefa0e8..6d2df38cdc103623c8e4da59ad49a61738b8fe81 100644
--- a/lib_enc/bw_detect_fx.c
+++ b/lib_enc/bw_detect_fx.c
@@ -40,12 +40,12 @@
void bw_detect_fx(
Encoder_State *st, /* i/o: Encoder State */
- const Word16 signal_in[], /* i : input signal */
- Word16 *spectrum, /* i : MDCT spectrum */
+ const Word16 signal_in[], /* i : input signal */
+ Word16 *spectrum, /* i : MDCT spectrum */
const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */
const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */
const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const int16_t mct_on /* i : flag MCT mode */
+ const Word16 mct_on /* i : flag MCT mode */
)
{
Word16 Q_dct;
@@ -63,6 +63,7 @@ void bw_detect_fx(
Word32 cldfb_bin[9];
Word16 cldfb_bin_Exp[9];
Word16 cldfb_bin_width = 4;
+ move16();
const Word32 *pt32;
Word32 max_NB32, max_WB32, max_SWB32, max_FB32, mean_NB32, mean_WB32, mean_SWB32, mean_FB32; /* Q11*/ /* we need Word32 for the new cldfb energy vectors */
Word16 bwd_count_wider_bw;
@@ -74,6 +75,7 @@ void bw_detect_fx(
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
bwd_count_wider_bw = BWD_COUNT_WIDER_BW;
@@ -120,14 +122,15 @@ void bw_detect_fx(
move32(); /* result: Q31 */
}
- cldfb_bin[0] = Mpy_32_16_1( cldfb_bin[0], ScalFac );
- move32(); /* Q31 */
+ cldfb_bin[0] = Mpy_32_16_1( cldfb_bin[0], ScalFac ); // Q(31-cldfb_bin_Exp)
+ move32(); /* Q31 */
cldfb_bin_Exp[0] = add( cldfb_bin_Exp[0], CLDFBscalingFactor_EXP );
move16();
if ( cldfb_bin[i] == 0 )
{
cldfb_bin[i] = L_deposit_l( 1 );
+ move32();
}
L_tmp = BASOP_Util_Log2( cldfb_bin[0] ); /*(log2(660423549*2^(-31))/64)*2^31*/
#ifdef BASOP_NOGLOB
@@ -153,7 +156,7 @@ void bw_detect_fx(
}
FOR( i = 1; i <= 2; i++ )
{
- cldfb_bin[i] = Mpy_32_16_1( cldfb_bin[i], ScalFac );
+ cldfb_bin[i] = Mpy_32_16_1( cldfb_bin[i], ScalFac ); // Q(31-(cldfv_bin_Exp+CLDFBscalingFactor_EXP))
move32();
cldfb_bin_Exp[i] = add( cldfb_bin_Exp[i], CLDFBscalingFactor_EXP );
move16();
@@ -161,6 +164,7 @@ void bw_detect_fx(
if ( cldfb_bin[i] == 0 )
{
cldfb_bin[i] = L_deposit_l( 1 );
+ move32();
}
L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/
L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */
@@ -191,7 +195,7 @@ void bw_detect_fx(
}
FOR( i = 3; i <= 6; i++ )
{
- cldfb_bin[i] = Mpy_32_16_1( cldfb_bin[i], ScalFac );
+ cldfb_bin[i] = Mpy_32_16_1( cldfb_bin[i], ScalFac ); // Q(31-(cldfv_bin_Exp+CLDFBscalingFactor_EXP))
move32();
cldfb_bin_Exp[i] = add( cldfb_bin_Exp[i], CLDFBscalingFactor_EXP );
move16();
@@ -199,6 +203,7 @@ void bw_detect_fx(
if ( cldfb_bin[i] == 0 )
{
cldfb_bin[i] = L_deposit_l( 1 );
+ move32();
}
L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/
L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */
@@ -231,6 +236,7 @@ void bw_detect_fx(
if ( cldfb_bin[i] == 0 )
{
cldfb_bin[i] = L_deposit_l( 1 );
+ move32();
}
L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/
L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */
@@ -305,13 +311,14 @@ void bw_detect_fx(
#else /* BASOP_NOGLOB */
spect[i] = round_fx( L_shr( spect32[i], Q_dct ) );
#endif
+ move16();
}
Q_dct = -2;
move16();
}
ELSE
{
- Word16 l_frame = (int16_t) ( st->input_Fs / FRAMES_PER_SEC );
+ Word16 l_frame = extract_l( st->input_Fs / FRAMES_PER_SEC );
IF( EQ_16( st->core, TCX_10_CORE ) )
{
l_frame = shr( l_frame, 1 );
@@ -359,6 +366,7 @@ void bw_detect_fx(
e_tmp = sub( sub( 30, e_tmp ), Q_dct );
L_tmp = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
spect_bin[i] = round_fx( L_shl( L_tmp, 11 ) ); /* Q11 */
+ move16();
}
}
}
@@ -527,23 +535,25 @@ void bw_detect_fx(
/*if( localVAD || st->lp_noise > 30 )*/
test();
- IF( st->localVAD || GT_16( st->lp_noise_fx, 7680 ) )
+ IF( st->localVAD || GT_16( st->lp_noise_fx, 7680 /*30 in Q8*/ ) )
{
/*st->lt_mean_NB_fx = ALPHA_BWD * st->lt_mean_NB_fx + (1-ALPHA_BWD) * mean_NB;*/
L_tmp = L_mult( ALPHA_BWD_FX, st->lt_mean_NB_fx ); /* Q15 * Q11 -> Q27 */
L_tmp = L_mac( L_tmp, 32768 - ALPHA_BWD_FX, mean_NB ); /* Q15 * Q11) -> L_mac(Q27, Q27) -> Q27*/
st->lt_mean_NB_fx = round_fx( L_tmp ); /* Q11 (27-16) */
+ move16();
/*st->lt_mean_WB_fx = ALPHA_BWD * st->lt_mean_WB_fx + (1-ALPHA_BWD) * mean_WB;*/
L_tmp = L_mult( ALPHA_BWD_FX, st->lt_mean_WB_fx );
L_tmp = L_mac( L_tmp, 32768 - ALPHA_BWD_FX, mean_WB );
st->lt_mean_WB_fx = round_fx( L_tmp );
+ move16();
/*st->lt_mean_SWB_fx = ALPHA_BWD * st->lt_mean_SWB_fx + (1-ALPHA_BWD) * mean_SWB;*/
L_tmp = L_mult( ALPHA_BWD_FX, st->lt_mean_SWB_fx );
L_tmp = L_mac( L_tmp, 32768 - ALPHA_BWD_FX, mean_SWB );
st->lt_mean_SWB_fx = round_fx( L_tmp );
-
+ move16();
IF( enerBuffer != NULL )
{
@@ -565,6 +575,7 @@ void bw_detect_fx(
IF( GT_32( L_tmp, L_tmp1 ) ) /* Q24 */
{
st->count_WB = add( st->count_WB, 1 );
+ move16();
}
}
ELSE
@@ -576,6 +587,7 @@ void bw_detect_fx(
IF( L_tmp < 0 )
{
st->count_WB = sub( st->count_WB, 1 );
+ move16();
}
}
@@ -603,6 +615,7 @@ void bw_detect_fx(
IF( L_tmp1 > 0 )
{
st->count_SWB = add( st->count_SWB, 1 );
+ move16();
}
}
ELSE
@@ -614,6 +627,7 @@ void bw_detect_fx(
IF( L_tmp1 < 0 )
{
st->count_SWB = sub( st->count_SWB, 1 );
+ move16();
}
}
/*if( max_FB > BWD_LT_THRESH_FX * st->lt_mean_SWB_fx && 0.83f * max_SWB > BWD_LT_THRESH_FX * st->lt_mean_WB_fx && max_WB > BWD_LT_THRESH_FX * st->lt_mean_NB_fx )*/
@@ -645,6 +659,7 @@ void bw_detect_fx(
IF( L_tmp1 > 0 )
{
st->count_FB = add( st->count_FB, 1 );
+ move16();
}
}
ELSE
@@ -656,6 +671,7 @@ void bw_detect_fx(
IF( L_tmp1 < 0 )
{
st->count_FB = sub( st->count_FB, 1 );
+ move16();
}
}
}
@@ -666,9 +682,10 @@ void bw_detect_fx(
{
/*if( 2 * max_WB > max_NB )*/
L_tmp = L_mult( 8192, max_WB ); /* 2.0 in Q12 x Q11 -> Q24*/
- if ( L_msu( L_tmp, max_NB, 4096 ) > 0 )
+ IF( L_msu( L_tmp, max_NB, 4096 ) > 0 )
{
st->count_WB = add( st->count_WB, 1 );
+ move16();
}
}
ELSE
@@ -678,22 +695,23 @@ void bw_detect_fx(
L_tmp = L_msu( L_tmp, mean_NB, 4096 );
test();
test();
- if ( L_tmp < 0 && !( EQ_16( mean_WB, -1 ) && EQ_16( mean_NB, -1 ) ) )
+ IF( L_tmp < 0 && !( EQ_16( mean_WB, -1 ) && EQ_16( mean_NB, -1 ) ) )
{
st->count_WB = sub( st->count_WB, 1 );
+ move16();
}
}
- test();
/*if( max_SWB > BWD_LT_THRESH * st->lt_mean_WB_fx && max_WB > BWD_LT_THRESH * st->lt_mean_NB_fx )*/
test();
IF( L_msu( L_deposit_h( max_SWB ), BWD_LT_THRESH_FX, st->lt_mean_WB_fx ) > 0 && L_msu( L_deposit_h( max_WB ), BWD_LT_THRESH_FX, st->lt_mean_NB_fx ) > 0 )
{
/*if( 2 * max_SWB > max_WB )*/
L_tmp = L_mult( 8192, max_SWB ); /* 2.0 in Q12 x Q11 -> Q24*/
- if ( L_msu( L_tmp, max_WB, 4096 ) > 0 )
+ IF( L_msu( L_tmp, max_WB, 4096 ) > 0 )
{
st->count_SWB = add( st->count_SWB, 1 );
+ move16();
}
}
ELSE
@@ -703,9 +721,10 @@ void bw_detect_fx(
L_tmp = L_msu( L_tmp, mean_WB, 4096 );
test();
test();
- if ( L_tmp < 0 && !( EQ_16( mean_SWB, -1 ) && EQ_16( mean_WB, -1 ) ) )
+ IF( L_tmp < 0 && !( EQ_16( mean_SWB, -1 ) && EQ_16( mean_WB, -1 ) ) )
{
st->count_SWB = sub( st->count_SWB, 1 );
+ move16();
}
}
@@ -716,9 +735,10 @@ void bw_detect_fx(
{
/*if( 2 * max_FB > max_SWB )*/
L_tmp = L_mult( 8192, max_FB ); /* 2.0 in Q12 x Q11 -> Q24*/
- if ( L_msu( L_tmp, max_SWB, 4096 ) > 0 )
+ IF( L_msu( L_tmp, max_SWB, 4096 ) > 0 )
{
st->count_FB = add( st->count_FB, 1 );
+ move16();
}
}
ELSE
@@ -727,9 +747,10 @@ void bw_detect_fx(
L_tmp = L_mult( 12288, mean_FB ); /* 3.0 in Q12 x Q11 -> Q24*/
test();
test();
- if ( L_msu( L_tmp, mean_SWB, 4096 ) < 0 && !( EQ_16( mean_FB, -1 ) && EQ_16( mean_SWB, -1 ) ) )
+ IF( L_msu( L_tmp, mean_SWB, 4096 ) < 0 && !( EQ_16( mean_FB, -1 ) && EQ_16( mean_SWB, -1 ) ) )
{
st->count_FB = sub( st->count_FB, 1 );
+ move16();
}
}
}
@@ -887,12 +908,12 @@ void bw_detect_fx(
/* verify that maximum encoded bandwidth (specified on the command line) is not exceeded */
- IF( GT_16( st->input_bwidth, st->max_bwidth ) )
+ if ( GT_16( st->input_bwidth, st->max_bwidth ) )
{
st->input_bwidth = st->max_bwidth;
move16();
}
- IF( EQ_16( st->element_mode, EVS_MONO ) )
+ IF( st->element_mode == EVS_MONO )
{
set_bw_fx( -1, -1, st, st->codec_mode );
}
@@ -1022,7 +1043,7 @@ void set_bw_fx(
BREAK;
}
}
- if ( EQ_16( n, FRAME_SIZE_NB ) )
+ IF( EQ_16( n, FRAME_SIZE_NB ) )
{
assert( !"Bitrate not supported: not part of EVS" );
}
diff --git a/lib_enc/cng_enc.c b/lib_enc/cng_enc.c
index dde1a574ad1dba8585f581d8e9750bd9cf162a0b..ea957da8c51d3508ab6446de4df77ebbc2867ff9 100644
--- a/lib_enc/cng_enc.c
+++ b/lib_enc/cng_enc.c
@@ -47,13 +47,6 @@
#include "prot_fx.h"
#include "ivas_rom_com_fx.h"
-/*---------------------------------------------------------------------*
- * Local constants
- *---------------------------------------------------------------------*/
-
-#define MAX_DELTA_CNG 1
-#define ENER_MID_DEAD_ZONE 0.01 /* dead-zone width around mid points between quantization levels */
-
/*---------------------------------------------------------------------*
* Local function prototypes
*---------------------------------------------------------------------*/
@@ -169,10 +162,10 @@ static void shb_CNG_encod_ivas_fx(
Word16 tmp, tmp1, tmp2, scale, exp1, exp2, ener_mid_dec_thr_e;
tmp = BASOP_Util_Divide1616_Scale( st->hTdCngEnc->last_idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0
- scale = scale + ( 15 - 0 );
+ scale = add( scale, ( 15 - 0 ) );
tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) );
tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp1 );
- exp1 = exp1 + ( scale - 0 );
+ exp1 = add( exp1, ( scale - 0 ) );
ener_mid_dec_thr_fx = shr( mult( tmp1, 9864 ), 1 ); // exp = exp
@@ -346,7 +339,7 @@ static Word16 shb_DTX_ivas_fx(
move16();
move16();
}
- IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 ) ) // 12 in Q8
+ IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12 in Q8*/ ) )
{
allow_cn_step = 1;
move16();
@@ -355,7 +348,7 @@ static Word16 shb_DTX_ivas_fx(
/* Also allow step if shb energy has dropped 12 dB */
test();
test();
- IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GT_16( sub( hTdCngEnc->mov_shb_cng_ener_fx, log_shb_ener_fx ), 3072 ) )
+ IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GT_16( sub( hTdCngEnc->mov_shb_cng_ener_fx, log_shb_ener_fx ), 3072 /*12 in Q8*/ ) )
{
allow_cn_step = 1;
move16();
@@ -365,16 +358,20 @@ static Word16 shb_DTX_ivas_fx(
{
hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx;
hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx;
+ move16();
+ move16();
}
ELSE
{
tmp = sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ); /* Q8 */
- tmp = mult( tmp, 29491 ); /* Q8 */
+ tmp = mult( tmp, 29491 /* .9f in Q15*/ ); /* Q8 */
hTdCngEnc->mov_wb_cng_ener_fx = add( hTdCngEnc->mov_wb_cng_ener_fx, tmp ); /* Q8 */
+ move16();
tmp = sub( log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx );
- tmp = mult( tmp, 8192 ); /* Q8 */
+ tmp = mult( tmp, 8192 /* .25f in Q15*/ ); /* Q8 */
hTdCngEnc->mov_shb_cng_ener_fx = add( hTdCngEnc->mov_shb_cng_ener_fx, tmp ); /* Q8 */
+ move16();
}
hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 );
@@ -383,10 +380,11 @@ static Word16 shb_DTX_ivas_fx(
move16();
move16();
- test();
- test();
IF( EQ_32( st->core_brate, SID_2k40 ) )
{
+ test();
+ test();
+ test();
IF( st->hDtxEnc->first_CNG == 0 )
{
update = 1;
@@ -443,6 +441,5 @@ static Word16 shb_DTX_ivas_fx(
move16();
}
- test();
return ( update );
}
diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c
index 44ce22cc9d629151ac2cb0a67bfd0e5c19d4b3ff..e2c81a8d11eb1f4bc9eb3d13c786d5a02d515829 100644
--- a/lib_enc/cng_enc_fx.c
+++ b/lib_enc/cng_enc_fx.c
@@ -50,10 +50,14 @@ void CNG_enc_fx(
Word16 m1;
Word16 res[L_FRAME16k];
Word16 step_inv = 0;
+ move16();
Word16 hi, lo;
Word16 maxl = 0;
+ move16();
Word16 num_bits = 0;
+ move16();
Word16 step = 0;
+ move16();
Word16 *pt_res;
const Word16 *pt_sp;
Word16 enr;
@@ -64,9 +68,11 @@ void CNG_enc_fx(
Word32 L_tmp1;
Word16 exp;
Word16 m = 0;
+ move16();
Word16 tmp[HO_HIST_SIZE * M];
Word16 ll, s_ptr;
Word16 tmpv, maxv, scale, att = 1;
+ move16();
Word16 lsf_tmp[M];
Word32 C[M];
Word32 max_val[2];
@@ -77,9 +83,12 @@ void CNG_enc_fx(
Word16 max_dev;
Word16 dist;
Word16 max_idx1[2] = { 0, 0 };
+ move16();
+ move16();
Word16 fft_io[L_FRAME16k];
Word16 *ptR, *ptI;
Word32 enr1 = 0;
+ move32();
Word32 env[NUM_ENV_CNG];
Word32 min1;
Word16 min1_idx;
@@ -90,21 +99,24 @@ void CNG_enc_fx(
Word16 temp_lo_fx, temp_hi_fx;
Word16 exp_pow;
Word16 force_cn_step = 0;
+ move16();
Word16 tmp_loop;
Word16 st_lp_sp_enr;
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx;
+ move16();
Word16 lp_ener_thr_scale;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Temp variables for floating point functions */
lp_ener_thr_scale = 8; /* 4.0f*/ /*IVAS_CODE Q2 */
move16();
- if ( NE_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode != EVS_MONO )
{
lp_ener_thr_scale = 7; /* 3.5f;*/
move16();
@@ -163,8 +175,9 @@ void CNG_enc_fx(
test();
test();
test();
- IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16( hTdCngEnc->lp_sp_enr_fx, 1536 ) &&
- GT_16( sub( sp_enr, hTdCngEnc->lp_sp_enr_fx ), 1024 ) && GT_16( sp_enr, 1536 ) )
+ test();
+ IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /*6.0f in Q8*/ ) &&
+ GT_16( sub( sp_enr, hTdCngEnc->lp_sp_enr_fx ), 1024 /*4.0f in Q8*/ ) && GT_16( sp_enr, 1536 /*6.0f in Q8*/ ) )
{
hTdCngEnc->lp_sp_enr_fx = sp_enr;
move16();
@@ -174,10 +187,12 @@ void CNG_enc_fx(
ELSE
{
hTdCngEnc->lp_sp_enr_fx = round_fx( L_mac( L_mult( 29491 /* 0.9, Q15 */, hTdCngEnc->lp_sp_enr_fx ), 3277 /* 0.1, Q15 */, sp_enr ) ); /* Q8 (8+15+1-16) */
+ move16();
}
}
/* update the pointer to circular buffer of old LSP vectors */
hTdCngEnc->cng_hist_ptr = add( hTdCngEnc->cng_hist_ptr, 1 );
+ move16();
if ( EQ_16( hTdCngEnc->cng_hist_ptr, DTX_HIST_SIZE ) )
{
hTdCngEnc->cng_hist_ptr = 0;
@@ -203,7 +218,7 @@ void CNG_enc_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
+ ftmp_fx = 964; /*(6400/(M+1))X2.56 */
move16(); /*QX2.56 */
tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -211,7 +226,7 @@ void CNG_enc_fx(
ELSE
{
lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205;
+ ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -225,7 +240,7 @@ void CNG_enc_fx(
L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */
}
- C[i] = Mpy_32_16_1( L_tmp, 1928 );
+ C[i] = Mpy_32_16_1( L_tmp, 1928 /*.0588235f Q15*/ );
move32(); /*QX6.5536 */
IF( GT_32( C[i], max_val[0] ) )
@@ -251,6 +266,7 @@ void CNG_enc_fx(
FOR( i = 0; i < M; i++ )
{
L_tmp = 0;
+ move32();
FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ )
{
L_tmp = L_add( L_tmp, L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[j * M + i] ) ); /*Q15 */
@@ -260,6 +276,7 @@ void CNG_enc_fx(
tmpv = div_s( 1, sub( hDtxEnc->cng_hist_size, 2 ) ); /*Q15 */
L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
lsp_new[i] = extract_l( L_tmp ); /*Q15 */
+ move16();
}
max_idx1[0] = max_idx[0];
move16();
@@ -280,7 +297,7 @@ void CNG_enc_fx(
test();
test();
IF( ( ( hDtxEnc->cng_cnt == 0 ) &&
- GT_16( hTdCngEnc->lp_sp_enr_fx, 1536 ) &&
+ GT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /* 6.0, Q8 */ ) &&
( LT_16( add( st_lp_sp_enr, 1024 /* 4.0, Q8 */ ), sp_enr ) ) &&
( hDtxEnc->first_CNG != 0 ) &&
( hTdCngEnc->old_enr_index >= 0 ) &&
@@ -297,12 +314,12 @@ void CNG_enc_fx(
Copy( st_fx->lsp_old_fx, hDtxEnc->lspCNG_fx, M );
/* Average the CNG spectral envelope in case of the very first CNG frame */
- IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode != EVS_MONO )
{
FOR( i = 0; i < M; i++ )
{
/*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/
- lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 ), lsp_new[i], 16384 );
+ lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 ), lsp_new[i], 16384 /*.5 Q15*/ );
move16();
}
}
@@ -372,7 +389,8 @@ void CNG_enc_fx(
test();
test();
test();
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) )
+ test();
+ IF( st_fx->element_mode == EVS_MONO && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) )
{
IF( GT_32( hDtxEnc->last_active_brate, ACELP_16k40 ) )
{
@@ -382,11 +400,13 @@ void CNG_enc_fx(
ELSE
{
hDtxEnc->CNG_mode = get_cng_mode( hDtxEnc->last_active_brate );
+ move16();
}
}
/* If first sid after active burst update LSF history from circ buffer */
hTdCngEnc->burst_ho_cnt = s_min( hTdCngEnc->burst_ho_cnt, hTdCngEnc->ho_circ_size );
+ move16();
hTdCngEnc->act_cnt = 0;
move16();
s_ptr = add( sub( hTdCngEnc->ho_circ_ptr, hTdCngEnc->burst_ho_cnt ), 1 );
@@ -399,6 +419,7 @@ void CNG_enc_fx(
FOR( ll = hTdCngEnc->burst_ho_cnt; ll > 0; ll-- )
{
hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 );
+ move16();
if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) )
{
hTdCngEnc->ho_hist_ptr = 0;
@@ -422,9 +443,11 @@ void CNG_enc_fx(
Copy( &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), &( hTdCngEnc->ho_lsp_hist_fx[hTdCngEnc->ho_hist_ptr * M] ), M );
Copy32( &( hTdCngEnc->ho_ener_circ_fx[s_ptr] ), &( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 1 );
hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
+ move32();
Copy32( &( hTdCngEnc->ho_env_circ_fx[s_ptr * NUM_ENV_CNG] ), &( hTdCngEnc->ho_env_hist_fx[hTdCngEnc->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG );
hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 );
+ move16();
if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) )
{
hTdCngEnc->ho_hist_size = HO_HIST_SIZE;
@@ -458,9 +481,10 @@ void CNG_enc_fx(
#endif
test();
test();
- IF( ( hDtxEnc->first_CNG > 0 || EQ_16( st_fx->element_mode, EVS_MONO ) ) && L_tmp1 > 0 )
+ IF( ( hDtxEnc->first_CNG > 0 || st_fx->element_mode == EVS_MONO ) && L_tmp1 > 0 )
{
*allow_cn_step = s_or( *allow_cn_step, 1 );
+ move16();
}
}
test();
@@ -481,7 +505,7 @@ void CNG_enc_fx(
L_enr = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */
weights = W_DTX_HO_FX[0]; /* Q15 */
-
+ move16();
m = 1;
move16();
FOR( k = 1; k < hTdCngEnc->ho_hist_size; k++ )
@@ -531,7 +555,7 @@ void CNG_enc_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
+ ftmp_fx = 964; /*(6400/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -539,7 +563,7 @@ void CNG_enc_fx(
ELSE
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205;
+ ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -615,6 +639,8 @@ void CNG_enc_fx(
dist = 0; /*Q15 */
max_dev = 0; /*Q15 */
+ move16();
+ move16();
FOR( i = 0; i < M; i++ )
{
dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */
@@ -731,16 +757,17 @@ void CNG_enc_fx(
IF( EQ_16( st_fx->bwidth, WB ) && hDtxEnc->CNG_mode >= 0 )
{
ftmp_fx = HO_ATT_FX[hDtxEnc->CNG_mode];
+ move16();
}
ELSE
{
- ftmp_fx = 19661;
+ ftmp_fx = 19661; /*0.6f in Q15*/
move16();
}
- att = mult( ftmp_fx, 5461 ); /* Q15 */
- L_tmp = L_mult( att, 8 ); /* Q16 */
- tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */
+ att = mult( ftmp_fx, 5461 /*1/6f in Q15*/ ); /* Q15 */
+ L_tmp = L_mult( att, 8 ); /* Q16 */
+ tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */
tmp1 = add( 16384, tmp1 );
att = div_s( 16374, tmp1 ); /* Q15 */
@@ -919,6 +946,7 @@ void CNG_enc_fx(
enr = round_fx( L_tmp ); /* Q8 */
}
/* decrease the energy in case of WB input */
+ test();
IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) )
{
// PMT("CNG IVAS_SCE and IVAS_CPE_DFT code missing")
@@ -1011,6 +1039,7 @@ void CNG_enc_fx(
/* substract by 2 not done to leave Energy in Q2 */
lo = L_Extract_lc( L_tmp, &hi );
hTdCngEnc->Enew_fx = Pow2( add( hi, 4 ), lo ); /* Q6 */
+ move32();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
{
/* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/
@@ -1098,6 +1127,7 @@ void CNG_enc_fx(
FOR( i = 0; i < NUM_ENV_CNG; i++ )
{
q_env[i] = L_deposit_l( CNG_details_codebook_fx[min1_idx][i] );
+ move32();
}
}
/* Update hangover memory during CNG */
@@ -1106,6 +1136,7 @@ void CNG_enc_fx(
{
/* update the pointer to circular buffer of old LSP vectors */
hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 );
+ move16();
if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) )
{
hTdCngEnc->ho_hist_ptr = 0;
@@ -1139,6 +1170,7 @@ void CNG_enc_fx(
Copy32( env, &( hTdCngEnc->ho_env_hist_fx[( hTdCngEnc->ho_hist_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
}
hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 );
+ move16();
if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) )
{
hTdCngEnc->ho_hist_size = HO_HIST_SIZE;
@@ -1167,6 +1199,7 @@ void CNG_enc_fx(
move16();
push_indice_fx( hBstr, IND_SID_TYPE, 0, 1 );
+ test();
IF( LT_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->element_mode, IVAS_CPE_DFT ) )
{
push_indice_fx( hBstr, IND_SID_BW, 0, 1 );
@@ -1193,6 +1226,7 @@ void CNG_enc_fx(
ELSE
{
hDtxEnc->cng_cnt = add( hDtxEnc->cng_cnt, 1 );
+ move16();
}
return;
@@ -1419,7 +1453,7 @@ void CNG_enc_ivas_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
+ ftmp_fx = 964; /*(6400/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -1427,7 +1461,7 @@ void CNG_enc_ivas_fx(
ELSE
{
lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205;
+ ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -1467,6 +1501,7 @@ void CNG_enc_ivas_fx(
FOR( i = 0; i < M; i++ )
{
L_tmp = 0;
+ move32();
FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ )
{
L_tmp = L_add( L_tmp, L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[j * M + i] ) ); /*Q15 */
@@ -1476,6 +1511,7 @@ void CNG_enc_ivas_fx(
tmpv = div_s( 1, sub( hDtxEnc->cng_hist_size, 2 ) ); /*Q15 */
L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
lsp_new[i] = extract_l( L_tmp ); /*Q15 */
+ move16();
}
max_idx1[0] = max_idx[0];
move16();
@@ -1518,7 +1554,7 @@ void CNG_enc_ivas_fx(
FOR( i = 0; i < M; i++ )
{
/*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/
- lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 ), lsp_new[i], 16384 );
+ lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 /*.5f Q15*/ ), lsp_new[i], 16384 /*.5f Q15*/ );
move16();
}
}
@@ -1574,7 +1610,7 @@ void CNG_enc_ivas_fx(
FOR( i = 0; i < M; i++ )
{
/* AR low-pass filter */
- hDtxEnc->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i] ), 32768 - CNG_ISF_FACT_FX, lsp_new[i] );
+ hDtxEnc->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i] ), 32768 /*1f Q15*/ - CNG_ISF_FACT_FX, lsp_new[i] );
move16(); /* Q15 (15+15+1-16) */
}
}
@@ -1585,6 +1621,7 @@ void CNG_enc_ivas_fx(
test();
test();
test();
+ test();
IF( ( st_fx->element_mode == EVS_MONO ) && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) )
{
IF( GT_32( hDtxEnc->last_active_brate, ACELP_16k40 ) )
@@ -1595,6 +1632,7 @@ void CNG_enc_ivas_fx(
ELSE
{
hDtxEnc->CNG_mode = get_cng_mode( hDtxEnc->last_active_brate );
+ move16();
}
}
@@ -1688,7 +1726,7 @@ void CNG_enc_ivas_fx(
L_ener = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */
weights = W_DTX_HO_FX[0]; /* Q15 */
-
+ move16();
m = 1;
move16();
FOR( k = 1; k < hTdCngEnc->ho_hist_size; k++ )
@@ -1738,7 +1776,7 @@ void CNG_enc_ivas_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
+ ftmp_fx = 964; /*(6400/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -1746,7 +1784,7 @@ void CNG_enc_ivas_fx(
ELSE
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205;
+ ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -1815,9 +1853,9 @@ void CNG_enc_ivas_fx(
}
L_tmp = L_sub( L_tmp, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15 */
- tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */
- L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
- lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */
+ tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */ /*Q15 */
+ L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ /*Q15 */
+ lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ /*Q15 */
move16();
}
}
@@ -1851,7 +1889,7 @@ void CNG_enc_ivas_fx(
FOR( i = 0; i < M; i++ )
{
/* AR low-pass filter */
- hDtxEnc->lspCNG_fx[i] = add( mult_r( 26214, lsp_tmp[i] ), mult_r( 6554, lsp_new[i] ) ); /* Q15 */
+ hDtxEnc->lspCNG_fx[i] = add( mult_r( 26214 /*.8f Q15*/, lsp_tmp[i] ), mult_r( 6554 /*.2f Q15*/, lsp_new[i] ) ); /* Q15 */
move16();
}
}
@@ -1909,7 +1947,7 @@ void CNG_enc_ivas_fx(
{
E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M );
exp = sub( Q14, norm_s( Aq[0] ) );
- Scale_sig( Aq, M, sub( Q12, exp ) );
+ Scale_sig( Aq, M, sub( Q12, exp ) ); // Q12
}
tmp_loop = shr( st_fx->L_frame, 6 );
@@ -1930,8 +1968,8 @@ void CNG_enc_ivas_fx(
{
L_tmp1 = L_mult0( hTdCngEnc->CNG_att_fx, 26214 /* 1/20.0f in Q19 */ ); // Q26 (7 + 19)
L_tmp1 = BASOP_Util_fPow( 1342177280 /*10 in Q27 */, 4, L_tmp1, 5, &exp );
- att = extract_h( L_shl( L_tmp1, exp ) ); // Q15
- v_multc_fixed_16_16( res1, att, res1, st_fx->L_frame ); /* Q_new */
+ att = extract_h( L_shl( L_sub( L_tmp1, EPSILON_FX ), exp ) ); // Q15 // Subtracting by EPSILON_FX to avoid assertion when L_tmp1 value is 1073741824 and exp =1
+ v_multc_fixed_16_16( res1, att, res1, st_fx->L_frame ); /* Q_new */
}
ELSE IF( st_fx->bwidth != NB )
{
@@ -1943,7 +1981,7 @@ void CNG_enc_ivas_fx(
}
ELSE
{
- ftmp_fx = 19661;
+ ftmp_fx = 19661; /*.6f in Q15*/
move16();
}
@@ -2130,6 +2168,7 @@ void CNG_enc_ivas_fx(
enr = round_fx( L_tmp ); /* Q8 */
}
/* decrease the energy in case of WB input */
+ test();
IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) )
{
enr = add( enr, mult( hTdCngEnc->CNG_att_fx, FAC_LOG2_BY10_Q16 ) ); /* Q8 (Q7 + Q16 - Q15)*/
@@ -2154,7 +2193,7 @@ void CNG_enc_ivas_fx(
ELSE
{
att = 384;
- move16(); /*Q8*/
+ move16(); /*1.5f Q8*/
}
enr = sub( enr, att );
}
@@ -2220,6 +2259,7 @@ void CNG_enc_ivas_fx(
/* substract by 2 not done to leave Energy in Q2 */
lo = L_Extract_lc( L_tmp, &hi );
hTdCngEnc->Enew_fx = Pow2( add( hi, 4 ), lo ); /* Q6 */
+ move32();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
{
/* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/
@@ -2272,7 +2312,7 @@ void CNG_enc_ivas_fx(
}
/* codebook search */
- min1 = 1310588928; /* Q17 */
+ min1 = 1310588928; /* 9999.0f Q17 */
move32();
min1_idx = 0;
move16();
@@ -2425,6 +2465,7 @@ void swb_CNG_enc_fx(
)
{
Word16 shb_SID_updt_fx = 0;
+ move16();
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
test();
@@ -2534,10 +2575,11 @@ static void shb_CNG_encod_fx(
#ifndef IVAS_CODE
hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_CNG_ENV1].nb_bits );
hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1;
+ move16();
+ move16();
#else
delete_indice( hBstr, IND_CNG_ENV1 );
#endif
- move16();
#ifdef IVAS_CODE
if ( st->element_mode == IVAS_CPE_DFT )
{
@@ -2550,6 +2592,8 @@ static void shb_CNG_encod_fx(
}
hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
hTdCngEnc->ho_sid_bw = L_or( hTdCngEnc->ho_sid_bw, 0x1L );
+ move32();
+ move32();
}
ELSE
{
@@ -2587,11 +2631,13 @@ static Word16 shb_DTX_fx(
Word16 fra;
Word16 att; /*Q8*/
Word16 allow_cn_step_fx = 0;
+ move16();
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4;
Copy( hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 );
@@ -2666,7 +2712,7 @@ static Word16 shb_DTX_fx(
move16();
}
- if ( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 ) )
+ if ( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12.0f Q8*/ ) )
{
allow_cn_step_fx = 1;
move16();
@@ -2688,15 +2734,16 @@ static Word16 shb_DTX_fx(
ELSE
{
tmp = sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ); /* Q8 */
- tmp = mult( tmp, 29491 ); /* Q8 */
+ tmp = mult( tmp, 29491 /*.9f in Q15*/ ); /* Q8 */
hTdCngEnc->mov_wb_cng_ener_fx = add( hTdCngEnc->mov_wb_cng_ener_fx, tmp ); /* Q8 */
-
+ move16();
tmp = sub( log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx );
- tmp = mult( tmp, 8192 ); /* Q8 */
+ tmp = mult( tmp, 8192 /*.25f in Q15*/ ); /* Q8 */
hTdCngEnc->mov_shb_cng_ener_fx = add( hTdCngEnc->mov_shb_cng_ener_fx, tmp ); /* Q8 */
+ move16();
}
hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 );
-
+ move16();
update_fx = 0;
move16();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
@@ -2715,10 +2762,11 @@ static Word16 shb_DTX_fx(
update_fx = 1;
move16();
hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 );
+ move16();
}
ELSE
{
- IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) )
+ IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 /*3.0f in Q8*/ ) )
{
update_fx = 1;
move16();
@@ -2777,14 +2825,14 @@ static Word16 shb_DTX_fx(
*---------------------------------------------------------------------*/
void calculate_hangover_attenuation_gain_fx(
Encoder_State *st, /* i : encoder state structure */
- Word16 *att, /* o : attenuation factor */
+ Word16 *att, /* o : attenuation factor Q15 */
const Word16 vad_hover_flag /* i : VAD hangover flag */
)
{
Word16 offset;
TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc;
- *att = 32767;
+ *att = 32767; // 1.0f in Q15
move16();
/* smoothing in case of CNG */
@@ -2793,7 +2841,7 @@ void calculate_hangover_attenuation_gain_fx(
test();
test();
test();
- IF( hTdCngEnc->burst_ho_cnt > 0 && ( vad_hover_flag != 0 ) && ( NE_16( st->bwidth, NB ) || GT_16( st->element_mode, EVS_MONO ) ) ) /* corresponds to line 504 in FLT acelp_core_enc.c */
+ IF( hTdCngEnc->burst_ho_cnt > 0 && ( vad_hover_flag != 0 ) && ( NE_16( st->bwidth, NB ) || st->element_mode > EVS_MONO ) ) /* corresponds to line 504 in FLT acelp_core_enc.c */
{
#ifdef IVAS_CODE
if ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD )
@@ -2804,6 +2852,7 @@ void calculate_hangover_attenuation_gain_fx(
#endif
{
offset = 5;
+ move16();
test();
if ( EQ_16( st->bwidth, WB ) && st->hDtxEnc->CNG_mode >= 0 )
{
@@ -2811,7 +2860,7 @@ void calculate_hangover_attenuation_gain_fx(
move16();
}
assert( hTdCngEnc->burst_ho_cnt > 0 );
- *att = CNG_burst_att_fx[offset][sub( hTdCngEnc->burst_ho_cnt, 1 )]; /*Q15*/
+ *att = CNG_burst_att_fx[offset][hTdCngEnc->burst_ho_cnt - 1]; /*Q15*/
move16();
}
}
@@ -2821,20 +2870,20 @@ void calculate_hangover_attenuation_gain_fx(
void calculate_hangover_attenuation_gain_ivas_fx(
Encoder_State *st, /* i : encoder state structure */
- Word16 *att, /* o : attenuation factor */
+ Word16 *att, /* o : attenuation factor Q15 */
const Word16 vad_hover_flag /* i : VAD hangover flag */
)
{
Word16 lim, result_e;
- *att = 32767;
+ *att = 32767; // 1.0f in Q15
move16();
test();
test();
test();
test();
- IF( st->hTdCngEnc != NULL && ( vad_hover_flag != 0 ) && GT_16( st->hTdCngEnc->burst_ho_cnt, 0 ) && ( NE_16( st->bwidth, NB ) || GT_16( st->element_mode, EVS_MONO ) ) )
+ IF( st->hTdCngEnc != NULL && ( vad_hover_flag != 0 ) && GT_16( st->hTdCngEnc->burst_ho_cnt, 0 ) && ( NE_16( st->bwidth, NB ) || st->element_mode > EVS_MONO ) )
{
test();
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c
index d933989970e0a6297977d86702570cf5eb5a6442..cbe006f5360f7186fdc9750cbb41ce72978ff63d 100644
--- a/lib_enc/cod2t32_fx.c
+++ b/lib_enc/cod2t32_fx.c
@@ -30,10 +30,10 @@
void acelp_2t32_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 dn[], /* i : corr. between target and h[]. */
- const Word16 h[], /* i : impulse response of weighted synthesis filter */
- Word16 code[], /* o : algebraic (fixed) codebook excitation */
- Word16 y[] /* o : filtered fixed codebook excitation */
+ const Word16 dn[], /* i : corr. between target and h[]. Qx*/
+ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12*/
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
+ Word16 y[] /* o : filtered fixed codebook excitation Q9*/
)
{
Word16 i, j, k, i0, i1, ix, iy, pos, pos2, sign0, sign1, index;
@@ -50,6 +50,7 @@ void acelp_2t32_fx(
Word16 rrixiy[MSIZE];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
* Compute rrixix[][] needed for the codebook search.
@@ -57,12 +58,9 @@ void acelp_2t32_fx(
/* Init pointers to last position of rrixix[] */
p0 = &rrixix[0][NB_POS_FCB_2T - 1];
- move16();
p1 = &rrixix[1][NB_POS_FCB_2T - 1];
- move16();
ptr_h1 = h;
- move16();
L_cor = L_deposit_h( 1 );
FOR( i = 0; i < NB_POS_FCB_2T; i++ )
{
@@ -85,9 +83,7 @@ void acelp_2t32_fx(
}
p0 = rrixix[0];
- move16();
p1 = rrixix[1];
- move16();
FOR( i = 0; i < NB_POS_FCB_2T; i++ )
{
@@ -108,46 +104,41 @@ void acelp_2t32_fx(
pos2 = MSIZE - 2;
move16();
ptr_hf = h + 1;
- move16();
FOR( k = 0; k < NB_POS_FCB_2T; k++ )
{
/* Init pointers to last position of diagonals */
p1 = &rrixiy[pos];
- move16();
p0 = &rrixiy[pos2];
- move16();
ptr_h1 = h;
- move16();
ptr_h2 = ptr_hf;
- move16();
- L_cor = L_mult( *ptr_h1++, *ptr_h2++ );
+ L_cor = L_mult( *ptr_h1++, *ptr_h2++ ); // Q(12+12+1)
FOR( i = k; i < NB_POS_FCB_2T - 1; i++ )
{
#ifdef BASOP_NOGLOB
- *p1 = round_fx_o( L_cor, &Overflow );
+ *p1 = round_fx_o( L_cor, &Overflow ); // Q(25-16)
L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow );
#else
*p1 = round_fx( L_cor );
L_cor = L_mac( L_cor, *ptr_h1++, *ptr_h2++ );
#endif
#ifdef BASOP_NOGLOB
- *p0 = round_fx_o( L_cor, &Overflow );
+ *p0 = round_fx_o( L_cor, &Overflow ); // Q(9)
L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow );
#else
*p0 = round_fx( L_cor );
L_cor = L_mac( L_cor, *ptr_h1++, *ptr_h2++ );
#endif
- p1 -= ( NB_POS_FCB_2T + 1 );
move16();
- p0 -= ( NB_POS_FCB_2T + 1 );
move16();
+ p1 -= ( NB_POS_FCB_2T + 1 );
+ p0 -= ( NB_POS_FCB_2T + 1 );
}
#ifdef BASOP_NOGLOB
- *p1 = round_fx_o( L_cor, &Overflow );
+ *p1 = round_fx_o( L_cor, &Overflow ); // Q9
#else
*p1 = round_fx( L_cor );
#endif
@@ -155,7 +146,6 @@ void acelp_2t32_fx(
move16();
pos2--;
ptr_hf += STEP;
- move16();
}
/*----------------------------------------------------------------*
@@ -168,18 +158,18 @@ void acelp_2t32_fx(
/* FIR high-pass filtering */
IF( i == 0 )
{
- L_tmp = L_msu( L_tmp, dn[1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[1], 11469 /*.3f Q15*/ );
}
ELSE IF( EQ_16( i, L_SUBFR - 1 ) )
{
L_tmp = L_deposit_h( dn[i] );
- L_tmp = L_msu( L_tmp, dn[i - 1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[i - 1], 11469 /*.3f Q15*/ );
}
ELSE
{
L_tmp = L_deposit_h( dn[i] );
- L_tmp = L_msu( L_tmp, dn[i - 1], 11469 );
- L_tmp = L_msu( L_tmp, dn[i + 1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[i - 1], 11469 /*.3f Q15*/ );
+ L_tmp = L_msu( L_tmp, dn[i + 1], 11469 /*.3f Q15*/ );
}
/* pre-selection of polarities */
@@ -232,11 +222,8 @@ void acelp_2t32_fx(
*----------------------------------------------------------------*/
p0 = rrixix[0];
- move16();
p1 = rrixix[1];
- move16();
p2 = rrixiy;
- move16();
psk = -1;
move16();
alpk = 1;
@@ -279,7 +266,6 @@ void acelp_2t32_fx(
}
}
p1 -= NB_POS_FCB_2T;
- move16();
IF( pos >= 0 )
{
@@ -293,8 +279,8 @@ void acelp_2t32_fx(
i0 = shr( ix, 1 );
i1 = shr( iy, 1 );
- sign0 = shl( pol[ix], 9 );
- sign1 = shl( pol[iy], 9 );
+ sign0 = shl( pol[ix], 9 ); // Q9
+ sign1 = shl( pol[iy], 9 ); // Q9
/*-------------------------------------------------------------------*
* Build the codeword, the filtered codeword and index of codevector.
@@ -327,12 +313,13 @@ void acelp_2t32_fx(
FOR( i = ix; i < L_SUBFR; i++ )
{
- y[i] = mult_r( sign0, h[i - ix] );
+ y[i] = mult_r( sign0, h[i - ix] ); // Q9
move16();
}
FOR( i = iy; i < L_SUBFR; i++ )
{
- y[i] = round_fx( L_mac( L_deposit_h( y[i] ), sign1, h[i - iy] ) );
+ y[i] = round_fx( L_mac( L_deposit_h( y[i] ), sign1, h[i - iy] ) ); // Q9
+ move16();
}
{
/* write index to array of indices */
@@ -343,10 +330,10 @@ void acelp_2t32_fx(
void acelp_2t32_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 dn[], /* i : corr. between target and h[]. */
- const Word16 h[], /* i : impulse response of weighted synthesis filter */
- Word16 code[], /* o : algebraic (fixed) codebook excitation */
- Word16 y[] /* o : filtered fixed codebook excitation */
+ const Word16 dn[], /* i : corr. between target and h[]. Qx*/
+ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12*/
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9 */
+ Word16 y[] /* o : filtered fixed codebook excitation Q9 */
)
{
Word16 i, j, k, i0, i1, ix, iy, pos, pos2, sign0, sign1, index;
@@ -371,9 +358,7 @@ void acelp_2t32_ivas_fx(
/* Init pointers to last position of rrixix[] */
p0 = &rrixix[0][NB_POS_FCB_2T - 1];
- move16();
p1 = &rrixix[1][NB_POS_FCB_2T - 1];
- move16();
ptr_h1 = h;
move16();
@@ -399,9 +384,7 @@ void acelp_2t32_ivas_fx(
}
p0 = rrixix[0];
- move16();
p1 = rrixix[1];
- move16();
FOR( i = 0; i < NB_POS_FCB_2T; i++ )
{
@@ -422,42 +405,37 @@ void acelp_2t32_ivas_fx(
pos2 = MSIZE - 2;
move16();
ptr_hf = h + 1;
- move16();
FOR( k = 0; k < NB_POS_FCB_2T; k++ )
{
/* Init pointers to last position of diagonals */
p1 = &rrixiy[pos];
- move16();
p0 = &rrixiy[pos2];
- move16();
ptr_h1 = h;
- move16();
ptr_h2 = ptr_hf;
- move16();
- L_cor = L_mult( *ptr_h1++, *ptr_h2++ );
+ L_cor = L_mult( *ptr_h1++, *ptr_h2++ ); // Q25
FOR( i = k; i < NB_POS_FCB_2T - 1; i++ )
{
#ifdef BASOP_NOGLOB
- *p1 = round_fx_o( L_cor, &Overflow );
+ *p1 = round_fx_o( L_cor, &Overflow ); // Q9
L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow );
#else
*p1 = round_fx( L_cor );
L_cor = L_mac( L_cor, *ptr_h1++, *ptr_h2++ );
#endif
#ifdef BASOP_NOGLOB
- *p0 = round_fx_o( L_cor, &Overflow );
+ *p0 = round_fx_o( L_cor, &Overflow ); // Q9
L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow );
#else
*p0 = round_fx( L_cor );
L_cor = L_mac( L_cor, *ptr_h1++, *ptr_h2++ );
#endif
- p1 -= ( NB_POS_FCB_2T + 1 );
move16();
- p0 -= ( NB_POS_FCB_2T + 1 );
move16();
+ p1 -= ( NB_POS_FCB_2T + 1 );
+ p0 -= ( NB_POS_FCB_2T + 1 );
}
#ifdef BASOP_NOGLOB
@@ -467,7 +445,7 @@ void acelp_2t32_ivas_fx(
#endif
pos -= NB_POS_FCB_2T;
move16();
- pos2--;
+ pos2 = sub( pos2, 1 );
ptr_hf += STEP;
move16();
}
@@ -482,18 +460,18 @@ void acelp_2t32_ivas_fx(
/* FIR high-pass filtering */
IF( i == 0 )
{
- L_tmp = L_msu( L_tmp, dn[1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[1], 11469 /*.3f Q15*/ );
}
ELSE IF( EQ_16( i, L_SUBFR - 1 ) )
{
L_tmp = L_deposit_h( dn[i] );
- L_tmp = L_msu( L_tmp, dn[i - 1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[i - 1], 11469 /*.3f Q15*/ );
}
ELSE
{
L_tmp = L_deposit_h( dn[i] );
- L_tmp = L_msu( L_tmp, dn[i - 1], 11469 );
- L_tmp = L_msu( L_tmp, dn[i + 1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[i - 1], 11469 /*.3f Q15*/ );
+ L_tmp = L_msu( L_tmp, dn[i + 1], 11469 /*.3f Q15*/ );
}
/* pre-selection of polarities */
@@ -546,11 +524,8 @@ void acelp_2t32_ivas_fx(
*----------------------------------------------------------------*/
p0 = rrixix[0];
- move16();
p1 = rrixix[1];
- move16();
p2 = rrixiy;
- move16();
psk = -1;
move16();
alpk = 1;
@@ -593,7 +568,6 @@ void acelp_2t32_ivas_fx(
}
}
p1 -= NB_POS_FCB_2T;
- move16();
IF( pos >= 0 )
{
@@ -607,8 +581,8 @@ void acelp_2t32_ivas_fx(
i0 = shr( ix, 1 );
i1 = shr( iy, 1 );
- sign0 = shl( pol[ix], 9 );
- sign1 = shl( pol[iy], 9 );
+ sign0 = shl( pol[ix], 9 ); // Q9
+ sign1 = shl( pol[iy], 9 ); // Q9
/*-------------------------------------------------------------------*
* Build the codeword, the filtered codeword and index of codevector.
@@ -641,12 +615,13 @@ void acelp_2t32_ivas_fx(
FOR( i = ix; i < L_SUBFR; i++ )
{
- y[i] = mult_r( sign0, h[i - ix] );
+ y[i] = mult_r( sign0, h[i - ix] ); // Q9
move16();
}
FOR( i = iy; i < L_SUBFR; i++ )
{
- y[i] = round_fx( L_mac( L_deposit_h( y[i] ), sign1, h[i - iy] ) );
+ y[i] = round_fx( L_mac( L_deposit_h( y[i] ), sign1, h[i - iy] ) ); // Q9
+ move16();
}
{
/* write index to array of indices */
@@ -665,10 +640,10 @@ void acelp_2t32_ivas_fx(
void acelp_1t64_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 dn[], /* i : corr. between target and h[]. */
- const Word16 h[], /* i : impulse response of weighted synthesis filter */
- Word16 code[], /* o : algebraic (fixed) codebook excitation */
- Word16 y[], /* o : filtered fixed codebook excitation */
+ const Word16 dn[], /* i : corr. between target and h[]. Qx*/
+ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12 */
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9 */
+ Word16 y[], /* o : filtered fixed codebook excitation Q9 */
const Word16 L_subfr /* i : subframe length */
)
{
@@ -681,12 +656,12 @@ void acelp_1t64_fx(
IF( dn[pos] < 0 )
{
- sgn = -512;
+ sgn = -512; //-1 in Q9
move16();
}
ELSE
{
- sgn = 512;
+ sgn = 512; // 1 in Q9
move16();
}
@@ -704,12 +679,12 @@ void acelp_1t64_fx(
{
IF( sgn > 0 )
{
- y[i] = shr_r( h[i - pos], 3 );
+ y[i] = shr_r( h[i - pos], 3 ); // Q9
move16();
}
ELSE
{
- y[i] = negate( shr_r( h[i - pos], 3 ) );
+ y[i] = negate( shr_r( h[i - pos], 3 ) ); // Q9
move16();
}
}
@@ -734,10 +709,10 @@ void acelp_1t64_fx(
void acelp_1t64_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 dn[], /* i : corr. between target and h[]. */
- const Word16 h[], /* i : impulse response of weighted synthesis filter */
- Word16 code[], /* o : algebraic (fixed) codebook excitation */
- Word16 y[], /* o : filtered fixed codebook excitation */
+ const Word16 dn[], /* i : corr. between target and h[]. Qx */
+ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12*/
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
+ Word16 y[], /* o : filtered fixed codebook excitation Q9*/
const Word16 L_subfr /* i : subframe length */
)
{
@@ -773,12 +748,12 @@ void acelp_1t64_ivas_fx(
{
IF( sgn > 0 )
{
- y[i] = shr_r( h[i - pos], 3 );
+ y[i] = shr_r( h[i - pos], 3 ); // Q9
move16();
}
ELSE
{
- y[i] = negate( shr_r( h[i - pos], 3 ) );
+ y[i] = negate( shr_r( h[i - pos], 3 ) ); // Q9
move16();
}
}
diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c
index 3e28b35a6c6cc959a100eced185fb14985f24905..1a1383d4121d2d2ffd95ea78bd1978fda445d8d9 100644
--- a/lib_enc/cod4t64_fast.c
+++ b/lib_enc/cod4t64_fast.c
@@ -60,7 +60,7 @@
*---------------------------------------------------------------------*/
/*! r: return index (N+1 bits) */
-static Word16 quant_1p_N1_L_subfr(
+static Word16 quant_1p_N1_L_subfr_fx(
const Word16 nb_pos, /* i : number of positions */
const Word16 pos, /* i : position of the pulse */
const Word16 N /* i : number of bits for position */
@@ -72,7 +72,7 @@ static Word16 quant_1p_N1_L_subfr(
index = s_and( pos, mask );
- if ( s_and( pos, nb_pos ) != 0 )
+ IF( s_and( pos, nb_pos ) != 0 )
{
index = add( index, shl( 1, N ) );
}
@@ -83,14 +83,15 @@ static Word16 find_best_pulse_fx(
const Word16 L_subfr,
const Word16 nb_tracks,
const Word16 track,
- const Word32 dn[],
- const Word16 sign[],
- Word16 *s )
+ const Word32 dn[], // Qx
+ const Word16 sign[], // Q0
+ Word16 *s // Q0
+)
{
Word16 m, i;
Word32 temp, max_val;
- max_val = MIN_32;
+ max_val = EPSILLON_FX;
move32();
m = track;
move16();
@@ -370,7 +371,7 @@ void acelp_fast_fx(
{
h[i] = H[i];
move16();
- h_inv[i] = -H[i];
+ h_inv[i] = negate( H[i] );
move16();
}
@@ -594,7 +595,7 @@ void acelp_fast_fx(
move16();
s64 = 0;
-
+ move64();
FOR( i = track; i < L_subfr; i += nb_tracks )
{
dn[i] = L_shr( L_msu( L_mult0( Gd, dn_orig[i] ), G, *alp_pos0 ), 6 ); // Q_dn
@@ -606,11 +607,18 @@ void acelp_fast_fx(
dndn_fx = W_extract_h( W_shl( s64, exp1 ) ); // 2 * Q_dyn + exp1 - 31
dndn_e = sub( 31, sub( add( shl( Q_dn, 1 ), exp ), 31 ) );
+ IF( dndn_fx == 0 )
+ {
+ dndn_fx = 214748365 /* 0.1f in Q31 */;
+ move32();
+ dndn_e = 0;
+ move16();
+ }
s_coef_fx = BASOP_Util_Divide3232_Scale( dndn_fx, cncn_track[track], &exp1 );
exp1 = add( exp1, sub( dndn_e, cncn_track_e[track] ) );
s_coef_fx = Sqrt16( s_coef_fx, &exp1 );
exp1 = sub( exp1, shift );
- max_val_fx = MIN_16;
+ max_val_fx = EPSILLON_FX;
move16();
m[1] = track; // Q0
move16();
@@ -641,6 +649,7 @@ void acelp_fast_fx(
{
Gn = add( Gn, i_mult( s[1], shr( dn_orig[m[1]], 1 ) ) ); // Q_dn -1
Gd32 = Gd;
+ move16();
Gd32 = L_add( Gd32, L_add( alp[0], L_mult0( i_mult( shl( s[0], 1 ), s[1] ), alp[m[0] - m[1]] ) ) ); // Q6
G = Gn; // Q_dn - 1
move16();
@@ -672,6 +681,7 @@ void acelp_fast_fx(
{
Gn = add( Gn, i_mult( s[2], shr( dn_orig[m[2]], 1 ) ) ); // Q_dn-1
Gd32 = Gd;
+ move16();
Gd32 = L_add( Gd32, L_add( L_add( alp[0], L_mult0( i_mult( shl( s[0], 1 ), s[2] ), alp[m[0] - m[2]] ) ), L_mult0( i_mult( shl( s[1], 1 ), s[2] ), alp[m[1] - m[2]] ) ) ); // Q6
G = Gn; // Q_dn-1
move16();
@@ -711,12 +721,14 @@ void acelp_fast_fx(
{
Gn = add( Gn, i_mult( s[3], shr( dn_orig[m[3]], 1 ) ) ); // Q_dn-1
Gd32 = Gd;
+ move16();
Gd32 = L_add( Gd32, L_add( L_add( L_add( alp[0], L_mult0( i_mult( shl( s[0], 1 ), s[3] ), alp[m[0] - m[3]] ) ), L_mult0( i_mult( shl( s[1], 1 ), s[3] ), alp[m[1] - m[3]] ) ), L_mult0( i_mult( shl( s[2], 1 ), s[3] ), alp[m[2] - m[3]] ) ) ); // Q6
- G = Gn; // Q_dn-1
- G1 = i_mult( G, s[1] ); // Q_dn-1
- G2 = i_mult( G, s[2] ); // Q_dn-1
- G3 = i_mult( G, s[3] ); // Q_dn-1
- G = i_mult( G, s[0] ); // Q_dn-1
+ G = Gn;
+ move16(); // Q_dn-1
+ G1 = i_mult( G, s[1] ); // Q_dn-1
+ G2 = i_mult( G, s[2] ); // Q_dn-1
+ G3 = i_mult( G, s[3] ); // Q_dn-1
+ G = i_mult( G, s[0] ); // Q_dn-1
IF( EQ_16( cdk_index, 6 ) )
{
@@ -791,7 +803,7 @@ void acelp_fast_fx(
FOR( i = 0; i < L_subfr; i++ )
{
- y_tmp[i] = add( y_tmp[i], *p_hn++ ); // q_H
+ y_tmp[i] = add_sat( y_tmp[i], *p_hn++ ); // q_H
move16();
}
@@ -814,9 +826,9 @@ void acelp_fast_fx(
crit_den = W_extract_h( W_shl( s64, exp1 ) ); // 2*q_H + exp1 - 32
q_crit_den = add( shl( q_H, 1 ), sub( exp1, 32 ) );
- L_tmp1 = Mpy_32_32( crit_num, crit_den_max );
+ L_tmp1 = Mpy_32_32( crit_num, crit_den_max ); // q_crit_num+q_crit_den_max-31
exp = sub( add( q_crit_num, q_crit_den_max ), 31 );
- L_tmp2 = Mpy_32_32( crit_den, crit_num_max );
+ L_tmp2 = Mpy_32_32( crit_den, crit_num_max ); // q_crit_den+q_crit_num_max-31
exp1 = sub( add( q_crit_den, q_crit_num_max ), 31 );
IF( GT_16( exp, exp1 ) )
@@ -984,7 +996,7 @@ void acelp_fast_fx(
j = i_mult( q, NPMAXPT );
IF( NE_16( ind_stream[j], -1 ) )
{
- idx = quant_1p_N1_L_subfr( nb_pos, ind_stream[j], bits_track );
+ idx = quant_1p_N1_L_subfr_fx( nb_pos, ind_stream[j], bits_track );
push_indice( hBstr, IND_ALG_CDBK_4T64, idx, add( bits_track, 1 ) );
}
}
@@ -1001,7 +1013,7 @@ void acelp_fast_fx(
}
ELSE
{
- idx = quant_1p_N1_L_subfr( nb_pos, ind_stream[j], bits_track );
+ idx = quant_1p_N1_L_subfr_fx( nb_pos, ind_stream[j], bits_track );
push_indice( hBstr, IND_ALG_CDBK_4T64, idx, add( bits_track, 1 ) );
}
}
diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c
index 92db2139b7b4c08b412056294c6f194875c646fc..44cde6f27d8488be31521c55cd81eb875d3a196d 100644
--- a/lib_enc/cod4t64_fx.c
+++ b/lib_enc/cod4t64_fx.c
@@ -57,10 +57,10 @@ static Word32 pre_process_fx( const Word16 v[], Word16 sector_6p[], Word32 secto
Word16 acelp_4t64_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 dn[], /* i : corr. between target and h[]. */
+ Word16 dn[], /* i : corr. between target and h[]. */
const Word16 cn[], /* i : residual after long term prediction Q_new*/
const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/
- Word16 R[], /* i : autocorrelation values */
+ Word16 R[], /* i : autocorrelation values */
const Word16 acelpautoc, /* i : autocorrealtion flag */
Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
Word16 y[], /* o : filtered fixed codebook excitation Q9*/
@@ -100,9 +100,9 @@ Word16 acelp_4t64_fx(
case 28: /* EVS pulse indexing: 28 bits, 6 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x20x16=1280 loops */
- config.alp = 8192;
- move16(); /* coeff FOR sign setting */
+ move16(); /* 4x20x16=1280 loops */
+ config.alp = 8192; /*1 in Q13*/
+ move16(); /* coeff FOR sign setting */
config.nb_pulse = 6;
move16();
config.fixedpulses = 0;
@@ -117,9 +117,9 @@ Word16 acelp_4t64_fx(
case 36: /* EVS/AMR-WB pulse indexing: 36 bits, 8 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x20x16=1280 loops */
- config.alp = 8192;
- move16(); /* coeff FOR sign setting */
+ move16(); /* 4x20x16=1280 loops */
+ config.alp = 8192; /*1 in Q13*/
+ move16(); /* coeff FOR sign setting */
config.nb_pulse = 8;
move16();
config.fixedpulses = 2;
@@ -135,8 +135,8 @@ Word16 acelp_4t64_fx(
case 43: /* EVS pulse indexing: 43 bits, 10 pulses, 4 tracks */
case 44: /* AMR-WB pulse indexing: 44 bits, 10 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x26x16=1664 loops */
- config.alp = 8192;
+ move16(); /* 4x26x16=1664 loops */
+ config.alp = 8192; /*1 in Q13*/
move16();
config.nb_pulse = 10;
move16();
@@ -155,8 +155,8 @@ Word16 acelp_4t64_fx(
case 50: /* EVS pulse indexing: 50 bits, 12 pulses, 4 tracks */
case 52: /* AMR-WB pulse indexing: 52 bits, 12 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x26x16=1664 loops */
- config.alp = 8192;
+ move16(); /* 4x26x16=1664 loops */
+ config.alp = 8192; /*1 in Q13*/
move16();
config.nb_pulse = 12;
move16();
@@ -175,8 +175,8 @@ Word16 acelp_4t64_fx(
case 62: /* EVS pulse indexing: 62 bits, 16 pulses, 4 tracks */
case 64: /* AMR-WB pulse indexing: 64 bits, 16 pulses, 4 tracks */
config.nbiter = 3;
- move16(); /* 3x36x16=1728 loops */
- config.alp = 6554;
+ move16(); /* 3x36x16=1728 loops */
+ config.alp = 6554; /*.8f in Q13*/
move16();
config.nb_pulse = 16;
move16();
@@ -198,8 +198,8 @@ Word16 acelp_4t64_fx(
case 72: /* AMR-WB pulse indexing: 72 bits, 18 pulses, 4 tracks */
config.nbiter = 3;
- move16(); /* 3x35x16=1680 loops */
- config.alp = 6144;
+ move16(); /* 3x35x16=1680 loops */
+ config.alp = 6144; /*.75f in Q13*/
move16();
config.nb_pulse = 18;
move16();
@@ -223,8 +223,8 @@ Word16 acelp_4t64_fx(
case 88: /* AMR-WB pulse indexing: 88 bits, 24 pulses, 4 tracks */
config.nbiter = 2;
- move16(); /* 2x53x16=1696 loop */
- config.alp = 4096;
+ move16(); /* 2x53x16=1696 loop */
+ config.alp = 4096; /*.5f in Q13*/
move16();
config.nb_pulse = 24;
move16();
@@ -255,7 +255,7 @@ Word16 acelp_4t64_fx(
case 87: /* EVS pulse indexing: 87 bits, 26 pulses, 4 tracks */
config.nbiter = 1;
move16();
- config.alp = 4096;
+ config.alp = 4096; /*.5f in Q13*/
move16();
config.nb_pulse = 26;
move16();
@@ -472,10 +472,10 @@ Word16 acelp_4t64_fx(
Word16 acelp_4t64_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 dn[], /* i : corr. between target and h[]. */
+ Word16 dn[], /* i : corr. between target and h[]. */
const Word16 cn[], /* i : residual after long term prediction Q_new*/
const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/
- Word16 R[], /* i : autocorrelation values */
+ Word16 R[], /* i : autocorrelation values */
const Word16 acelpautoc, /* i : autocorrealtion flag */
Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
Word16 y[], /* o : filtered fixed codebook excitation Q9*/
@@ -515,9 +515,9 @@ Word16 acelp_4t64_ivas_fx(
case 28: /* EVS pulse indexing: 28 bits, 6 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x20x16=1280 loops */
- config.alp = 8192;
- move16(); /* coeff FOR sign setting */
+ move16(); /* 4x20x16=1280 loops */
+ config.alp = 8192; /*1 in Q13*/
+ move16(); /* coeff FOR sign setting */
config.nb_pulse = 6;
move16();
config.fixedpulses = 0;
@@ -532,9 +532,9 @@ Word16 acelp_4t64_ivas_fx(
case 36: /* EVS/AMR-WB pulse indexing: 36 bits, 8 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x20x16=1280 loops */
- config.alp = 8192;
- move16(); /* coeff FOR sign setting */
+ move16(); /* 4x20x16=1280 loops */
+ config.alp = 8192; /*1 in Q13*/
+ move16(); /* coeff FOR sign setting */
config.nb_pulse = 8;
move16();
config.fixedpulses = 2;
@@ -550,8 +550,8 @@ Word16 acelp_4t64_ivas_fx(
case 43: /* EVS pulse indexing: 43 bits, 10 pulses, 4 tracks */
case 44: /* AMR-WB pulse indexing: 44 bits, 10 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x26x16=1664 loops */
- config.alp = 8192;
+ move16(); /* 4x26x16=1664 loops */
+ config.alp = 8192; /*1 in Q13*/
move16();
config.nb_pulse = 10;
move16();
@@ -570,8 +570,8 @@ Word16 acelp_4t64_ivas_fx(
case 50: /* EVS pulse indexing: 50 bits, 12 pulses, 4 tracks */
case 52: /* AMR-WB pulse indexing: 52 bits, 12 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x26x16=1664 loops */
- config.alp = 8192;
+ move16(); /* 4x26x16=1664 loops */
+ config.alp = 8192; /*1 in Q13*/
move16();
config.nb_pulse = 12;
move16();
@@ -590,8 +590,8 @@ Word16 acelp_4t64_ivas_fx(
case 62: /* EVS pulse indexing: 62 bits, 16 pulses, 4 tracks */
case 64: /* AMR-WB pulse indexing: 64 bits, 16 pulses, 4 tracks */
config.nbiter = 3;
- move16(); /* 3x36x16=1728 loops */
- config.alp = 6554;
+ move16(); /* 3x36x16=1728 loops */
+ config.alp = 6554; /*.8f in Q13*/
move16();
config.nb_pulse = 16;
move16();
@@ -613,8 +613,8 @@ Word16 acelp_4t64_ivas_fx(
case 72: /* AMR-WB pulse indexing: 72 bits, 18 pulses, 4 tracks */
config.nbiter = 3;
- move16(); /* 3x35x16=1680 loops */
- config.alp = 6144;
+ move16(); /* 3x35x16=1680 loops */
+ config.alp = 6144; /*.75f in Q13*/
move16();
config.nb_pulse = 18;
move16();
@@ -638,8 +638,8 @@ Word16 acelp_4t64_ivas_fx(
case 88: /* AMR-WB pulse indexing: 88 bits, 24 pulses, 4 tracks */
config.nbiter = 2;
- move16(); /* 2x53x16=1696 loop */
- config.alp = 4096;
+ move16(); /* 2x53x16=1696 loop */
+ config.alp = 4096; /*.5f in Q13*/
move16();
config.nb_pulse = 24;
move16();
@@ -670,7 +670,7 @@ Word16 acelp_4t64_ivas_fx(
case 87: /* EVS pulse indexing: 87 bits, 26 pulses, 4 tracks */
config.nbiter = 1;
move16();
- config.alp = 4096;
+ config.alp = 4096; /*.5f in Q13*/
move16();
config.nb_pulse = 26;
move16();
@@ -709,7 +709,7 @@ Word16 acelp_4t64_ivas_fx(
}
config.codetrackpos = TRACKPOS_FIXED_FIRST;
- move16();
+ move32();
config.bits = nbbits;
move16();
@@ -905,7 +905,7 @@ static Word32 fcb_encode_cl_fx( /* o: class index of t
FOR( i = 0; i < pulse_num; i++ )
{
- k = L_sub( k, PI_select_table[L_sub( temp1, buffer[i] )][temp2--] );
+ k = L_sub( k, PI_select_table[temp1 - buffer[i]][temp2--] );
temp1 = L_sub( temp1, 1 );
}
@@ -917,7 +917,7 @@ static Word32 fcb_encode_cl_fx( /* o: class index of t
*encode fcb pulse index *
*---------------------------------------------------------------------*/
static Word32 fcb_encode_PI_fx( /* o: return index of the pulse on a track */
- const Word16 v[], /* i: pulse on a track */
+ const Word16 v[], /* i: pulse on a track Q9 */
const Word32 pulse_num /* i: number of the pulse on a track */
)
{
@@ -935,7 +935,7 @@ static Word32 fcb_encode_PI_fx( /* o: return index of t
/*encode the class and compute class offset*/
code_index = L_add( code_index, fcb_encode_class_fx( sector_p_num, pulse_num, pulse_pos_num ) );
- code_index = L_add( PI_offset[pulse_num][L_sub( L_add( pulse_num, 1L ), pulse_pos_num )], L_add( L_shl( code_index, extract_l( pulse_pos_num ) ), sign ) );
+ code_index = L_add( PI_offset[pulse_num][( ( pulse_num + 1L ) - pulse_pos_num )], L_add( L_shl( code_index, extract_l( pulse_pos_num ) ), sign ) );
return code_index;
}
@@ -999,7 +999,7 @@ static Word32 fcb_encode_position_fx( /* o: return
FOR( i = 0; i < pos_num; i++ )
{
/*mmm1 -= PI_select_table_fx[sub(n,pos_vector[i]-1)][temp2--];*/
- mmm1 = L_sub( mmm1, PI_select_table[L_sub( n, add( pos_vector[i], 1 ) )][temp2--] );
+ mmm1 = L_sub( mmm1, PI_select_table[n - ( pos_vector[i] + 1 )][temp2--] );
}
}
ELSE
@@ -1008,7 +1008,7 @@ static Word32 fcb_encode_position_fx( /* o: return
FOR( i = 0; i < pos_num; i++ )
{
/*mmm1 -= PI_select_table_fx[n-pos_vector[i]-1][temp2--];*/
- mmm1 = L_sub( mmm1, PI_select_table[L_sub( n, add( pos_vector[i], 1 ) )][temp2--] );
+ mmm1 = L_sub( mmm1, PI_select_table[n - ( pos_vector[i] + 1 )][temp2--] );
n = L_sub( n, 1 );
}
}
@@ -1232,7 +1232,7 @@ static Word32 quant_4p_4N_fx( /* o : return 4*N bits
Word16 posA[4], posB[4];
Word32 index;
- n_1 = (Word16) ( N - 1 );
+ n_1 = sub( N, 1 );
move16();
nb_pos = shl( 1, n_1 ); /* nb_pos = (1< it doesn't need to be operated by Basic Operators */
- n_1 = (Word16) ( N - 1 );
- move16();
+ n_1 = sub( N, 1 );
nb_pos = shl( 1, n_1 ); /* nb_pos = (1< 1, Q0 */
+ move32();
IF( v[k] > 0 )
{
sign = L_shl( sign, 1 );
@@ -1492,6 +1494,7 @@ static Word32 pre_process_fx( /* o: return sign value
}
}
*pulse_pos_num = L_deposit_l( j );
+move32();
return sign;
}
@@ -1510,7 +1513,7 @@ return sign;
*--------------------------------------------------------------------------*/
Word16 E_ACELP_code43bit_fx(
- const Word16 code[],
+ const Word16 code[], /*Q9*/
UWord32 *ps,
Word16 *p,
UWord16 idxs[] )
@@ -1522,8 +1525,9 @@ Word16 E_ACELP_code43bit_fx(
Word32 L_tmp;
Word32 joint_index;
static const Word32 joint_offset = 3611648; /*offset for 3 pulses per track*/
+ move32();
Word16 saved_bits = 0;
-
+ move16();
FOR( track = 0; track < 2; track++ )
{
ps[track] = fcb_encode_PI_fx( code + track, 3 );
@@ -1535,19 +1539,19 @@ Word16 E_ACELP_code43bit_fx(
FOR( track = 2; track < NB_TRACK_FCB_4T; track++ )
{
i = j = i_mult2( track, NPMAXPT );
- move16();
+
FOR( k = track; k < 64; k += 4 )
{
IF( code[k] )
{
tmp = shr( k, 2 );
- if ( code[k] < 0 )
+ IF( code[k] < 0 )
{
tmp = add( tmp, 16 );
}
ind[j] = tmp;
move16();
- IF( GT_16( abs_s( code[k] ), 512 ) )
+ IF( GT_16( abs_s( code[k] ), 512 /*Q9*/ ) )
{
ind[j + 1] = tmp;
move16();
@@ -1580,6 +1584,8 @@ Word16 E_ACELP_code43bit_fx(
idxs[0] = extract_l( L_add( L_shl( ps[2], 9 ), ps[3] ) );
idxs[1] = extract_l( L_add( L_shl( joint_index, 2 ), L_shr( ps[2], 7 ) ) );
idxs[2] = extract_l( L_shr( joint_index, 14 ) );
-
+ move16();
+ move16();
+ move16();
return saved_bits;
}
diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c
index e11f068b60025545274b06dee47173f94398c4de..bea89f5116e8d52f17b82f8a096f21f546042360 100644
--- a/lib_enc/cod_ace_fx.c
+++ b/lib_enc/cod_ace_fx.c
@@ -22,19 +22,19 @@
*-------------------------------------------------------------------*/
Word16 coder_acelp_fx( /* o : SEGSNR for CL decision */
- const Word16 A[], /* i : coefficients 4xAz[M+1] */
- const Word16 Aq[], /* i : coefficients 4xAz_q[M+1] */
- const Word16 speech[], /* i : speech[-M..lg] */
+ const Word16 A[], /* i : coefficients 4xAz[M+1] Qx*/
+ const Word16 Aq[], /* i : coefficients 4xAz_q[M+1] Q12*/
+ const Word16 speech[], /* i : speech[-M..lg] Qx*/
Word16 *prm, /* o : acelp parameters */
- Word16 stab_fac,
+ Word16 stab_fac, /*Q15 */
Encoder_State *st,
PLC_ENC_EVS_HANDLE hPlc_Ext,
const Word16 target_bits, /* i/o: coder memory state */
const Word16 Q_new,
const Word16 shift,
Word16 *pitch_buf, /* o : pitch values for each subfr.*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc /* o : excitation for SWB TBE */
+ Word16 *voice_factors, /* o : voicing factors Q15 */
+ Word16 *bwe_exc /* o : excitation for SWB TBE Qx */
)
{
#ifndef SIMPLIFY_CODE_BE
@@ -73,13 +73,17 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
Word16 code2[L_SUBFR];
Word16 y22[L_SUBFR]; /* Filtered adaptive excitation */
Word16 error = 0;
- Word16 gain_preQ = 0; /* Gain of prequantizer excitation */
+ move16();
+ Word16 gain_preQ = 0; /* Gain of prequantizer excitation */
+ move16();
Word16 code_preQ[L_SUBFR]; /* Prequantizer excitation */
Word16 dummy = 0;
+ move16();
ACELP_config *acelp_cfg;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
acelp_cfg = &( st->acelp_cfg );
@@ -109,8 +113,9 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
move16();
move16();
move16();
+ move16();
L_frame = st->L_frame;
-
+ move16();
/*------------------------------------------------------------------------*
* Previous frame is TCX (for non-EVS modes)(deactivated permanently) *
@@ -126,11 +131,10 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
Q_new_p5 = add( Q_new, 5 );
/* Reset phase dispersion */
- IF( GT_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core > ACELP_CORE )
{
move16();
move16();
- move16();
hLPDmem->dm_fx.prev_gain_code = 0;
set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 );
@@ -138,8 +142,6 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
}
/* set excitation memory*/
- move16();
- move16();
exc = exc_buf + L_EXC_MEM;
Copy( hLPDmem->old_exc, exc_buf, L_EXC_MEM );
*( exc + st->L_frame ) = 0;
@@ -193,8 +195,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
* - find synthesis speech *
* - update states of weighting filter *
*------------------------------------------------------------------------*/
- move16();
- move16();
+
p_A = A;
p_Aq = Aq;
@@ -231,7 +232,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = Mode2_gp_clip( st->voicing_fx, i_subfr, st->coder_type, xn, st->clip_var_fx, L_SUBFR, Q_xn );
+ clip_gain = Mode2_gp_clip_fx( st->voicing_fx, i_subfr, st->coder_type, xn, st->clip_var_fx, L_SUBFR, Q_xn );
/*-----------------------------------------------------------------*
* - find unity gain pitch excitation (adaptive codebook entry) *
@@ -292,7 +293,10 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
g_corr.xy2_e = sub( g_corr.xy2_e, add( Q_xn, 9 ) ); /* -(Q_xn+9) (xn: Q_xn y2: Q9) */
g_corr.y1y2_e = sub( g_corr.y1y2_e, add( Q_xn, 9 ) ); /* -(Q_xn+9) (y1: Q_xn y2: Q9) */
g_corr.xx_e = sub( g_corr.xx_e, add( Q_xn, Q_xn ) ); /* -(Q_xn+Q_xn) (xn: Q_xn) */
-
+ move16();
+ move16();
+ move16();
+ move16();
/*----------------------------------------------------------------------*
* Add Gaussian excitation *
@@ -334,6 +338,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
IF( st->Opt_RF_ON )
{
hRF->rf_tilt_buf[i_subfr / L_SUBFR] = hLPDmem->tilt_code;
+ move16();
}
/*-----------------------------------------------------------------*
* Update memory of the weighting filter
@@ -354,6 +359,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
#else
hLPDmem->mem_w0 = shr( hLPDmem->mem_w0, shift ); /*Qnew-1*/
#endif
+ move16();
BASOP_SATURATE_WARNING_ON_EVS;
/*-------------------------------------------------------*
@@ -398,7 +404,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
exc2[i] = round_fx( L_shl( Ltmp, 1 ) );
BASOP_SATURATE_WARNING_ON_EVS
#endif
-
+ move16();
Ltmp2 = Mpy_32_16_1( gain_code, code[i] );
#ifdef BASOP_NOGLOB
Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 );
@@ -416,6 +422,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
BASOP_SATURATE_WARNING_ON_EVS
exc[i + i_subfr] = round_fx( Ltmp );
#endif
+ move16();
}
#endif
/*-----------------------------------------------------------------*
@@ -454,8 +461,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
/*----------------------------------------------------------*
* Update *
*----------------------------------------------------------*/
- move16();
- move16();
+
p_A += ( M + 1 );
p_Aq += ( M + 1 );
@@ -499,7 +505,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
tmp = hLPDmem->syn[M];
E_UTIL_deemph2( sub( Q_new, 1 ), syn, st->preemph_fac, L_frame, &tmp );
- if ( st->hTcxEnc != NULL )
+ IF( st->hTcxEnc != NULL )
{
bufferCopyFx( syn + L_frame - ( L_frame / 2 ), hTcxEnc->Txnq, shr( L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_Txnq*/, 0 /*Q_syn*/, 0 /*Q_Txnq*/ );
}
@@ -511,6 +517,6 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
/*Update MODE1*/
Copy( p_Aq, st->old_Aq_12_8_fx, M + 1 );
st->old_Es_pred_fx = Es_pred;
-
+ move16();
return 0;
}
diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c
index a07ee551ab99b6234e51a74d1802deefefad070f..aaa7e4e2e13f01ee0207daa1bad4b3d412ba7824 100644
--- a/lib_enc/cod_tcx.c
+++ b/lib_enc/cod_tcx.c
@@ -55,9 +55,7 @@
*
*-------------------------------------------------------------------*/
-#define SIMILAR_TNS_THRESHOLD ( 0.04f )
#define SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ( 1311 )
-#define TNS_GAIN_THRESHOLD_FOR_WHITE ( 3.0f )
#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ( 384 )
void TNSAnalysisStereo_fx(
Encoder_State **sts, /* i : encoder state handle */
@@ -132,7 +130,7 @@ void TNSAnalysisStereo_fx(
* Temporal Noise Shaping analysis *
*-----------------------------------------------------------*/
- IF( hTcxEnc->transform_type[k] == TCX_5 )
+ IF( EQ_16( hTcxEnc->transform_type[k], TCX_5 ) )
{
/* rearrange LF sub-window lines prior to TNS analysis & filtering */
tcx5TnsGrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), spectrum_fx );
@@ -141,12 +139,12 @@ void TNSAnalysisStereo_fx(
/* WMOPS: All initializations are either for safety or static (tables) and thus not to be counted */
ResetTnsData( &hTcxEnc->tnsData[k] );
- if ( st->hTcxCfg->pCurrentTnsConfig->maxOrder <= 0 )
+ IF( st->hTcxCfg->pCurrentTnsConfig->maxOrder <= 0 )
{
- break;
+ BREAK;
}
- CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, &hTcxEnc->tnsData[k], NULL );
+ CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, hTcxEnc->spectrum_e[k], &hTcxEnc->tnsData[k], NULL );
}
}
}
@@ -216,7 +214,7 @@ void TNSAnalysisStereo_fx(
sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )];
sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )];
- FOR( iFilter = sub( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
STnsFilter *pFilter[2];
struct TnsParameters const *pTnsParameters[2];
@@ -229,8 +227,8 @@ void TNSAnalysisStereo_fx(
* both filters for the decision
*/
- meanPredictionGain_fx = mac_r( L_mult( pFilter[0]->predictionGain, 16384 ), pFilter[1]->predictionGain, 16384 ); // Q7
- maxPredictionGain_fx = s_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q7
+ meanPredictionGain_fx = mac_r( L_mult( pFilter[0]->predictionGain, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain, 16384 /*0.5f Q15*/ ); // Q7
+ maxPredictionGain_fx = s_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q7
test();
test();
@@ -244,7 +242,7 @@ void TNSAnalysisStereo_fx(
}
test();
IF( LT_16( abs_s( sub( pFilter[0]->predictionGain, pFilter[1]->predictionGain ) ), mult( SIMILAR_TNS_THRESHOLD_FX_IN_Q15, meanPredictionGain_fx ) ) &&
- ( sts[0]->hTcxEnc->tnsData[k].nFilters == sts[1]->hTcxEnc->tnsData[k].nFilters ) )
+ ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) )
{
Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15
@@ -259,7 +257,9 @@ void TNSAnalysisStereo_fx(
test();
IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 || sts[1]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( meanLtpGain_fx, 19660 /* 0.6 in Q15*/ ) )
{
- ++sts[0]->hTcxEnc->tnsData[k].nFilters;
+
+ sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
/* When order parameter is evaluated as 0 and change in precision causes the flow to reach here,
this may result in crash later. Changing the filter type here so the order is taken here in further section */
IF( pFilter[0]->order != 0 )
@@ -272,7 +272,8 @@ void TNSAnalysisStereo_fx(
pFilter[0]->filterType = TNS_FILTER_ON_ZERO;
move16();
}
- ++sts[1]->hTcxEnc->tnsData[k].nFilters;
+ sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
IF( pFilter[1]->order != 0 )
{
pFilter[1]->filterType = TNS_FILTER_ON;
@@ -287,11 +288,12 @@ void TNSAnalysisStereo_fx(
ELSE
{
Word16 maxEnergyChange_fx;
- maxEnergyChange_fx = shr( add( GetTCXMaxenergyChange_ivas_fx( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), GetTCXMaxenergyChange_ivas_fx( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ) ), 1 );
+ maxEnergyChange_fx = mac_r( L_mult( GetTCXMaxenergyChange_ivas_fx( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ), GetTCXMaxenergyChange_ivas_fx( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 );
IF( GE_16( maxEnergyChange_fx, pTnsParameters[0]->minEnergyChange ) )
{
- ++sts[0]->hTcxEnc->tnsData[k].nFilters;
+ sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
/* When order parameter is evaluated as 0 and change in precision causes the flow to reach here,
this may result in crash later. Changing the filter type here so the order is taken here in further section */
IF( pFilter[0]->order != 0 )
@@ -304,7 +306,8 @@ void TNSAnalysisStereo_fx(
pFilter[0]->filterType = TNS_FILTER_ON_ZERO;
move16();
}
- ++sts[1]->hTcxEnc->tnsData[k].nFilters;
+ sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
IF( pFilter[1]->order != 0 )
{
pFilter[1]->filterType = TNS_FILTER_ON;
@@ -329,8 +332,12 @@ void TNSAnalysisStereo_fx(
{
pFilter[0]->filterType = TNS_FILTER_ON_ZERO;
pFilter[1]->filterType = TNS_FILTER_ON_ZERO;
- ++sts[0]->hTcxEnc->tnsData[k].nFilters;
- ++sts[1]->hTcxEnc->tnsData[k].nFilters;
+ move16();
+ move16();
+ sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
+ sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
}
ELSE IF( NE_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) /* sanity check */
{
@@ -361,7 +368,7 @@ void TNSAnalysisStereo_fx(
IF( EQ_16( tmpIntValue, 1 ) ) /* the TNS coefficients are sufficiently similar to equalize the two filters */
{
- FOR( i = sub( maxOrder, 1 ); i >= 0; i-- )
+ FOR( i = maxOrder - 1; i >= 0; i-- )
{
IF( LT_16( abs_s( pFilter[0]->coefIndex[i] ), abs_s( pFilter[1]->coefIndex[i] ) ) )
{
@@ -438,7 +445,7 @@ void TNSAnalysisStereo_fx(
move16();
sts[1]->hTcxEnc->fUseTns[k] = 0;
move16();
- FOR( iFilter = sub( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
sts[0]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF;
move16();
@@ -463,7 +470,7 @@ void TNSAnalysisStereo_fx(
move16();
sts[1]->hTcxEnc->fUseTns[k] = 0;
move16();
- FOR( iFilter = sub( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
ClearTnsFilterCoefficients( sts[0]->hTcxEnc->tnsData[k].filter + iFilter );
ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter );
@@ -478,9 +485,9 @@ void TNSAnalysisStereo_fx(
/* individual decision for each channel */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
+ IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
- continue;
+ CONTINUE;
}
Word8 isTCX10;
@@ -511,7 +518,7 @@ void TNSAnalysisStereo_fx(
move16();
sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )];
- FOR( iFilter = sub( sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
STnsFilter *pFilter;
struct TnsParameters const *pTnsParameters;
@@ -524,9 +531,10 @@ void TNSAnalysisStereo_fx(
{
test();
test();
- IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( sts[ch]->hTcxEnc->tcxltp_gain, 19660 ) )
+ IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( sts[ch]->hTcxEnc->tcxltp_gain, 19660 /*.6f in Q15*/ ) )
{
- ++sts[ch]->hTcxEnc->tnsData[k].nFilters;
+ sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
/* When order parameter is evaluated as 0 and change in precision causes the flow to reach here,
this may result in crash later. Changing the filter type here so the order is taken here in further section */
IF( pFilter->order != 0 )
@@ -546,7 +554,8 @@ void TNSAnalysisStereo_fx(
IF( GE_16( maxEnergyChange_fx, pTnsParameters->minEnergyChange ) )
{
- ++sts[ch]->hTcxEnc->tnsData[k].nFilters;
+ sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
/* When order parameter is evaluated as 0 and change in precision causes the flow to reach here,
this may result in crash later. Changing the filter type here so the order is taken here in further section */
IF( pFilter->order != 0 )
@@ -571,7 +580,8 @@ void TNSAnalysisStereo_fx(
{
pFilter->filterType = TNS_FILTER_ON_ZERO;
move16();
- ++sts[ch]->hTcxEnc->tnsData[k].nFilters;
+ sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
}
ELSE
{
@@ -599,7 +609,7 @@ void TNSAnalysisStereo_fx(
move16();
sts[ch]->hTcxEnc->tnsData[k].nFilters = 0;
move16();
- FOR( iFilter = sub( sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter );
sts[ch]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF;
@@ -615,9 +625,9 @@ void TNSAnalysisStereo_fx(
/* we have the decision, set filter data accordingly */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- if ( EQ_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
+ IF( EQ_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
- continue;
+ CONTINUE;
}
IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
@@ -637,7 +647,7 @@ void TNSAnalysisStereo_fx(
{
sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )];
- FOR( iFilter = sub( sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
STnsFilter *pFilter;
pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter;
@@ -662,9 +672,9 @@ void TNSAnalysisStereo_fx(
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
st = sts[ch];
- if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
+ IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
- continue;
+ CONTINUE;
}
IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) )
@@ -683,6 +693,7 @@ void TNSAnalysisStereo_fx(
test();
test();
test();
+ test();
IF( bWhitenedDomain && ( ch > 0 ) && /* test for identical TNS filter data in both channels */
sts[0]->hTcxCfg->fIsTNSAllowed && sts[0]->hTcxEnc->fUseTns[k] &&
sts[1]->hTcxCfg->fIsTNSAllowed && sts[1]->hTcxEnc->fUseTns[k] )
@@ -701,7 +712,7 @@ void TNSAnalysisStereo_fx(
IF( equalFilterData )
{
- FOR( iFilter = sub( st->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = st->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
const Word16 *pDataCh0 = (const Word16 *) &sts[0]->hTcxEnc->tnsData[k].filter[iFilter];
const Word16 *pDataCh1 = (const Word16 *) &sts[1]->hTcxEnc->tnsData[k].filter[iFilter];
@@ -711,18 +722,20 @@ void TNSAnalysisStereo_fx(
test();
WHILE( ( i >= 0 ) && EQ_16( pDataCh0[i], pDataCh1[i] ) )
{
+ test();
i = sub( i, 1 );
}
- if ( i >= 0 )
+ IF( i >= 0 )
{
equalFilterData = 0;
move16();
- break;
+ BREAK;
}
}
IF( equalFilterData )
{
st->hTcxEnc->tnsData[k].nFilters = i_mult( st->hTcxEnc->tnsData[k].nFilters, -1 ); /* signals common TNS */
+ move16();
}
}
}
@@ -747,7 +760,7 @@ void TNSAnalysisStereo_fx(
}
st->hTcxEnc->tnsData[k].tnsOnWhitenedSpectra = st->hTcxEnc->bTnsOnWhithenedSpectra[k];
-
+ move16();
EncodeTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], param_core[ch] + k * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, tnsSize[ch] + k, tnsBits[ch] + k );
}
diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c
index 890f98e12e9b5fa6b4f750cca9d3811999a14db6..ea0468587fe90c936f4a5f3acc203d2befc2b087 100644
--- a/lib_enc/cod_tcx_fx.c
+++ b/lib_enc/cod_tcx_fx.c
@@ -32,7 +32,7 @@ void HBAutocorrelation_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 left_overlap_mode, /* input: overlap mode of left window half */
Word16 right_overlap_mode, /* input: overlap mode of right window half */
- Word16 speech[], /* input: speech[-LFAC..L_frame+LFAC] */
+ Word16 speech[], /* input: speech[-LFAC..L_frame+LFAC] Qx*/
Word16 L_frame, /* input: frame length */
Word32 *r, /* output: autocorrelations vector */
Word16 m /* input : order of LP filter */
@@ -45,6 +45,7 @@ void HBAutocorrelation_fx(
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------*
@@ -64,7 +65,7 @@ void HBAutocorrelation_fx(
move16();
L_sum = L_deposit_l( 0 );
Overflow = 0;
- move16();
+ move32();
FOR( i = 0; i < len; i += 1 )
{
/* Test Addition */
@@ -76,7 +77,7 @@ void HBAutocorrelation_fx(
IF( Overflow )
{
Overflow = 0;
- move16();
+ move32();
shift = 1;
move16();
L_tmp = L_msu0( 0, y[i], y[i] );
@@ -91,7 +92,7 @@ void HBAutocorrelation_fx(
#else
L_sum = L_sub( L_sum, L_tmp );
#endif
- FOR( j = add( i, 1 ); j < len; j++ )
+ FOR( j = i + 1; j < len; j++ )
{
L_tmp = L_msu0( 0, y[j], y[j] );
L_tmp = L_shr( L_tmp, shift );
@@ -105,7 +106,7 @@ void HBAutocorrelation_fx(
IF( Overflow )
{
Overflow = 0;
- move16();
+ move32();
shift = add( shift, 1 );
L_tmp = L_shr( L_tmp, 1 );
#ifdef BASOP_NOGLOB /* Critical Overflow */
@@ -652,17 +653,19 @@ void TNSAnalysis_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 L_frame, /* input: frame length */
Word16 L_spec,
- Word16 tcxMode, /* input: TCX mode for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */
- Word8 isAfterACELP, /* input: Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */
- Word32 spectrum[], /* input: MDCT spectrum */
- STnsData *pTnsData, /* output: Tns data */
- Word8 *pfUseTns, /* output: Flag indicating if TNS is used */
- Word16 *predictionGain )
+ Word16 tcxMode, /* input: TCX mode for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */
+ Word8 isAfterACELP, /* input: Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */
+ Word32 spectrum[], /* input: MDCT spectrum Qx*/
+ STnsData *pTnsData, /* output: Tns data */
+ Word8 *pfUseTns, /* output: Flag indicating if TNS is used */
+ Word16 *predictionGain /*Q7*/
+)
{
Word32 buff[8];
Word16 tmp = 0; /* initialization only to avoid compiler warning, not counted */
Word16 tmp2 = 0; /* initialization only to avoid compiler warning, not counted */
-
+ move16();
+ move16();
/* Init TNS */
*pfUseTns = 0;
@@ -670,8 +673,7 @@ void TNSAnalysis_fx(
IF( hTcxCfg->fIsTNSAllowed != 0 )
{
- hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[sub( tcxMode, TCX_20 ) == 0][isAfterACELP];
- test();
+ hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[( tcxMode - TCX_20 ) == 0][isAfterACELP];
L_spec = hTcxCfg->pCurrentTnsConfig->iFilterBorders[0];
move16();
@@ -756,8 +758,7 @@ void TNSAnalysis_ivas_fx(
IF( hTcxCfg->fIsTNSAllowed != 0 )
{
- hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[sub( transform_type, TCX_20 ) == 0][isAfterACELP];
- test();
+ hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[( transform_type - TCX_20 ) == 0][isAfterACELP];
L_spec = hTcxCfg->pCurrentTnsConfig->iFilterBorders[0];
move16();
@@ -818,8 +819,8 @@ void TNSAnalysis_ivas_fx(
void ShapeSpectrum_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
- Word16 A[], /* input: quantized coefficients NxAz_q[M+1] */
- Word16 gainlpc[], /* output: MDCT gains for the previous frame */
+ Word16 A[], /* input: quantized coefficients NxAz_q[M+1] Q = 14 - norm(A[0])*/
+ Word16 gainlpc[], /* output: MDCT gains for the previous frame Q(15-gainlpc_e)*/
Word16 gainlpc_e[], /* output: MDCT gains exponents */
Word16 L_frame_glob, /* input: frame length */
Word16 L_spec,
@@ -834,6 +835,8 @@ void ShapeSpectrum_fx(
Word16 gainlpc_noinv_e[FDNS_NPTS];
Word16 i;
Word32 max_low_pre = 0, max_high_pre = 0;
+ move32();
+ move32();
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
/*-----------------------------------------------------------*
@@ -875,6 +878,7 @@ void ShapeSpectrum_fx(
IF( st->enablePlcWaveadjust )
{
hTcxCfg->SFM2 = SFM_Cal_fx( spectrum, s_min( 200, L_frame ) );
+ move32();
}
test();
@@ -897,7 +901,7 @@ void ShapeSpectrum_fx(
max_high_pre = 0;
move32();
- for ( i = 0; i < L_spec - L_frame; i++ )
+ FOR( i = 0; i < L_spec - L_frame; i++ )
{
Word32 tmp = L_abs( spectrum[L_frame + i] );
if ( GT_32( tmp, max_high_pre ) )
@@ -925,6 +929,8 @@ void ShapeSpectrum_fx(
/* reduce the peaks in the IGF region, to make life of the core-coder easier... */
test();
+ test();
+ test();
IF( ( EQ_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->bwidth, SWB ) ) ||
( EQ_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) ) )
{
@@ -967,7 +973,7 @@ void ShapeSpectrum_fx(
max_low1 = 0;
move32();
- FOR( i = 0; i < sub( L_frame, sf_width ); i++ )
+ FOR( i = 0; i < ( L_frame - sf_width ); i++ )
{
Word32 tmp = L_abs( spectrum[L_frame - sf_width - 1 - i] );
if ( GT_32( tmp, max_low1 ) )
@@ -975,7 +981,7 @@ void ShapeSpectrum_fx(
max_low1 = tmp;
move32();
}
- if ( tmp > max_low2 )
+ if ( GT_32( tmp, max_low2 ) )
{
dist_low = add( sf_width, i );
}
@@ -987,10 +993,10 @@ void ShapeSpectrum_fx(
move32();
dist_high = 0;
move16();
- FOR( i = 0; i < sub( L_spec, L_frame ); i++ )
+ FOR( i = 0; i < ( L_spec - L_frame ); i++ )
{
Word32 tmp = L_abs( spectrum[L_frame + i] );
- if ( GT_32( tmp, max_high ) )
+ IF( GT_32( tmp, max_high ) )
{
max_high = tmp;
move32();
@@ -1036,6 +1042,7 @@ void ShapeSpectrum_fx(
FOR( i = 0; i < sub( L_spec, L_frame ); i++ )
{
spectrum[L_frame + i] = Mpy_32_16_1( spectrum[L_frame + i], fac );
+ move32();
}
}
}
@@ -1052,11 +1059,11 @@ void ShapeSpectrum_fx(
void ShapeSpectrum_ivas_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 A[], /* input: quantized coefficients NxAz_q[M+1], Q = 14 - norm(A[0]) */
- Word16 gainlpc[], /* output: MDCT gains for the previous frame */
+ Word16 gainlpc[], /* output: MDCT gains for the previous frame Q(15-gainlpc_e)*/
Word16 gainlpc_e[], /* output: MDCT gains exponents */
Word16 L_frame_glob, /* input: frame length */
Word16 L_spec,
- Word32 spectrum[], /* i/o: MDCT spectrum */
+ Word32 spectrum[], /* i/o: MDCT spectrum Q(31-spectrum_e) */
Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */
Word8 pfUseTns, /* output: Flag indicating if TNS is used */
Encoder_State *st,
@@ -1075,6 +1082,13 @@ void ShapeSpectrum_ivas_fx(
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
move32();
move32();
+ Word32 total_brate = st->total_brate;
+ move32();
+ if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ total_brate = st->element_brate;
+ move32();
+ }
/*-----------------------------------------------------------*
* Init *
@@ -1098,7 +1112,7 @@ void ShapeSpectrum_ivas_fx(
{
L_frame = add( L_frame, hTcxCfg->tcx_offset );
L_spec = add( L_spec, shr( hTcxCfg->tcx_coded_lines, 2 ) );
- IF( hTcxCfg->lfacNext < 0 )
+ if ( hTcxCfg->lfacNext < 0 )
{
L_frame = sub( L_frame, hTcxCfg->lfacNext );
move16();
@@ -1110,7 +1124,7 @@ void ShapeSpectrum_ivas_fx(
tcxGetNoiseFillingTilt( A,
M,
L_frame,
- ( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 ),
+ ( GE_32( total_brate, ACELP_13k20 ) && st->rf_mode == 0 ),
&hTcxEnc->noiseTiltFactor );
/* Calculate Spectrum Flatness Measure for the TCX Concealment */
@@ -1121,7 +1135,7 @@ void ShapeSpectrum_ivas_fx(
}
test();
- IF( LE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
+ IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
{
max_low_pre = 0;
move32();
@@ -1160,19 +1174,18 @@ void ShapeSpectrum_ivas_fx(
test();
IF( NE_16( len, L_spec ) && LT_16( add( q_spectrum, 1 ), sub( 31, *spectrum_e ) ) )
{
- scale_sig32( spectrum + len, sub( L_spec, len ), sub( add( q_spectrum, 1 ), sub( 31, *spectrum_e ) ) );
+ scale_sig32( spectrum + len, sub( L_spec, len ), sub( add( q_spectrum, 1 ), sub( 31, *spectrum_e ) ) ); // Q31
}
ELSE IF( NE_16( len, L_spec ) && GT_16( add( q_spectrum, 1 ), sub( 31, *spectrum_e ) ) )
{
- scale_sig32( spectrum, len, sub( sub( 31, *spectrum_e ), add( q_spectrum, 1 ) ) );
+ scale_sig32( spectrum, len, sub( sub( 31, *spectrum_e ), add( q_spectrum, 1 ) ) ); // Q(30-specturm_e)
q_spectrum = sub( 31 - 1, *spectrum_e );
}
FOR( i = L_frame; i < L_spec; i++ )
{
W_tmp = W_mult0_32_32( spectrum[i], sns_int_scf[hTcxCfg->psychParamsCurrent->nBands - 1] );
- W_tmp = W_shr( W_tmp, Q16 );
- spectrum[i] = W_extract_l( W_tmp );
+ spectrum[i] = W_extract_h( W_shl( W_tmp, Q16 ) );
move32();
}
*spectrum_e = sub( 31 - 1, q_spectrum ); // As the output spectrum from sns_shape_spectrum_fx has Q = q_spectrum + 1
@@ -1198,7 +1211,7 @@ void ShapeSpectrum_ivas_fx(
/* reduce the peaks in the IGF region, to make life of the core-coder easier... */
test();
- IF( LE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
+ IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
{
Word16 sf_width;
Word16 dist_low, dist_high;
@@ -1247,7 +1260,7 @@ void ShapeSpectrum_ivas_fx(
max_low1 = tmp;
move32();
}
- IF( GT_32( tmp, max_low2 ) )
+ if ( GT_32( tmp, max_low2 ) )
{
dist_low = add( sf_width, i );
}
@@ -1259,10 +1272,10 @@ void ShapeSpectrum_ivas_fx(
move32();
dist_high = 0;
move16();
- FOR( i = 0; i < sub( L_spec, L_frame ); i++ )
+ FOR( i = 0; i < ( L_spec - L_frame ); i++ )
{
Word32 tmp = L_abs( spectrum[L_frame + i] );
- if ( GT_32( tmp, max_high ) )
+ IF( GT_32( tmp, max_high ) )
{
max_high = tmp;
move32();
@@ -1526,15 +1539,15 @@ static Word16 GetTransWidth_ivas_fx(
static void EstimateTCXNoiseLevel_ivas_fx(
Encoder_State *st, /* i : encoder state handle */
- Word32 x_orig[], /* i : shaped MDCT spectrum */
+ Word32 x_orig[], /* i : shaped MDCT spectrum Q(31-x_orig_e) */
Word16 x_orig_e, /* i : shaped MDCT spectrum exponent */
Word32 spectrum[], /* i/o: quantized MDCT spectrum */
- const Word16 gain_tcx, /* i : global gain */
+ const Word16 gain_tcx, /* i : global gain Q(15-gain_tcx_e) */
const Word16 gain_tcx_e, /* i : global gain exponent */
const Word16 L_frame, /* i : frame length */
const Word16 noiseFillingBorder, /* i : noise filling border */
const Word16 hm_active, /* i : flag indicating if the harmonic model is active */
- Word16 *fac_ns, /* o : noise filling level, Q15 */
+ Word16 *fac_ns, /* o : noise filling level, fac_ns_q */
Word16 *fac_ns_q /* o : quantized noise filling level, Q0 */
)
{
@@ -1628,7 +1641,7 @@ void QuantizeSpectrum_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 A_fx[], /* i : quantized coefficients NxAz_q[M+1], Q = 14 - norm_s(A_fx[0]) */
const Word16 Aqind[], /* i : frame-independent quantized coefficients (M+1) */
- Word16 gainlpc_fx[], /* i : MDCT gains of the previous frame */
+ Word16 gainlpc_fx[], /* i : MDCT gains of the previous frame Q(15-gainlpc_e) */
Word16 gainlpc_e[], /* i : exponents of MDCT gains of the previous frame */
Word16 synth[], /* o : synthesis buffer, Q0 */
const Word16 nb_bits, /* i : bit budget */
@@ -1665,6 +1678,12 @@ void QuantizeSpectrum_ivas_fx(
QuantizeTCXSpectrum_fx( st, frame_cnt, hTcxEnc->spectrum_fx[frame_cnt], hTcxEnc->spectrum_e[frame_cnt], gainlpc_fx, gainlpc_e, Aqind, tnsSize, nb_bits, vad_hover_flag,
&L_frameTCX, &L_frame, &L_spec, &tcx_offset, &noiseFillingBorder, quantized_spectrum_fx, &quantized_spectrum_e, hm_cfg, &hm_active, lf_deemph_fact_fx, &nf_seed, &ener_fx, &ener_e, &gain_tcx_fx, &gain_tcx_e, prm );
+ if ( hTcxEnc->spectrum_e[frame_cnt] < 0 )
+ {
+ /*buffer is already scaled inside QuantizeTCXSpectrum_fx*/
+ hTcxEnc->spectrum_e[frame_cnt] = 0;
+ move16();
+ }
Word16 s1 = sub( getScaleFactor32( st->hTcxEnc->spectrum_fx[frame_cnt], L_frame ), 6 );
Word16 s2 = getScaleFactor32( quantized_spectrum_fx, s_max( L_frame, L_spec ) );
@@ -1707,8 +1726,8 @@ void QuantizeSpectrum_ivas_fx(
void EstimateStereoTCXNoiseLevel_fx(
Encoder_State **sts, /* i : state handle */
- Word32 *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum */
- Word16 gain_tcx[][NB_DIV], /* i : global gain */
+ Word32 *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum Qx */
+ Word16 gain_tcx[][NB_DIV], /* i : global gain Q(15-gain_tcx_e) */
Word16 gain_tcx_e[][NB_DIV], /* i : global gain exponent */
Word16 L_frame[][NB_DIV], /* i : frame length */
Word16 noiseFillingBorder[][NB_DIV], /* i : noise filling border */
@@ -1742,9 +1761,9 @@ void EstimateStereoTCXNoiseLevel_fx(
move16();
}
- if ( ignore_chan[ch] )
+ IF( ignore_chan[ch] )
{
- continue;
+ CONTINUE;
}
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag )
@@ -1811,8 +1830,8 @@ void EstimateStereoTCXNoiseLevel_fx(
test();
IF( L_tmp != 0 || L_tmp1 != 0 )
{
- scale_sig32( hTcxEnc->spectrum_fx[n], L_frame[ch][n], -Q1 );
- scale_sig32( combined_q_spectrum, L_frame[ch][n], -Q1 );
+ scale_sig32( hTcxEnc->spectrum_fx[n], L_frame[ch][n], -Q1 ); // Q(31-(spectrum_e+1)
+ scale_sig32( combined_q_spectrum, L_frame[ch][n], -Q1 ); // Q(31-(spectrum_e+1)
hTcxEnc->spectrum_e[n] = add( hTcxEnc->spectrum_e[n], Q1 );
move16();
}
@@ -1842,6 +1861,7 @@ void EstimateStereoTCXNoiseLevel_fx(
ELSE
{
hTcxEnc->noiseLevelMemory_cnt = sub( -1, hTcxEnc->noiseLevelMemory_cnt );
+ move16();
}
}
ELSE
@@ -1861,7 +1881,7 @@ void QuantizeSpectrum_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 A[], /* input: quantized coefficients NxAz_q[M+1] */
Word16 Aqind[], /* input: frame-independent quantized coefficients (M+1) */
- Word16 gainlpc[], /* input: MDCT gains of the previous frame */
+ Word16 gainlpc[], /* input: MDCT gains of the previous frame Q(15-gainlpc_e)*/
Word16 gainlpc_e[], /* input: MDCT gains exponents */
Word16 synth[],
Word16 L_frame_glob, /* input: frame length */
@@ -1869,7 +1889,7 @@ void QuantizeSpectrum_fx(
Word16 L_spec,
Word16 nb_bits, /*input: bit budget*/
Word8 tcxonly, /*input: only TCX flag*/
- Word32 spectrum[], /* i/o: MDCT spectrum, input is shaped MDCT spectrum */
+ Word32 spectrum[], /* i/o: MDCT spectrum, input is shaped MDCT spectrum Q(31-spectrum_e) */
Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */
STnsData *pTnsData, /* input: Tns data */
Word8 fUseTns, /* input: Flag indicating if TNS is used */
@@ -2087,6 +2107,7 @@ void QuantizeSpectrum_fx(
FOR( i = st->hIGFEnc->infoStopLine; i < L_frameTCX; i++ )
{
spectrum[i] = L_deposit_l( 0 );
+ move32();
}
/*-----------------------------------------------------------*
@@ -2297,6 +2318,7 @@ void QuantizeSpectrum_fx(
#else /* BASOP_NOGLOB */
hTcxEnc->tcx_target_bits_fac = shl( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 );
#endif /* BASOP_NOGLOB */
+ move16();
BASOP_SATURATE_WARNING_ON_EVS
if ( GT_16( hTcxEnc->tcx_target_bits_fac, 0x5000 ) )
@@ -2529,7 +2551,7 @@ void QuantizeSpectrum_fx(
tmp8 = 1;
move16();
- if ( EQ_16( st->last_core, ACELP_CORE ) )
+ if ( st->last_core == ACELP_CORE )
{
tmp8 = 0;
move16();
@@ -2598,7 +2620,7 @@ void QuantizeSpectrum_fx(
/*-----------------------------------------------------------*
* Quantize TCX gain *
*-----------------------------------------------------------*/
-
+ test();
IF( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 )
{
QuantizeGain( L_spec, &gain_tcx, &gain_tcx_e, &prm[0] );
@@ -2695,6 +2717,7 @@ void QuantizeSpectrum_fx(
{
/* noise filling start bin */
i = shr( L_frame, 3 );
+ test();
IF( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 )
{
i = idiv1616U( L_frame, 6 );
@@ -2736,6 +2759,7 @@ void QuantizeSpectrum_fx(
IF( EQ_16( prm[NOISE_FILL_RANGES], 1 ) )
{
hTcxEnc->noiseLevelMemory_cnt = add( 1, abs_s( hTcxEnc->noiseLevelMemory_cnt ) ); /* update counter */
+ move16();
}
ELSE
{
@@ -2756,6 +2780,7 @@ void QuantizeSpectrum_fx(
tmp1 = sub( -1, hTcxEnc->noiseLevelMemory_cnt );
}
hTcxEnc->noiseLevelMemory_cnt = tmp1;
+ move16();
}
ELSE
{
@@ -2790,6 +2815,7 @@ void QuantizeSpectrum_fx(
* Noise Filling. *
*-----------------------------------------------------------*/
+ test();
/* Replication of ACELP formant enhancement for low rates */
IF( LT_32( st->total_brate, ACELP_13k20 ) || st->rf_mode != 0 )
{
@@ -2800,6 +2826,7 @@ void QuantizeSpectrum_fx(
{
tmp1 = 0;
move16();
+ test();
if ( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 )
{
tmp1 = 1;
@@ -2814,7 +2841,7 @@ void QuantizeSpectrum_fx(
tcx_noise_filling( spectrum, *spectrum_e, nf_seed /* seed */, i, noiseFillingSize, noiseTransWidth, L_frame, hTcxEnc->noiseTiltFactor, fac_ns, NULL, st->element_mode );
}
-
+ test();
IF( LT_32( st->total_brate, ACELP_13k20 ) || st->rf_mode != 0 )
{
/* partially recompute global gain (energy part), taking noise filling and formant enhancement into account */
@@ -2849,14 +2876,14 @@ void QuantizeSpectrum_fx(
/*-----------------------------------------------------------*
* Apply gain *
*-----------------------------------------------------------*/
- IF( EQ_16( st->hTcxCfg->coder_type, INACTIVE ) )
+ IF( st->hTcxCfg->coder_type == INACTIVE )
{
gain_tcx = mult_r( gain_tcx, hTcxCfg->na_scale );
}
FOR( i = 0; i < L_spec; i++ )
{
- spectrum[i] = Mpy_32_16_1( spectrum[i], gain_tcx );
+ spectrum[i] = Mpy_32_16_1( spectrum[i], gain_tcx ); // Q(31-(spectrum_e+gain_tcx_e))
move32();
}
*spectrum_e = add( *spectrum_e, gain_tcx_e );
@@ -2896,8 +2923,6 @@ void QuantizeSpectrum_fx(
IF( hTcxCfg->fIsTNSAllowed != 0 )
{
- test();
- test();
test();
SetTnsConfig( hTcxCfg, sub( L_frame_glob, st->L_frame ) == 0, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) );
@@ -2931,7 +2956,7 @@ void QuantizeSpectrum_fx(
s = getScaleFactor32( spectrum, L_frame );
FOR( i = 0; i < L_frame; i++ )
{
- spectrum[i] = L_shl( spectrum[i], s );
+ spectrum[i] = L_shl( spectrum[i], s ); // Q(31-(spectrum_e-s))
move32();
}
*spectrum_e = sub( *spectrum_e, s );
@@ -3115,7 +3140,6 @@ void QuantizeSpectrum_fx(
0 );
- move16();
tmpP16 = xn_buf16 + add( sub( L_win, shr( L_ola, 1 ) ), shr( overlap, 1 ) );
tcx_windowing_synthesis_past_frame( tmpP16,
@@ -3144,7 +3168,7 @@ void QuantizeSpectrum_fx(
L_win );
/* extra folding-out on left side of win, for perfect reconstruction */
- FOR( w = shr( overlap, 1 ); w < overlap; w++ )
+ FOR( w = overlap / 2; w < overlap; w++ )
{
xn_buf16[overlap - 1 - w] = negate( xn_buf16[w] );
move16();
@@ -3546,9 +3570,9 @@ static Word16 DecideTonalSideInfo_fx(
void QuantizeTCXSpectrum_fx(
Encoder_State *st, /* i : state handle */
const Word16 frame_cnt, /* i : frame counter in the super_frame Q0 */
- Word32 *x_orig_fx, /* i : shaped MDCT spectrum */
- const Word16 x_orig_e, /* i : exp of shaped MDCT spectrum */
- Word16 *gainlpc_fx, /* i : FDNS gains */
+ Word32 *x_orig_fx, /* i : shaped MDCT spectrum Q(31-x_orig_e)*/
+ Word16 x_orig_e, /* i : exp of shaped MDCT spectrum */
+ Word16 *gainlpc_fx, /* i : FDNS gains Q(15-gainlpc_e)*/
Word16 *gainlpc_e, /* i : exp of FDNS gains */
const Word16 *Aqind, /* i : frame-independent quantized coefficients (M+1) Q0 */
const Word16 tnsSize, /* i : number of tns parameters put into prm Q0 */
@@ -3559,15 +3583,15 @@ void QuantizeTCXSpectrum_fx(
Word16 *pL_spec, /* o : length of the coded spectrum Q0 */
Word16 *ptcx_offset, /* o : folding point offset relative to the end of the previous frame Q0 */
Word16 *pnoiseFillingBorder, /* o : noise filling border Q0 */
- Word32 spectrum_fx[], /* o : quantized MDCT spectrum */
+ Word32 spectrum_fx[], /* o : quantized MDCT spectrum Q(31-spectrum_e)*/
Word16 *spectrum_e, /* o : exp of quantized MDCT spectrum */
CONTEXT_HM_CONFIG *hm_cfg, /* o : Context-based harmonic model configuration */
Word16 *hm_active, /* o : flag indicating if the harmonic model is active */
Word16 lf_deemph_fact_fx[], /* o : low frequency deemphasis factors Q14*/
Word16 *nf_seed, /* o : noise filling random seed Q0*/
- Word32 *ener_fx, /* o : energy of the quantized spectrum */
+ Word32 *ener_fx, /* o : energy of the quantized spectrum Q(31-ener_e) */
Word16 *ener_e, /* o : exp of energy of the quantized spectrum */
- Word16 *gain_tcx_fx, /* o : global gain */
+ Word16 *gain_tcx_fx, /* o : global gain Q(15-gain_tcx_e) */
Word16 *gain_tcx_e, /* o : exp of global gain */
Word16 prm[] /* o : tcx parameters Q0 */
)
@@ -3692,6 +3716,7 @@ void QuantizeTCXSpectrum_fx(
IF( EQ_16( st->core, TCX_20_CORE ) )
{
L_frame_glob = st->L_frame;
+ move16();
}
ELSE
{
@@ -3702,6 +3727,15 @@ void QuantizeTCXSpectrum_fx(
}
/* Start with the pre-shaped spectrum*/
+
+ /*scaling buffer to Q31 if exp < 0 to avoid overflow while scaling constants*/
+ IF( x_orig_e < 0 )
+ {
+ scale_sig32( x_orig_fx, L_spec, x_orig_e );
+ x_orig_e = 0;
+ move16();
+ }
+
Copy32( x_orig_fx, spectrum_fx, L_spec );
*spectrum_e = x_orig_e;
move16();
@@ -3793,7 +3827,7 @@ void QuantizeTCXSpectrum_fx(
}
/* Quantize original spectrum */
- sqGain_fx = SQ_gain_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e );
+ sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e );
tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly );
@@ -3802,7 +3836,7 @@ void QuantizeTCXSpectrum_fx(
move16();
IF( st->element_mode > EVS_MONO )
{
- sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, &lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
+ sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, &lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
}
ELSE
{
@@ -3816,7 +3850,7 @@ void QuantizeTCXSpectrum_fx(
/* Context Mapping */
IF( st->element_mode > EVS_MONO )
{
- sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, &lastnzCtxHm, &nEncodedCtxHm, sqTargetBits - NumIndexBits, &stopCtxHm, 0, hm_cfg );
+ sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, &lastnzCtxHm, &nEncodedCtxHm, sqTargetBits - NumIndexBits, &stopCtxHm, 0, hm_cfg );
}
ELSE
{
@@ -3881,7 +3915,7 @@ void QuantizeTCXSpectrum_fx(
}
ELSE
{
- sqGain_fx = SQ_gain_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e );
+ sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e );
}
/* Quantize spectrum */
tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly );
@@ -3892,7 +3926,7 @@ void QuantizeTCXSpectrum_fx(
IF( st->element_mode > EVS_MONO )
{
- sqBits_noStop = sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, prm_lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
+ sqBits_noStop = sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, prm_lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
move16();
}
ELSE
@@ -3926,12 +3960,12 @@ void QuantizeTCXSpectrum_fx(
#endif /* BASOP_NOGLOB */
BASOP_SATURATE_WARNING_ON_EVS
- if ( GT_16( hTcxEnc->tcx_target_bits_fac, 20480 ) )
+ if ( GT_16( hTcxEnc->tcx_target_bits_fac, 20480 /*1.25 in Q14*/ ) )
{
hTcxEnc->tcx_target_bits_fac = 20480;
move16();
}
- if ( LT_16( hTcxEnc->tcx_target_bits_fac, 12288 ) )
+ if ( LT_16( hTcxEnc->tcx_target_bits_fac, 12288 /*.75 in Q14*/ ) )
{
hTcxEnc->tcx_target_bits_fac = 12288;
move16();
@@ -3981,7 +4015,7 @@ void QuantizeTCXSpectrum_fx(
IF( st->element_mode > EVS_MONO )
{
/* Fix: Use updated value for target bits (sqTargetBits + NumIndexBits) before computing non-mapped estimate */
- sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, &lastnz, &nEncodedCtxHm, sqTargetBits + NumIndexBits, &stopCtxHm, 0, NULL );
+ sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, &lastnz, &nEncodedCtxHm, sqTargetBits + NumIndexBits, &stopCtxHm, 0, NULL );
}
ELSE
{
@@ -4056,7 +4090,7 @@ void QuantizeTCXSpectrum_fx(
move16();
IF( st->element_mode > EVS_MONO )
{
- sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, &lastnzCtxHm, &nEncodedCtxHm, sqTargetBits - NumIndexBits, &stopCtxHm, 0, hm_cfg );
+ sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, &lastnzCtxHm, &nEncodedCtxHm, sqTargetBits - NumIndexBits, &stopCtxHm, 0, hm_cfg );
}
ELSE
{
@@ -4170,7 +4204,7 @@ void QuantizeTCXSpectrum_fx(
sqTargetBits = add( sqTargetBits, NumIndexBits );
ctxHmBits = sub( ctxHmBits, NumIndexBits );
}
- sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, prm_lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
+ sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, prm_lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
}
ELSE
{
@@ -4194,8 +4228,10 @@ void QuantizeTCXSpectrum_fx(
FOR( i = 0; i < L_spec; i++ )
{
spectrum_fx[i] = (Word32) sqQ[i];
+ move32();
/* noise filling seed */
*nf_seed = (Word16) L_add( *nf_seed, L_mult0( abs_s( sqQ[i] ), shl( i, 1 ) ) );
+ move16();
}
tmp32 = L_deposit_l( 0 );
@@ -4236,7 +4272,7 @@ void QuantizeTCXSpectrum_fx(
Word8 tmp8 = 1;
move16();
- if ( ( st->last_core == ACELP_CORE ) )
+ if ( st->last_core == ACELP_CORE )
{
tmp8 = 0;
move16();
@@ -4300,6 +4336,7 @@ void QuantizeTCXSpectrum_fx(
{
calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
*gain_tcx_fx = mult( *gain_tcx_fx, att_fx );
+ move16();
}
/*-----------------------------------------------------------*
@@ -4383,13 +4420,13 @@ void coder_tcx_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 A[], /* input: quantized coefficients NxAz_q[M+1] */
Word16 Aqind[], /* input: frame-independent quantized coefficients (M+1) */
- Word16 synth[],
- Word16 L_frame_glob, /* input: frame length */
+ Word16 synth[], /*Qx*/
+ Word16 L_frame_glob, /* input: frame length */
Word16 L_frameTCX_glob,
Word16 L_spec,
Word16 nb_bits, /*input: bit budget*/
Word8 tcxonly, /*input: only TCX flag*/
- Word32 spectrum[], /* i/o: MDCT spectrum */
+ Word32 spectrum[], /* i/o: MDCT spectrum Q(31-spectrum_e)*/
Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */
Word16 prm[], /* output: tcx parameters */
Encoder_State *st,
@@ -4485,6 +4522,7 @@ void coder_tcx_fx(
/* DCT */
edct_fx( tmp_buf, spectrum, L_frame, &Q );
*spectrum_e = sub( 31, Q );
+ move16();
}
@@ -4523,8 +4561,7 @@ void coder_tcx_fx(
powerSpec, &powerSpec_e );
IF( hTcxCfg->fIsTNSAllowed != 0 )
{
- test();
- test();
+
SetTnsConfig( hTcxCfg, sub( L_frame_glob, st->L_frame ) == 0, st->last_core == 0 );
TNSAnalysis_fx( hTcxCfg, L_frame, L_spec, TCX_20, st->last_core == 0, spectrum, hTcxEnc->tnsData, hTcxEnc->fUseTns, &st->hIGFEnc->tns_predictionGain );
@@ -4577,6 +4614,7 @@ void coder_tcx_fx(
#ifndef MSAN_FIX
hLPDmem->nbits = add( hLPDmem->nbits, add( tnsBits, ltpBits ) );
+ move16();
#endif
}
@@ -4655,18 +4693,18 @@ void InternalTCXDecoder_fx(
const Word16 tcx_offset, /* i : folding point offset relative to the end of the previous frame */
const Word16 noiseFillingBorder, /* i : noise filling border */
const Word32 *x_quant_fx, /* i : quantized spectrum, exponent same as spectrum_e */
- const Word32 ener_fx, /* i : energy of the quantized spectrum */
+ const Word32 ener_fx, /* i : energy of the quantized spectrum Q(31-ener_e) */
const Word16 ener_e, /* i : exponent of energy of the quantized spectrum */
Word16 lf_deemph_fact_fx[], /* i/o: low frequency deemphasis factors */
const Word16 fac_ns_fx, /* i : noise filling level, Q15 */
const Word16 nf_seed, /* i : noise filling random seed, Q0 */
const Word16 *A_fx, /* i : LPC representation of the FDNS gains, Q = 14 - norm_s(A_fx[0]) */
- Word16 gainlpc_fx[], /* i/o: FDNS gains */
+ Word16 gainlpc_fx[], /* i/o: FDNS gains Q(15-gainlpc_e) */
Word16 gainlpc_e[], /* i/o: FDNS gains exponents */
const Word16 hm_active, /* i : flag indicating if the harmonic model is active */
- Word16 gain_tcx_fx, /* i/o: global gain / quantized global gain */
+ Word16 gain_tcx_fx, /* i/o: global gain / quantized global gain Q(15-gain_tcx_e) */
Word16 *gain_tcx_e, /* i/o: global gain / quantized global gain exponent */
- Word32 spectrum_fx[], /* o : dequantized spectrum */
+ Word32 spectrum_fx[], /* o : dequantized spectrum Q(31-spectrum_e) */
Word16 *spectrum_e, /* o : exponent of dequantized spectrum */
Word16 synth[], /* o : time domain signal */
Word16 *gain_tcx_q /* o : quantized global gain (at low bitrates), Q0 */
@@ -4746,7 +4784,7 @@ void InternalTCXDecoder_fx(
tmp2 = add( tmp2, sub( ener_e, add( shl( sub( *spectrum_e, s ), 1 ), 1 ) ) );
tmp1 = Sqrt16( tmp1, &tmp2 );
- gain_tcx_fx = mult( gain_tcx_fx, tmp1 );
+ gain_tcx_fx = mult( gain_tcx_fx, tmp1 ); // Q(15-(gain_tcx_e+tmp2))
*gain_tcx_e = add( *gain_tcx_e, tmp2 );
move16();
@@ -4771,11 +4809,11 @@ void InternalTCXDecoder_fx(
test();
IF( NE_16( len, L_frame ) && LT_16( q_spec, sub( 31, *spectrum_e ) ) )
{
- scale_sig32( spectrum_fx + len, sub( L_frame, len ), sub( q_spec, sub( 15, *spectrum_e ) ) );
+ scale_sig32( spectrum_fx + len, sub( L_frame, len ), sub( q_spec, sub( 15, *spectrum_e ) ) ); // q_spec
}
ELSE IF( NE_16( len, L_frame ) && GT_16( q_spec, sub( 31, *spectrum_e ) ) )
{
- scale_sig32( spectrum_fx, len, sub( sub( 15, *spectrum_e ), q_spec ) );
+ scale_sig32( spectrum_fx, len, sub( sub( 15, *spectrum_e ), q_spec ) ); // Q(31-spectrum_e)
q_spec = sub( 31, *spectrum_e );
}
*spectrum_e = sub( 31, q_spec );
@@ -4789,7 +4827,7 @@ void InternalTCXDecoder_fx(
* Apply gain *
*-----------------------------------------------------------*/
- IF( EQ_16( st->hTcxCfg->coder_type, INACTIVE ) )
+ IF( st->hTcxCfg->coder_type == INACTIVE )
{
gain_tcx_fx = mult_r( gain_tcx_fx, st->hTcxCfg->na_scale );
}
@@ -5068,7 +5106,6 @@ void InternalTCXDecoder_fx(
0 );
- move16();
tmpP16 = xn_buf16 + add( sub( L_win, shr( L_ola, 1 ) ), shr( overlap, 1 ) );
tcx_windowing_synthesis_past_frame( tmpP16,
@@ -5182,7 +5219,7 @@ void InternalTCXDecoder_fx(
/* DCT */
Q = sub( 31, *spectrum_e );
- edct_fx( spectrum_fx, tmp_buf, L_frame, &Q );
+ edct_ivas_fx( spectrum_fx, tmp_buf, L_frame, &Q );
/* scale by sqrt(L / NORM_MDCT_FACTOR) */
tmp1 = mult_r( shl( L_frame, 4 ), 26214 /*128.f / NORM_MDCT_FACTOR Q15*/ ); /* 4Q11 */
@@ -5411,7 +5448,7 @@ void InternalTCXDecoder_fx(
st->hTcxCfg->tcx_curr_overlap_mode );
/* If current overlap mode = FULL_OVERLAP -> ALDO_WINDOW */
- IF( EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) )
+ IF( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP )
{
FOR( i = 0; i < nz; i++ )
{
diff --git a/lib_enc/cod_uv_fx.c b/lib_enc/cod_uv_fx.c
index ca17c0f2506a20a33a41b2686efcafc2a7350615..22b51541755628ab629d9f73f3ca25292aa64637 100644
--- a/lib_enc/cod_uv_fx.c
+++ b/lib_enc/cod_uv_fx.c
@@ -64,7 +64,7 @@ void gauss_L2_fx(
E_UTIL_f_convolve( code, h, y11, L_SUBFR ); /* y11: Q8+shift */
Scale_sig( y11, L_SUBFR, sub( 1, shift ) ); /* Q9 */
*gain = L_deposit_l( 0 );
-
+ move32();
/*Update correlations for gains coding */
tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */
tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */
@@ -83,6 +83,7 @@ void gauss_L2_fx(
#endif
g_corr->y1y1_e = sub( 31 - 18, tmp16 );
move16();
+ move16();
tmp16 = norm_l( tmp32_2 );
#ifdef BASOP_NOGLOB
@@ -92,6 +93,7 @@ void gauss_L2_fx(
#endif
g_corr->y1y2_e = sub( 31 - 18, tmp16 );
move16();
+ move16();
}
void gauss_L2_ivas_fx(
@@ -139,7 +141,7 @@ void gauss_L2_ivas_fx(
E_UTIL_f_convolve( code, h, y11, L_SUBFR ); /* y11: Q8+shift */
Scale_sig( y11, L_SUBFR, sub( 1, shift ) ); /* Q9 */
*gain = L_deposit_l( 0 );
-
+ move32();
/*Update correlations for gains coding */
tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */
tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */
@@ -159,9 +161,11 @@ void gauss_L2_ivas_fx(
#endif
g_corr->y1y1_e = sub( 31 - 18, tmp16 );
move16();
+ move16();
tmp16 = norm_l( tmp32_2 );
g_corr->y1y2 = round_fx_sat( L_shl( tmp32_2, tmp16 ) );
g_corr->y1y2_e = sub( 31 - 18, tmp16 );
move16();
+ move16();
}
diff --git a/lib_enc/comvad_decision_fx.c b/lib_enc/comvad_decision_fx.c
index 505e18326fb3483811fef7a6904da7b22a9d68b4..1499bbfce0e51540ecf72e3d742924df9442ebaf 100644
--- a/lib_enc/comvad_decision_fx.c
+++ b/lib_enc/comvad_decision_fx.c
@@ -24,10 +24,10 @@
/*#define CLDFB_VAD*/ /* test on the CLDFB-VAD */
static Word16 comvad_hangover(
- const Word32 lt_snr_org, /* i : original long time SNR*/
- const Word32 snr, /* i : frequency domain SNR */
- const Word32 l_snr, /* i : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
- const Word32 snr_flux, /* i : average tsnr*/
+ const Word32 lt_snr_org, /* i : original long time SNR Q25*/
+ const Word32 snr, /* i : frequency domain SNR Q25*/
+ const Word32 l_snr, /* i : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr Q25*/
+ const Word32 snr_flux, /* i : average tsnr Q25*/
const Word16 bw_index, /* i : band width index*/
const Word16 vad_flag,
const Word16 pre_res_hang_num, /* i : residual amount of previous hangover */
@@ -379,7 +379,7 @@ static Word16 comvad_hangover(
{
IF( ( NE_16( noisy_type, SILENCE ) ) )
{
- speech_flag--;
+ speech_flag = sub( speech_flag, 1 );
}
ELSE
{
@@ -395,13 +395,13 @@ static Word16 comvad_hangover(
Word16 comvad_decision_fx(
VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- const Word32 l_snr, /* i : long time frequency domain*/
- const Word32 lt_snr_org, /* i : original long time SNR*/
- const Word32 lt_snr, /* i : long time SNR calculated by fg_energy and bg_energy*/
- const Word32 snr_flux, /* i : average tsnr of several frames*/
- const Word32 snr, /* i : frequency domain SNR */
- Word32 tsnr, /* i : time domain SNR */
- const Word32 frame_energy, /* i : current frame energy */
+ const Word32 l_snr, /* i : long time frequency domain Q25*/
+ const Word32 lt_snr_org, /* i : original long time SNR Q25*/
+ const Word32 lt_snr, /* i : long time SNR calculated by fg_energy and bg_energy Q25*/
+ const Word32 snr_flux, /* i : average tsnr of several frames Q25*/
+ const Word32 snr, /* i : frequency domain SNR Q25 */
+ Word32 tsnr, /* i : time domain SNR Q25*/
+ const Word32 frame_energy, /* i : current frame energy Q(frame_energy_Q)*/
const Word16 music_backgound_f, /* i : background music flag*/
const Word16 frame_energy_Q, /* i : the Scaling of current frame energy*/
Word16 *cldfb_addition, /* o : adjust the harmonized hangover */
@@ -443,7 +443,7 @@ Word16 comvad_decision_fx(
move16();
test();
- IF( GT_32( hVAD_CLDFB->lf_snr_smooth, LS_MIN_SILENCE_SNR[hVAD_CLDFB->bw_index - CLDFBVAD_NB_ID] ) && GT_32( lt_snr_org, LT_MIN_SILENCE_SNR_FX[hVAD_CLDFB->bw_index - CLDFBVAD_NB_ID] ) )
+ if ( GT_32( hVAD_CLDFB->lf_snr_smooth, LS_MIN_SILENCE_SNR[hVAD_CLDFB->bw_index - CLDFBVAD_NB_ID] ) && GT_32( lt_snr_org, LT_MIN_SILENCE_SNR_FX[hVAD_CLDFB->bw_index - CLDFBVAD_NB_ID] ) )
{
noisy_type = SILENCE;
move16();
@@ -477,7 +477,7 @@ Word16 comvad_decision_fx(
IF( EQ_16( hVAD_CLDFB->fg_energy_count, 512 ) )
{
- fg_energy = MUL_F( fg_energy, 0x6000 );
+ fg_energy = MUL_F( fg_energy, 0x6000 /*.75f in Q15*/ );
hVAD_CLDFB->fg_energy_count = 384;
move16();
}
@@ -527,7 +527,7 @@ Word16 comvad_decision_fx(
l_silence_snr_count = L_shl( hVAD_CLDFB->l_silence_snr_count, Qnorm_silence_count );
snr_div_fix = div_l( l_silence_snr, extract_h( l_silence_snr_count ) );
}
- snr_sub = L_sub( snr, 0x3000000 );
+ snr_sub = L_sub( snr, 0x3000000 /*1.5f in Q25*/ );
snr_div_fix32 = L_deposit_l( snr_div_fix );
snr_div_fix32 = L_shr( snr_div_fix32, add( 6, sub( Qnorm_silence, Qnorm_silence_count ) ) );
@@ -536,7 +536,7 @@ Word16 comvad_decision_fx(
{
IF( EQ_32( hVAD_CLDFB->l_speech_snr_count, 512 ) )
{
- hVAD_CLDFB->l_speech_snr = L_add( MUL_F( hVAD_CLDFB->l_speech_snr, 0x6000 ), L_shr( snr, 9 ) );
+ hVAD_CLDFB->l_speech_snr = L_add( MUL_F( hVAD_CLDFB->l_speech_snr, 0x6000 /*.75f in Q15*/ ), L_shr( snr, 9 ) );
move32();
hVAD_CLDFB->l_speech_snr_count = L_deposit_l( 384 + 1 );
move32();
@@ -557,7 +557,7 @@ Word16 comvad_decision_fx(
{
Word32 lt_snr_add;
- lt_snr_add = L_add( 0x03cccccd, MUL_F( lt_snr, 0x23d7 ) );
+ lt_snr_add = L_add( 0x03cccccd /*1.9 in Q25*/, MUL_F( lt_snr, 0x23d7 ) );
if ( GT_32( snr_flux, lt_snr_add ) )
{
@@ -593,7 +593,7 @@ Word16 comvad_decision_fx(
{
Word32 lt_snr_add;
- lt_snr_add = L_add( 0x04333333, MUL_F( lt_snr, 0x1eb8 ) );
+ lt_snr_add = L_add( 0x04333333 /*2.1 in Q25*/, MUL_F( lt_snr, 0x1eb8 ) );
if ( GT_32( snr_flux, lt_snr_add ) )
{
@@ -629,7 +629,7 @@ Word16 comvad_decision_fx(
{
Word32 lt_snr_add;
- lt_snr_add = L_add( 0x04333333, MUL_F( lt_snr, 0x28f5 ) );
+ lt_snr_add = L_add( 0x04333333 /*2.1 Q25*/, MUL_F( lt_snr, 0x28f5 ) );
if ( ( GT_32( snr_flux, lt_snr_add ) ) )
{
@@ -671,7 +671,8 @@ Word16 comvad_decision_fx(
test();
if ( GT_16( hVAD_CLDFB->ltd_stable_rate[0], 2621 /* 0.08 Q15 */ ) && EQ_16( vad_flag, 1 ) && ( tmpout > 0 ) )
{
- hVAD_CLDFB->fg_energy_est_start = L_deposit_l( 1 );
+ hVAD_CLDFB->fg_energy_est_start = 1;
+ move32();
}
}
@@ -694,7 +695,7 @@ Word16 comvad_decision_fx(
move16();
}
vadb_flag = vad_flag;
-
+ move16();
IF( EQ_16( hVAD_CLDFB->bw_index, CLDFBVAD_SWB_ID ) )
{
test();
@@ -710,13 +711,14 @@ Word16 comvad_decision_fx(
test();
test();
test();
- IF( GT_32( snr_flux, 83886078 /* 2.5 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 40 && GT_32( snr_flux, 67108862 /* 2.0 Q25 */ ) ) || music_backgound_f == 1 )
+ IF( GT_32( snr_flux, 83886078 /* 2.5 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 40 && GT_32( snr_flux, 67108862 /* 2.0 Q25 */ ) ) || EQ_16( music_backgound_f, 1 ) )
{
vad_flag = s_or( vad_flag, vada_flag );
}
ELSE IF( EQ_16( SILENCE, noisy_type ) )
{
vad_flag = vada_flag;
+ move16();
}
}
}
@@ -735,13 +737,14 @@ Word16 comvad_decision_fx(
test();
test();
test();
- IF( GT_32( snr_flux, 73819748 /* 2.2 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 40 && GT_32( snr_flux, 57042532 /* 1.7 Q25 */ ) ) || music_backgound_f == 1 )
+ IF( GT_32( snr_flux, 73819748 /* 2.2 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 40 && GT_32( snr_flux, 57042532 /* 1.7 Q25 */ ) ) || EQ_16( music_backgound_f, 1 ) )
{
vad_flag = s_or( vad_flag, vada_flag );
}
ELSE IF( EQ_16( SILENCE, noisy_type ) )
{
vad_flag = vada_flag;
+ move16();
}
}
}
@@ -753,6 +756,7 @@ Word16 comvad_decision_fx(
IF( GT_32( hVAD_CLDFB->lf_snr_smooth, 419430388 /* 12.5 Q25 */ ) && music_backgound_f == 0 )
{
vad_flag = vada_flag;
+ move16();
}
}
ELSE
@@ -760,7 +764,7 @@ Word16 comvad_decision_fx(
test();
test();
test();
- IF( GT_32( snr_flux, 67108862 /* 2.0 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 30 && GT_32( snr_flux, 50331647 /* 1.5 Q25 */ ) ) || music_backgound_f == 1 )
+ IF( GT_32( snr_flux, 67108862 /* 2.0 Q25 */ ) || ( GT_16( hVAD_CLDFB->continuous_speech_num2, 30 ) && GT_32( snr_flux, 50331647 /* 1.5 Q25 */ ) ) || EQ_16( music_backgound_f, 1 ) )
{
vad_flag = s_or( vad_flag, vada_flag );
}
@@ -771,7 +775,7 @@ Word16 comvad_decision_fx(
{
IF( EQ_32( hVAD_CLDFB->l_silence_snr_count, 512 ) )
{
- hVAD_CLDFB->l_silence_snr = L_add( MUL_F( hVAD_CLDFB->l_silence_snr, 0x6000 ), L_shr( snr, 9 ) );
+ hVAD_CLDFB->l_silence_snr = L_add( MUL_F( hVAD_CLDFB->l_silence_snr, 0x6000 /*.75f Q15*/ ), L_shr( snr, 9 ) );
move32();
hVAD_CLDFB->l_silence_snr_count = L_deposit_l( 384 + 1 );
move32();
@@ -789,7 +793,7 @@ Word16 comvad_decision_fx(
{
IF( EQ_16( hVAD_CLDFB->bg_energy_count, 512 ) )
{
- bg_energy = MUL_F( bg_energy, 0x6000 );
+ bg_energy = MUL_F( bg_energy, 0x6000 /*.75f Q15*/ );
hVAD_CLDFB->bg_energy_count = 384;
move16();
}
@@ -804,9 +808,11 @@ Word16 comvad_decision_fx(
test();
hVAD_CLDFB->vad_flag_for_bk_update = vad_flag;
+ move16();
IF( LT_16( hVAD_CLDFB->update_count, 12 ) && EQ_16( vadb_flag, 1 ) )
{
hVAD_CLDFB->warm_hang_num = s_max( 20, speech_flag );
+ move16();
}
test();
IF( vad_flag == 0 && hVAD_CLDFB->warm_hang_num > 0 )
@@ -814,6 +820,7 @@ Word16 comvad_decision_fx(
hVAD_CLDFB->warm_hang_num = sub( hVAD_CLDFB->warm_hang_num, 1 );
vad_flag = 1;
move16();
+ move16();
}
@@ -827,15 +834,16 @@ Word16 comvad_decision_fx(
hVAD_CLDFB->speech_flag = speech_flag;
move16();
- move16();
test();
IF( EQ_16( noisy_type, SILENCE ) && NE_16( hVAD_CLDFB->bw_index, CLDFBVAD_NB_ID ) )
{
*cldfb_addition = 2;
+ move16();
}
ELSE
{
*cldfb_addition = 0;
+ move16();
if ( EQ_16( hVAD_CLDFB->bw_index, CLDFBVAD_WB_ID ) )
{
diff --git a/lib_enc/core_enc_2div_fx.c b/lib_enc/core_enc_2div_fx.c
index 151561b091bea6801e7c95d3ddd5cc9bdfba53c4..fa74ec6b562f88a5e675aba13685de56fa703fdb 100644
--- a/lib_enc/core_enc_2div_fx.c
+++ b/lib_enc/core_enc_2div_fx.c
@@ -22,7 +22,7 @@
*-------------------------------------------------------------------*/
void core_encode_twodiv_fx(
- const Word16 new_samples[], /* i : new samples */
+ const Word16 new_samples[], /* i : new samples */
Encoder_State *st, /* i/o: coder memory state */
const Word16 coder_type, /* i : coding type */
Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
@@ -60,9 +60,7 @@ void core_encode_twodiv_fx(
spectrum[1] = spectrum_buf + N_TCX10_MAX;
hm_cfg[0].indexBuffer = &indexBuffer[0];
- move16();
hm_cfg[1].indexBuffer = &indexBuffer[N_MAX / 2 + 1];
- move16();
move16();
move16();
@@ -203,19 +201,19 @@ void core_encode_twodiv_fx(
/* calculate noise-filling over whole spectrum for TCX10 frames */
move16();
- hTcxEnc->measuredBwRatio = 0x4000;
+ hTcxEnc->measuredBwRatio = 0x4000; // 1 in Q14
FOR( n = 0; n < 2; n++ )
{
target_bits = sub( shr( sub( add( bitsAvailable, 1 ), n ), 1 ), tnsBits[n] );
- if ( n == 0 )
+ IF( n == 0 )
{
target_bits = sub( target_bits, ltpBits );
}
test();
- if ( st->enablePlcWaveadjust && n )
+ IF( st->enablePlcWaveadjust && n )
{
target_bits = sub( target_bits, 1 );
}
@@ -285,7 +283,7 @@ void core_encode_twodiv_fx(
/* subtract bits for TCX overlap mode (1 bit: full, 2 bits: half or no overlap) */
target_bits = sub( target_bits, 1 );
test();
- if ( EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, HALF_OVERLAP ) || EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, MIN_OVERLAP ) )
+ IF( EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, HALF_OVERLAP ) || EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, MIN_OVERLAP ) )
{
target_bits = sub( target_bits, 1 );
}
@@ -293,7 +291,7 @@ void core_encode_twodiv_fx(
target_bits = sub( target_bits, st->hIGFEnc->infoTotalBitsPerFrameWritten );
- if ( st->enablePlcWaveadjust )
+ IF( st->enablePlcWaveadjust )
{
target_bits = sub( target_bits, 1 );
}
diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c
index c378731ad5ad216a71d2715360d782733d3e1b29..e09166f8a2f6ec504872d09f44fce67d336c3608 100644
--- a/lib_enc/core_enc_init.c
+++ b/lib_enc/core_enc_init.c
@@ -52,7 +52,7 @@
*-----------------------------------------------------------------------*/
static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag );
static void init_core_sig_ana_ivas_fx( Encoder_State *st );
-static void init_modes_ivas_fx( Encoder_State *st, const int32_t last_total_brate );
+static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate );
static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr );
static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift );
/*-----------------------------------------------------------------------*
@@ -121,7 +121,7 @@ void init_coder_ace_plus_ivas_fx(
test();
test();
test();
- IF( ( EQ_16( st->element_mode, EVS_MONO ) && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( GT_16( st->element_mode, EVS_MONO ) && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) )
+ IF( ( st->element_mode == EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->element_mode > EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) )
{
st->nb_subfr = NB_SUBFR16k;
move16();
@@ -160,7 +160,8 @@ void init_coder_ace_plus_ivas_fx(
st->currEnergyHF_fx = 0;
move32();
-
+ st->currEnergyHF_e_fx = 0;
+ move16();
test();
/* Initialize LPC analysis/quantization */
IF( LE_32( st->sr_core, INT_FS_16k ) && st->tcxonly == 0 )
@@ -221,7 +222,7 @@ void init_coder_ace_plus_ivas_fx(
init_acelp_ivas_fx( st, L_frame_old, 0 );
- IF( st->ini_frame == 0 )
+ if ( st->ini_frame == 0 )
{
st->tec_tfa = 0;
move16();
@@ -235,7 +236,7 @@ void init_coder_ace_plus_ivas_fx(
test();
test();
test();
- IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
+ IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO )
{
st->tec_tfa = 1;
move16();
@@ -254,7 +255,7 @@ void init_coder_ace_plus_ivas_fx(
test();
test();
test();
- IF( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
+ IF( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO )
{
st->glr = 1;
move16();
@@ -315,213 +316,6 @@ void init_coder_ace_plus_ivas_fx(
return;
}
-void init_coder_ace_plus(
- Encoder_State *st, /* i : Encoder state */
- const int32_t last_total_brate, /* i : last total bitrate */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-)
-{
- TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
- int16_t L_frame_old; /*keep old frame size for switching */
- int16_t L_subfr;
-
- /* Bitrate */
- st->tcxonly = getTcxonly_ivas_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format );
-
- /* Core Sampling Rate */
- st->sr_core = getCoreSamplerateMode2_flt( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format );
- st->fscale = sr2fscale( st->sr_core );
-
- /* Narrowband? */
- st->narrowBand = ( st->bwidth == NB ) ? 1 : 0;
-
- /* Core Framing */
- L_frame_old = st->last_L_frame;
- st->L_frame = (int16_t) ( st->sr_core / FRAMES_PER_SEC );
- st->L_frame_past = -1;
-
- if ( hTcxEnc != NULL )
- {
- hTcxEnc->L_frameTCX = (int16_t) ( st->input_Fs / FRAMES_PER_SEC );
-
- if ( st->ini_frame == 0 )
- {
- hTcxEnc->tcx_target_bits_fac = ONE_IN_Q14;
-
- set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 );
- hTcxEnc->acelp_zir = hTcxEnc->Txnq + L_FRAME / 2;
- hTcxEnc->q_Txnq = Q15;
- move16();
- }
- }
-
- if ( ( st->element_mode == EVS_MONO && st->L_frame == L_FRAME16k && st->total_brate <= ACELP_32k ) || ( st->element_mode > EVS_MONO && st->L_frame == L_FRAME16k && st->total_brate <= MAX_ACELP_BRATE ) )
- {
- st->nb_subfr = NB_SUBFR16k;
- }
- else
- {
- st->nb_subfr = NB_SUBFR;
- }
- L_subfr = st->L_frame / st->nb_subfr;
-
- /* Core Lookahead */
- st->encoderLookahead_enc = NS2SA( st->sr_core, ACELP_LOOK_NS );
- st->encoderLookahead_FB = NS2SA( st->input_Fs, ACELP_LOOK_NS );
-
- if ( st->ini_frame == 0 )
- {
- st->acelpFramesCount = 0;
-#ifdef MSAN_FIX
- st->prevTempFlatness_fx = 128; // Q7
-#endif
- }
-
- /* Initialize TBE */
- if ( st->hBWE_TD != NULL )
- {
- st->hBWE_TD->prev_coder_type = GENERIC;
- set16_fx( st->hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 );
- st->hBWE_TD->prev_tilt_para_fx = 0;
- set16_fx( st->hBWE_TD->cur_sub_Aq_fx, 0, M + 1 );
- move16();
- }
-
- st->currEnergyHF_fx = 0;
- move32();
-
- /* Initialize LPC analysis/quantization */
- if ( st->sr_core <= INT_FS_16k && st->tcxonly == 0 )
- {
- st->lpcQuantization = 1;
- }
- else
- {
- st->lpcQuantization = 0;
- }
-
- st->next_force_safety_net = 0;
- if ( ( st->last_L_frame != st->L_frame ) || ( st->last_core == AMR_WB_CORE ) || ( st->last_core == HQ_CORE ) )
- {
- set16_fx( st->mem_MA_fx, 0, M );
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
- }
-
- /* Initialize IGF */
- if ( st->hIGFEnc != NULL )
- {
- st->hIGFEnc->infoStopFrequency = -1;
- }
-
- if ( st->igf && st->hIGFEnc != NULL )
- {
- IGFEncSetMode_ivas_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode );
- }
- else if ( st->hIGFEnc != NULL )
- {
- st->hIGFEnc->infoTotalBitsWritten = 0;
- st->hIGFEnc->infoTotalBitsPerFrameWritten = 0;
- }
-
- /* Initialize Core Signal Analysis Module */
- init_core_sig_ana_ivas_fx( st );
-
- /* Initialize TCX */
- if ( hTcxEnc != NULL )
- {
- init_tcx_ivas_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag );
- }
-
- /* Initialize Signal Buffers */
- init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr );
-
- /* Initialize ACELP */
- init_acelp_ivas_fx( st, L_frame_old, 0 );
-
- if ( st->ini_frame == 0 )
- {
- st->tec_tfa = 0;
- }
-
- if ( st->hTECEnc != NULL )
- {
- resetTecEnc_Fx( st->hTECEnc, st->tec_tfa );
- }
-
- if ( st->bwidth == SWB && ( st->total_brate == ACELP_16k40 || st->total_brate == ACELP_24k40 ) && st->element_mode == EVS_MONO )
- {
- st->tec_tfa = 1;
- }
- else
- {
- st->tec_tfa = 0;
- }
-
- st->tec_flag = 0;
- st->tfa_flag = 0;
-
-
- if ( ( st->total_brate == ACELP_9k60 || st->total_brate == ACELP_16k40 || st->total_brate == ACELP_24k40 ) && st->element_mode == EVS_MONO )
- {
- st->glr = 1;
- }
- else
- {
- st->glr = 0;
- }
-
- st->glr_reset = 0;
-
- /* Initialize ACELP/TCX Modes */
- init_modes_ivas_fx( st, last_total_brate );
-
- /* Adaptive BPF */
- if ( st->total_brate >= HQ_48k )
- {
- st->enablePlcWaveadjust = 1;
- }
- else
- {
- st->enablePlcWaveadjust = 0;
- }
-
- set32_fx( st->mem_bpf_fx1, 0, 2 * L_FILT16k );
- set32_fx( st->mem_error_bpf_fx, 0, 2 * L_FILT16k );
-
- IF( st->ini_frame == 0 )
- {
- st->Q_max_enc[0] = 15;
- move16();
- st->Q_max_enc[1] = 15;
- move16();
- }
-
- IF( st->total_brate >= HQ_48k )
- {
- st->enablePlcWaveadjust = 1;
- move16();
- }
- ELSE
- {
- st->enablePlcWaveadjust = 0;
- move16();
- }
-
- if ( st->hPlcExt )
- {
- init_PLC_enc_fx( st->hPlcExt, st->sr_core );
- }
-
- st->glr_idx[0] = 0;
- st->glr_idx[1] = 0;
- st->mean_gc[0] = 0;
- st->mean_gc[1] = 0;
- st->prev_lsf4_mean = 0;
- st->last_stab_fac = 0;
-
- return;
-}
-
/*-----------------------------------------------------------------------*
* init_tcx()
*
@@ -670,7 +464,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
hTcxEnc->exp_buf_speech_ltp = 0;
move16();
}
- set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp() and also to accomodate for the wspeech_enc */
+ set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp_fx() and also to accomodate for the wspeech_enc */
st->exp_buf_wspeech_enc = 0;
move16();
}
@@ -688,8 +482,8 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) /* condition should be checked again */
{
Copy( st->buf_speech_enc, hTcxEnc->buf_speech_ltp, st->L_frame );
- Scale_sig( hTcxEnc->buf_speech_ltp, st->L_frame, sub( st->exp_buf_speech_enc, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) );
- Scale_sig( hTcxEnc->buf_speech_ltp + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( hTcxEnc->exp_buf_speech_ltp, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) );
+ Scale_sig( hTcxEnc->buf_speech_ltp, st->L_frame, sub( st->exp_buf_speech_enc, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp))
+ Scale_sig( hTcxEnc->buf_speech_ltp + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( hTcxEnc->exp_buf_speech_ltp, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp))
hTcxEnc->exp_buf_speech_ltp = s_max( hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc );
move16();
}
@@ -707,9 +501,9 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
// Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) );
Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM );
/* SCaling to common exponent*/
- Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) );
- Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) );
- Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) );
+ Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ))
+ Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ))
+ Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ))
st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe );
move16();
}
@@ -758,7 +552,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
hTcxEnc->new_speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc + st->encoderLookahead_enc;
}
- if ( st->hTcxEnc != NULL )
+ IF( st->hTcxEnc != NULL )
{
st->hTcxEnc->new_speech_TCX = st->input_buff_fx + Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 );
st->hTcxEnc->speech_TCX = st->hTcxEnc->new_speech_TCX - st->encoderLookahead_FB;
@@ -771,7 +565,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
hTcxEnc->speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc;
}
- IF( GT_16( st->element_mode, EVS_MONO ) )
+ IF( st->element_mode > EVS_MONO )
{
st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_SUBFR;
}
@@ -889,7 +683,7 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh
}
ELSE /*Rate switching*/
{
- IF( EQ_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core == ACELP_CORE )
{
lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, shr( st->L_frame, 1 ), shr( L_frame_old, 1 ) );
}
@@ -900,7 +694,7 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh
hTcxEnc->acelp_zir = hTcxEnc->Txnq + shr( st->L_frame, 1 );
/* Rate switching */
- IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) )
+ IF( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO )
{
IF( hLPDmem != NULL )
{
@@ -1142,9 +936,9 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh
move32();
st->pst_lp_ener_fx = 0;
move16();
- if ( EQ_16( st->last_codec_mode, MODE1 ) )
+ IF( EQ_16( st->last_codec_mode, MODE1 ) )
{
- st->mem_bpf_fx.lp_error = L_deposit_l( 0 );
+ st->mem_bpf_fx.lp_error = 0;
move32();
st->pst_mem_deemp_err_fx = 0;
move16();
diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c
index 3bde91b035642dc095efe0086f8ff602646c16d4..6638b4c338510d41eb2d2c62333841d05413fb79 100644
--- a/lib_enc/core_enc_init_fx.c
+++ b/lib_enc/core_enc_init_fx.c
@@ -6,9 +6,8 @@
//#include "prot_fx.h"
//#include "basop_mpy.h"
#include "options.h"
-#include "cnst.h" /* Common constants */
+#include "cnst.h"
#include "stl.h"
-#include "count.h"
#include "basop_util.h"
#include "rom_com_fx.h"
#include "ivas_cnst.h"
@@ -64,6 +63,7 @@ void init_coder_ace_plus_fx(
/* Core Sampling Rate */
st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format );
st->fscale = sr2fscale( st->sr_core );
+ move32();
move16();
/* Narrowband? */
@@ -78,12 +78,13 @@ void init_coder_ace_plus_fx(
/* Core Framing */
L_frame_old = st->last_L_frame;
move16();
- st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) );
+ st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 /* 1/FRAMES_PER_SEC in Q15*/ ) );
st->L_frame_past = -1;
move16();
+ move16();
- hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) );
-
+ hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 /* 1/FRAMES_PER_SEC in Q15*/ ) );
+ move16();
st->nb_subfr = NB_SUBFR;
move16();
L_subfr = shr( st->L_frame, 2 );
@@ -113,7 +114,7 @@ void init_coder_ace_plus_fx(
/* Initialize TBE */
hBWE_TD->prev_coder_type = GENERIC;
move16();
- set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 );
+ set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384 /*.5f Q15*/, LPC_SHB_ORDER - 2 );
hBWE_TD->prev_tilt_para_fx = 0;
move16();
set16_fx( hBWE_TD->cur_sub_Aq_fx, 0, M + 1 );
@@ -150,8 +151,9 @@ void init_coder_ace_plus_fx(
if ( st->hIGFEnc != NULL )
{
st->hIGFEnc->infoStopFrequency = -1;
+ move16();
}
- move16();
+
IF( st->igf )
{
IGFEncSetMode_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode );
@@ -159,9 +161,11 @@ void init_coder_ace_plus_fx(
ELSE IF( st->hIGFEnc != NULL )
{
st->hIGFEnc->infoTotalBitsWritten = 0;
+ move16();
if ( EQ_16( MCT_flag, -10 ) )
{
st->hIGFEnc->infoTotalBitsPerFrameWritten = 0;
+ move16();
}
/* the line above is needed for some transition, but when going from low rate to high rate, ex 7k2 to 96k, EVS fix point doesn't do the reset (or it does somewhere else */
}
@@ -210,7 +214,6 @@ void init_coder_ace_plus_fx(
/* Initialize DTX */
IF( st->ini_frame == 0 )
{
-
vad_init_fx( &st->vad_st );
}
@@ -270,8 +273,8 @@ void init_coder_ace_plus_fx(
move16();
move16();
move16(); /* casts */
- st->mean_gc[0] = L_deposit_h( 0 );
- st->mean_gc[1] = L_deposit_h( 0 );
+ st->mean_gc[0] = 0;
+ st->mean_gc[1] = 0;
st->prev_lsf4_mean = 0;
move16();
@@ -315,7 +318,7 @@ static void init_tcx_fx(
st->hTcxCfg->lfacNext = sub( st->hTcxCfg->tcx_offset, shr( st->L_frame, 2 ) );
move16();
st->hTcxCfg->lfacNextFB = sub( st->hTcxCfg->tcx_offsetFB, shr( hTcxEnc->L_frameTCX, 2 ) );
-
+ move16();
IF( st->ini_frame == 0 )
{
st->hTcxCfg->tcx_curr_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW;
@@ -376,7 +379,7 @@ static void init_tcx_fx(
/* TCX-LTP */
hTcxEnc->tcxltp = getTcxLtp( st->sr_core );
-
+ move16();
test();
test();
test();
@@ -393,7 +396,7 @@ static void init_tcx_fx(
hTcxEnc->tcxltp_norm_corr_past = 0;
move16();
}
- ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( st->total_brate == 16400 || st->total_brate == 24400 ) && ( st->total_brate == st->last_total_brate ) && ( st->last_bwidth == st->bwidth ) ) )
+ ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, 16400 ) || EQ_32( st->total_brate, 24400 ) ) && ( EQ_32( st->total_brate, st->last_total_brate ) ) && ( EQ_32( st->last_bwidth, st->bwidth ) ) ) )
{
Word16 pitres, pitres_old;
Word16 pit, pit_old;
@@ -428,7 +431,6 @@ static void init_tcx_fx(
hTcxEnc->tcxltp_pitch_int_past = pit;
move16();
- move16();
hTcxEnc->tcxltp_pitch_fr_past = i_mult2( sub( pit, hTcxEnc->tcxltp_pitch_int_past ), pitres );
move16();
}
@@ -445,8 +447,9 @@ static void init_tcx_fx(
}
st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode );
-
+ move16();
hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode );
+ move16();
}
void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr )
@@ -486,14 +489,14 @@ void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Wor
Copy( st->buf_speech_enc, hTcxEnc->buf_speech_ltp, st->L_frame );
}
- Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) );
+ Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); // Q(prev_Q_new)
/*Resamp buffers needed only for ACELP*/
test();
test();
IF( EQ_16( st->L_frame, L_FRAME ) && !st->tcxonly )
{
- Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) );
+ Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); // Q(prev_Q_new)
}
ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) && !st->tcxonly )
{
@@ -510,7 +513,7 @@ void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Wor
ELSE IF( !st->tcxonly && GE_32( st->last_total_brate, ACELP_32k ) )
{
- Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) );
+ Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); // Q(prev_Q_new)
/*Resamp buffers needed only for ACELP*/
IF( EQ_16( st->L_frame, L_FRAME16k ) )
@@ -609,7 +612,7 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
/* Init pitch lag */
st->pit_res_max = initPitchLagParameters( st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max );
-
+ move16();
/* Init LPDmem */
IF( st->ini_frame == 0 )
@@ -672,6 +675,8 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
/* unquantized LPC*/
test();
+ test();
+ test();
IF( !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, st->last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) )
{
Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/
@@ -694,6 +699,8 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/
st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW;
+ move16();
+ move16();
/*ALDO overlap windowed past: also used in MODE1 but for other MDCT-FB*/
set16_fx( hTcxEnc->old_out_fx, 0, st->L_frame );
}
@@ -705,6 +712,7 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
{
/* convert quantized LSP vector */
st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
+ move16();
IF( st->tcxonly == 0 )
{
lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core );
@@ -743,6 +751,7 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
#else
hLPDmem->mem_w0 = sub( shr( st->wspeech_enc[-1], shift ), tmp );
#endif
+ move16();
}
}
ELSE IF( ( NE_16( st->L_frame, L_frame_old ) ) )
@@ -805,7 +814,8 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
}
/* Post-processing */
- hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 );
+ hLPDmem->dm_fx.prev_gain_code = 0;
+ move32();
set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 );
hLPDmem->dm_fx.prev_state = 0;
@@ -816,7 +826,8 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
/* Pulse Search configuration */
st->acelp_autocorr = 1;
move16();
-
+ test();
+ test();
/*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/
if ( ( LE_32( st->total_brate, ACELP_9k60 ) || st->rf_mode != 0 ) && ( EQ_32( st->sr_core, 12800 ) ) )
{
@@ -828,10 +839,12 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
/*BPF parameters for adjusting gain in function of background noise*/
IF( EQ_16( st->codec_mode, MODE2 ) )
{
- st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 );
- if ( st->last_codec_mode == MODE1 )
+ st->mem_bpf_fx.lp_error_ener = 0;
+ move32();
+ if ( EQ_16( st->last_codec_mode, MODE1 ) )
{
- st->mem_bpf_fx.lp_error = L_deposit_l( 0 );
+ st->mem_bpf_fx.lp_error = 0;
+ move32();
}
}
@@ -890,13 +903,15 @@ static void init_modes_fx(
assert( st->fscale == 2 * st->L_frame ); /* this assumption is true if operated in 20ms frames with FSCALE_DENOM == 512, which is the current default */
tmp32 = L_shl( st->total_brate, 1 ); /* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate */
st->bits_frame_nominal = extract_l( L_shr( Mpy_32_16_1( tmp32, 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */
-
+ move16();
IF( st->Opt_AMR_WB )
{
st->bits_frame = st->bits_frame_nominal;
st->bits_frame_core = st->bits_frame_nominal;
st->frame_size_index = 0;
move16();
+ move16();
+ move16();
}
ELSE
{
diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c
index 93c3e4df5ed04fb4fb51f8937f600020384a2653..ee347543b87cf940ce5ed8b04041e788558d1f91 100644
--- a/lib_enc/core_enc_ol_fx.c
+++ b/lib_enc/core_enc_ol_fx.c
@@ -33,12 +33,12 @@ static void BITS_ALLOC_TCX_config_rf( Word16 *rf_frame_type, Word16 *rf_target_b
void core_encode_openloop_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 coder_type, /* i : coding type */
- const Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 *lsp_new, /* i : LSPs at the end of the frame */
- const Word16 *lsp_mid, /* i : LSPs at the middle of the frame */
- Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *ptr_bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes */
+ const Word16 *lsp_new, /* i : LSPs at the end of the frame Q15*/
+ const Word16 *lsp_mid, /* i : LSPs at the middle of the frame Q15*/
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subfr Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *ptr_bwe_exc, /* o : excitation for SWB TBE Qexc*/
const Word16 vad_hover_flag,
const Word16 vad_flag_dtx,
Word16 Q_new,
@@ -86,6 +86,7 @@ void core_encode_openloop_fx(
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
RF_ENC_HANDLE hRF = st->hRF;
@@ -123,23 +124,26 @@ void core_encode_openloop_fx(
/* back up LPD mem_w0 target generation memory */
hRF->rf_mem_w0 = hLPDmem->mem_w0;
-
+ move16();
/* back up clip gain memory */
Copy( st->clip_var_fx, hRF->rf_clip_var, 6 );
/* back up tilt code */
hRF->rf_tilt_code = hLPDmem->tilt_code;
-
+ move16();
/* back up dispMem */
hRF->rf_dm_fx.prev_state = hLPDmem->dm_fx.prev_state;
+ move16();
hRF->rf_dm_fx.prev_gain_code = hLPDmem->dm_fx.prev_gain_code;
+ move32();
FOR( i = 0; i < 6; i++ )
{
hRF->rf_dm_fx.prev_gain_pit[i] = hLPDmem->dm_fx.prev_gain_pit[i];
+ move16();
}
/* back up gc_threshold for noise addition */
hRF->rf_gc_threshold = hLPDmem->gc_threshold;
-
+ move32();
/* initialization */
tcx_lpc_cdk = 0;
@@ -233,7 +237,7 @@ void core_encode_openloop_fx(
/* calculate target bits for core coding */
target_bits = sub( target_bits, st->rf_target_bits_write );
}
- IF( st->igf != 0 )
+ if ( st->igf != 0 )
{
target_bits = sub( target_bits, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_mode ) );
}
@@ -249,7 +253,7 @@ void core_encode_openloop_fx(
}
/* reset TBE buffers previous frame frame wasn't ACELP*/
- IF( NE_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core != ACELP_CORE )
{
TBEreset_enc_fx( st, st->bwidth );
}
@@ -261,6 +265,7 @@ void core_encode_openloop_fx(
IF( st->hPlcExt )
{
st->glr_idx[0] = encSideSpecPowDiffuseDetector_fx( st->hPlcExt->last_lsf_ref, st->hPlcExt->last_lsf_con, st->last_sr_core, &( st->prev_lsf4_mean ), (Word8) st->glr, coder_type );
+ move16();
Copy( lsf_q, st->hPlcExt->last_lsf_ref, M );
Copy( st->hPlcExt->lsf_con, st->hPlcExt->last_lsf_con, M );
@@ -272,12 +277,11 @@ void core_encode_openloop_fx(
st->glr_idx[0] = 0;
}
move16();
- move16();
st->hPlcExt->LPDmem = hLPDmem;
encoderSideLossSimulation_fx( st, st->hPlcExt, lsf_q, stab_fac, st->hPlcExt->calcOnlylsf, st->L_frame );
}
st->last_stab_fac = stab_fac;
-
+ move16();
hTcxEnc->tcxltp_norm_corr_past = st->voicing_fx[1];
move16();
@@ -353,9 +357,9 @@ void core_encode_openloop_fx(
IF( EQ_16( st->mdct_sw, MODE1 ) )
{
/* Account for core signaling bits difference: bandwidth and ACELP/TCX signaling bit are replaced */
- target_bits = add( target_bits, sub( add( FrameSizeConfig[st->frame_size_index].bandwidth_bits, 1 ), signalling_mode1_tcx20_enc( st, 0 ) ) );
+ target_bits = add( target_bits, sub( add( FrameSizeConfig[st->frame_size_index].bandwidth_bits, 1 ), signalling_mode1_tcx20_enc_fx( st, 0 ) ) );
}
- ELSE if ( EQ_16( st->mdct_sw_enable, MODE2 ) )
+ ELSE IF( EQ_16( st->mdct_sw_enable, MODE2 ) )
{
target_bits = sub( target_bits, 1 );
}
@@ -396,7 +400,6 @@ void core_encode_openloop_fx(
coder_tcx_post_fx( st, hLPDmem, st->hTcxCfg, st->synth, A_q, Aw, st->wspeech_enc, Q_new, shift );
- move16();
IF( st->hPlcExt )
{
st->hPlcExt->LPDmem = hLPDmem;
@@ -430,7 +433,9 @@ void core_encode_openloop_fx(
lsf_update_memory( st->narrowBand, st->lsf_old_fx, st->mem_MA_fx, st->mem_MA_fx, M );
st->pstreaklen = 0;
- st->streaklimit_fx = 32767;
+ st->streaklimit_fx = 32767; /*1 Q15*/
+ move16();
+ move16();
/* check resonance for pitch clipping algorithm */
gp_clip_test_lsf_fx( st->element_mode, st->lsf_old_fx, st->clip_var_fx, 0 );
Copy( st->lsf_old_fx, st->mem_AR_fx, M );
@@ -447,6 +452,8 @@ void core_encode_openloop_fx(
*--------------------------------------------------------------*/
IF( st->Opt_DTX_ON != 0 )
{
+ test();
+ test();
/* update CNG parameters in active frames */
IF( EQ_16( st->bwidth, NB ) && st->enableTcxLpc && st->core != ACELP_CORE )
{
@@ -454,6 +461,7 @@ void core_encode_openloop_fx(
assert( st->L_frame == L_FRAME );
Copy( st->synth + L_FRAME - L_LP, buf, L_LP );
tmp = st->synth[L_FRAME - L_LP - 1];
+ move16();
E_UTIL_f_preemph2( Q_new - 1, buf, st->preemph_fac, L_LP, &tmp );
autocorr_fx( buf, M, r_h, r_l, &Q_r, L_LP, Assym_window_W16fx, 0, 0 );
lag_wind( r_h, r_l, M, INT_FS_FX, LAGW_WEAK );
@@ -501,12 +509,13 @@ void core_encode_openloop_fx(
*---------------------------------------------------------------*/
test();
- IF( GT_16( st->core, ACELP_CORE ) || ( st->rate_switching_reset != 0 ) )
+ IF( ( st->core > ACELP_CORE ) || ( st->rate_switching_reset != 0 ) )
{
/*TCX mode: copy values*/
set16_fx( st->mem_bpf_fx.noise_buf, 0, 2 * L_FILT16k ); /*TCX->no gain*/
set16_fx( st->mem_bpf_fx.error_buf, 0, L_FILT16k ); /*TCX->no gain*/
st->bpf_gain_param = 0;
+ move16();
}
ELSE IF( st->acelp_cfg.bpf_mode > 0 )
{
@@ -532,7 +541,7 @@ void core_encode_openloop_fx(
IF( EQ_16( st->rf_mode, 1 ) )
{
set16_fx( lsf_q_1st_rf, 0, M );
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
/* convert LSPs to LP coefficients */
lsp2lsf_fx( lsp_new, lsf_uq_rf, M, st->sr_core );
@@ -541,6 +550,7 @@ void core_encode_openloop_fx(
/* first stage VQ, 8 bits; reuse TCX high rate codebook */
hRF->rf_indx_lsf[0][0] = vlpc_1st_cod_fx( lsf_uq_rf, lsf_q_1st_rf, w_rf, st->rf_mode );
+ move16();
/*v_sub(lsf_uq_rf, lsf_q_1st_rf, lsf_q_d_rf, M);*/
FOR( i = 0; i < M; i++ )
{
@@ -549,6 +559,7 @@ void core_encode_openloop_fx(
#else
lsf_q_d_rf[i] = shl( mult_r( sub( lsf_uq_rf[i], lsf_q_1st_rf[i] ), 25600 ), 5 );
#endif
+ move16();
/*input value is in Qx2.56, convert to Q6 to match table, quantizer table kept at Q6 to avoid losing precision */
/*Assume this difference data max range can be represented by Q6*/
}
@@ -567,6 +578,7 @@ void core_encode_openloop_fx(
tmp = lsf_q_diff_cb_8b_rf[i + M * hRF->rf_indx_lsf[0][1]]; /*tmp = quantized lsf_q_d_rf in Q6*/
tmp = shr( mult_r( tmp, 20972 ), 4 ); /* bring lsf_q_d_rf to Qx2.56 for addition */
lsf_q_rf[i] = add( lsf_q_1st_rf[i], tmp );
+ move16();
}
v_sort( lsf_q_rf, 0, M - 1 );
@@ -584,9 +596,12 @@ void core_encode_openloop_fx(
hRF->rf_indx_lsf[0][0] = param_lpc[1];
hRF->rf_indx_lsf[0][1] = param_lpc[2];
hRF->rf_indx_lsf[0][2] = param_lpc[3];
+ move16();
+ move16();
+ move16();
}
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
/* current n-th ACELP frame and its corresponding partial copy */
@@ -608,8 +623,9 @@ void core_encode_openloop_fx(
/* RF frame type in the buffer */
hRF->rf_indx_frametype[0] = hRF->rf_frame_type;
hRF->rf_targetbits_buff[0] = hRF->rf_target_bits;
-
- IF( NE_16( hRF->rf_frame_type, RF_NO_DATA ) )
+ move16();
+ move16();
+ IF( hRF->rf_frame_type != RF_NO_DATA )
{
/* coder_acelp_rf_fx does the partial copy encoding based on the rf frame type chosen for the RF encoding */
coder_acelp_rf_fx( &( hRF->acelp_cfg_rf ), coder_type, Aw, Aq_rf, st->speech_enc_pe, st->voicing_fx, st->pitch,
@@ -651,7 +667,7 @@ void core_encode_openloop_fx(
test();
test();
test();
- IF(
+ if (
( EQ_16( st->core, TCX_20_CORE ) ) /*(st->core == TCX_20_CORE)*/
&& ( EQ_16( st->last_core, TCX_20_CORE ) ) /*&&(st->last_core == TCX_20_CORE)*/
&& ( EQ_16( hRF->rf_second_last_core, TCX_20_CORE ) ) /*&& (st->rf_second_last_core == TCX_20_CORE)*/
@@ -687,10 +703,12 @@ void core_encode_openloop_fx(
LT_16( hRF->rf_gain_tcx[0], mult_r( hRF->rf_gain_tcx[1], 29491 /*0.90f Q15*/ ) ) ) )
{
TD_mode = 0;
+ move16();
}
ELSE
{
TD_mode = 1;
+ move16();
}
/* updates */
@@ -743,6 +761,7 @@ static void closest_centroid_rf(
Word32 L_tmp, best_werr, werr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
ind_vec[0] = 0;
@@ -782,12 +801,12 @@ static void closest_centroid_rf(
void core_acelp_tcx20_switching_fx(
Encoder_State *st, /* i/o: encoder state structure */
- Word16 non_staX, /* i : unbound non-stationarity for sp/mu clas */
- Word16 *pitch_fr, /* i/o: fraction pitch values */
- Word16 *voicing_fr, /* i/o: fractional voicing values */
- const Word16 currFlatness, /* i : flatness */
- const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame */
- const Word16 stab_fac, /* i : LP filter stability */
+ Word16 non_staX, /* i : unbound non-stationarity for sp/mu clas Q8*/
+ Word16 *pitch_fr, /* i/o: fraction pitch values Q6*/
+ Word16 *voicing_fr, /* i/o: fractional voicing values Q15*/
+ const Word16 currFlatness, /* i : flatness Q7*/
+ const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame Q15*/
+ const Word16 stab_fac, /* i : LP filter stability Q15*/
Word16 Q_new,
Word16 shift )
{
@@ -818,6 +837,7 @@ void core_acelp_tcx20_switching_fx(
SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Check minimum pitch for quantization */
@@ -920,7 +940,7 @@ void core_acelp_tcx20_switching_fx(
Copy( hTcxEnc->speech_ltp + sub( tcx_offset, shr( overlap, 1 ) ), xn_buf, add( L_frame, overlap ) );
tmp16 = shr( overlap, 1 );
- IF( EQ_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core == ACELP_CORE )
{
IF( tcx_offset < 0 )
{
@@ -958,7 +978,7 @@ void core_acelp_tcx20_switching_fx(
tmp16 = mult_r( shl( L_frame, 5 ), 29309 /*16*0.0559017 Q15*/ ); /* L_frame / sqrt(2*NORM_MDCT_FACTOR); Q9 */
FOR( i = 0; i < L_frame; i++ )
{
- x[i] = Mpy_32_16_1( x[i], tmp16 );
+ x[i] = Mpy_32_16_1( x[i], tmp16 ); // Q(31-(x_e+6))
move32();
}
x_e = add( x_e, 6 );
@@ -971,7 +991,7 @@ void core_acelp_tcx20_switching_fx(
IF( st->narrowBand )
{
- j = mult( L_frame, 20480 );
+ j = mult( L_frame, 20480 /* .625 Q15*/ );
set32_fx( &x[j], 0, sub( L_frame, j ) );
}
@@ -1220,7 +1240,7 @@ void core_acelp_tcx20_switching_fx(
if ( ( GT_16( snr_acelp, snr_tcx ) ) &&
( LT_16( snr_acelp, add( snr_tcx, 512 /*2.0f Q8*/ ) ) ) &&
#ifdef BASOP_NOGLOB
- ( LT_16( add_o( st->prevTempFlatness_fx, currFlatness, &Overflow ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff ) ||
+ ( LT_16( add_o( st->prevTempFlatness_fx, currFlatness, &Overflow ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) ||
#else /* BASOP_NOGLOB */
( LT_16( add( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff ) ||
#endif
@@ -1269,7 +1289,7 @@ void core_acelp_tcx20_switching_fx(
test();
test();
test();
- if ( EQ_32( st->sr_core, INT_FS_12k8 ) && ( offset_tcx < 0x18950F ) && GT_16( non_staX, 1280 /*5.0f Q8*/ ) && ( snr_acelp >= snr_tcx - 1024 /*4.0f in Q8*/ ) && GE_16( st->acelpFramesCount, 1 ) && ( ( GT_16( hSpMusClas->lps_fx, hSpMusClas->lpm_fx ) && GE_16( tmp16, 9830 ) ) || ( GE_16( st->acelpFramesCount, 6 ) && ( hSpMusClas->lps_fx > hSpMusClas->lpm_fx - 768 ) ) ) && ( st->sp_aud_decision0 == 0 ) && st->vad_flag != 0 )
+ if ( EQ_32( st->sr_core, INT_FS_12k8 ) && ( offset_tcx < 0x18950F ) && GT_16( non_staX, 1280 /*5.0f Q8*/ ) && ( GE_16( snr_acelp, sub( snr_tcx, 1024 /*4.0f in Q8*/ ) ) ) && GE_16( st->acelpFramesCount, 1 ) && ( ( GT_16( hSpMusClas->lps_fx, hSpMusClas->lpm_fx ) && GE_16( tmp16, 9830 ) ) || ( GE_16( st->acelpFramesCount, 6 ) && ( GT_16( hSpMusClas->lps_fx, sub( hSpMusClas->lpm_fx, 768 ) ) ) ) ) && ( st->sp_aud_decision0 == 0 ) && st->vad_flag != 0 )
{
/* Fine tuned across various databases based on various metrics to detect TCX frames in speech.*/
dsnr = 1024;
@@ -1296,15 +1316,17 @@ void core_acelp_tcx20_switching_fx(
test();
test();
if ( EQ_32( st->sr_core, INT_FS_12k8 ) && ( LT_16( non_staX, 512 /*2.0f Q8*/ ) || ( st->flag_noisy_speech_snr == 0 && EQ_16( st->vad_flag, 1 ) && ( offset_tcx == L_add( 0xFFD57AB5, 0 ) ) && GE_16( st->acelpFramesCount, 6 ) ) ) &&
- ( st->last_core == ACELP_CORE || st->last_core == TCX_20_CORE ) )
+ ( st->last_core == ACELP_CORE || EQ_16( st->last_core, TCX_20_CORE ) ) )
{
st->core = st->last_core;
+ move16();
}
ELSE IF( GT_16( add( snr_acelp, dsnr ), snr_tcx ) )
{
st->core = ACELP_CORE;
move16();
st->acelpFramesCount = s_min( 32767 - 1, add( st->acelpFramesCount, 1 ) );
+ move16();
}
ELSE
{
@@ -1356,12 +1378,13 @@ void core_acelp_tcx20_switching_fx(
*-------------------------------------------------------------------*/
static void BITS_ALLOC_ACELP_config_rf(
const Word16 coder_type,
- Word16 *tilt_code,
+ Word16 *tilt_code, // Q15
Word16 *rf_frame_type,
Word16 *rf_target_bits,
Word16 nb_subfr,
Word16 rf_fec_indicator,
- Word16 *pitch_buf )
+ Word16 *pitch_buf // Q6
+)
{
Word16 mean_tc, min_tilt_code, max_tilt_code;
Word16 nrgMode, ltfMode, ltpMode, gainsMode;
@@ -1417,6 +1440,10 @@ static void BITS_ALLOC_ACELP_config_rf(
IF( EQ_16( rf_fec_indicator, 1 ) )
{
+ test();
+ test();
+ test();
+ test();
test();
test();
test();
@@ -1434,6 +1461,10 @@ static void BITS_ALLOC_ACELP_config_rf(
}
ELSE
{
+ test();
+ test();
+ test();
+ test();
test();
test();
test();
@@ -1456,41 +1487,52 @@ static void BITS_ALLOC_ACELP_config_rf(
/* rf_mode, 1 bit */
*rf_target_bits = add( *rf_target_bits, 1 );
-
+ move16();
/* rf_fec_offset 2 bits */
*rf_target_bits = add( *rf_target_bits, 2 );
-
+ move16();
/* rf_frame_type, 3 bits */
*rf_target_bits = add( *rf_target_bits, 3 );
-
+ move16();
/* LSF bits 8 + 8 bits */
*rf_target_bits = add( *rf_target_bits, 16 );
-
+ move16();
/* Intialize the RF mode frame type to all-pred */
*rf_frame_type = RF_ALLPRED;
-
+ move16();
+ test();
+ test();
+ test();
test();
- IF( EQ_16( coder_type, INACTIVE ) || en_partial_red == 0 )
+ IF( coder_type == INACTIVE || en_partial_red == 0 )
{
*rf_frame_type = RF_NO_DATA;
+ move16();
}
- ELSE IF( EQ_16( coder_type, UNVOICED ) || EQ_16( coder_type, INACTIVE ) )
+ ELSE IF( EQ_16( coder_type, UNVOICED ) || ( coder_type == INACTIVE ) )
{
*rf_frame_type = RF_NELP;
+ move16();
}
ELSE IF( EQ_16( coder_type, GENERIC ) && LT_16( max_tilt_code, 1638 /*0.05f Q15*/ ) )
{
*rf_frame_type = RF_NOPRED;
+ move16();
}
ELSE IF( EQ_16( coder_type, GENERIC ) && LT_16( mean_tc, 9830 /*0.3f Q15*/ ) )
{
*rf_frame_type = RF_GENPRED;
+ move16();
}
nrgMode = ACELP_NRG_MODE[1][1][*rf_frame_type];
ltfMode = ACELP_LTF_MODE[1][1][*rf_frame_type];
ltpMode = ACELP_LTP_MODE[1][1][*rf_frame_type];
gainsMode = ACELP_GAINS_MODE[1][1][*rf_frame_type];
+ move16();
+ move16();
+ move16();
+ move16();
/* Number of RF bits for different RF coder types */
SWITCH( *rf_frame_type )
@@ -1499,6 +1541,7 @@ static void BITS_ALLOC_ACELP_config_rf(
/* Es_pred bits 3 bits, LTF: 1, pitch: 8,5,5,5, FCB: 0, gain: 7,0,7,0, Diff GFr: 4*/
*rf_target_bits += ( ACELP_NRG_BITS[nrgMode] + ACELP_LTF_BITS[ltfMode] + ACELP_LTP_BITS_SFR[ltpMode][0] + ACELP_LTP_BITS_SFR[ltpMode][1] + ACELP_LTP_BITS_SFR[ltpMode][2] + ACELP_LTP_BITS_SFR[ltpMode][3] + ACELP_GAINS_BITS[gainsMode] + ACELP_GAINS_BITS[gainsMode] + 2 /*2 bits for PartialCopy GainFrame*/
);
+ move16();
BREAK;
case RF_NOPRED:
@@ -1506,6 +1549,7 @@ static void BITS_ALLOC_ACELP_config_rf(
/*bits += (3 + 0 + 0 + 28 + 12 + 2); */ /* 64 rf bits */
*rf_target_bits += ( ACELP_NRG_BITS[nrgMode] + ACELP_LTF_BITS[ltfMode] + 28 + ACELP_GAINS_BITS[gainsMode] + ACELP_GAINS_BITS[gainsMode] + 2 /*2 bits for PartialCopy GainFrame*/
);
+ move16();
BREAK;
case RF_GENPRED:
@@ -1513,16 +1557,19 @@ static void BITS_ALLOC_ACELP_config_rf(
/*bits += (3 + 0 + 16 + 23 + 10 + 0); */ /* 72 rf bits */
*rf_target_bits += ( ACELP_NRG_BITS[nrgMode] + ACELP_LTF_BITS[ltfMode] + ACELP_LTP_BITS_SFR[ltpMode][0] + ACELP_LTP_BITS_SFR[ltpMode][1] + ACELP_LTP_BITS_SFR[ltpMode][2] + ACELP_LTP_BITS_SFR[ltpMode][3] + 14 + ACELP_GAINS_BITS[gainsMode] + ACELP_GAINS_BITS[gainsMode] + 2 /*2 bits for PartialCopy GainFrame*/
);
+ move16();
BREAK;
case RF_NELP:
/* gain: 19, Diff GFr: 5 */
/*bits += (19 + 5); */
*rf_target_bits += ( 19 + NUM_BITS_SHB_FRAMEGAIN );
+ move16();
BREAK;
case RF_NO_DATA:
*rf_target_bits = 6;
+ move16();
BREAK;
default:
@@ -1553,7 +1600,7 @@ static void BITS_ALLOC_TCX_config_rf(
move16();
test();
- IF( EQ_16( coder_type, INACTIVE ) || EQ_16( last_core, ACELP_CORE ) )
+ IF( ( coder_type == INACTIVE ) || ( last_core == ACELP_CORE ) )
{
*rf_frame_type = RF_NO_DATA;
move16();
diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c
index 911e4b7a4be548036201f1235cddb4a3aca68463..24729c1241da0adae89e9cbe65962bb739122ed3 100644
--- a/lib_enc/core_enc_reconf.c
+++ b/lib_enc/core_enc_reconf.c
@@ -48,200 +48,6 @@
* - reconfig core coder when switching to another frame type *
*-----------------------------------------------------------------*/
-void core_coder_reconfig(
- Encoder_State *st,
- const int32_t last_total_brate )
-{
- TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
- int16_t bwidth, i, index;
-
- /*Configuration of ACELP*/
- BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) );
-
- /*Configuration of partial copy*/
- if ( st->Opt_RF_ON )
- {
- st->hRF->acelp_cfg_rf.mode_index = 1;
- st->hRF->acelp_cfg_rf.midLpc = 0;
- st->hRF->acelp_cfg_rf.midLpc_enable = 0;
- st->hRF->acelp_cfg_rf.pre_emphasis = 0;
- st->hRF->acelp_cfg_rf.formant_enh = 1;
- st->hRF->acelp_cfg_rf.formant_tilt = 1;
- st->hRF->acelp_cfg_rf.voice_tilt = 1;
- st->hRF->acelp_cfg_rf.formant_enh_num = FORMANT_SHARPENING_G1;
- st->hRF->acelp_cfg_rf.formant_enh_den = FORMANT_SHARPENING_G2;
- }
-
- if ( st->element_mode == IVAS_CPE_MDCT )
- {
- st->nb_bits_header_tcx = 2; /* signal class */
- }
- else if ( st->tcxonly )
- {
- st->nb_bits_header_tcx = 1 + 1; /*TCX20/TCX10 + last_core*/
- st->nb_bits_header_tcx += 2; /* Siganl class*/
- }
- else
- {
- st->nb_bits_header_ace = 1 + 2 + 1; /*TCX/ACELP+coder_type + last_core*/
- st->nb_bits_header_tcx = st->nb_bits_header_ace;
-
- if ( st->hTcxCfg != NULL )
- {
- if ( st->hTcxCfg->lfacNext <= 0 )
- {
- st->nb_bits_header_ace--; /*No last_core*/
- }
- }
- }
-
- /*Switch off TCX or ACELP?*/
- if ( st->sr_core == INT_FS_12k8 )
- {
- st->acelpEnabled = ( st->restrictedMode & 1 ) == 1;
- st->tcx20Enabled = ( st->restrictedMode & 2 ) == 2;
- }
- st->prevEnergyHF_fx = st->currEnergyHF_fx = 1073725440l /*65535.0f Q14*/; /* prevent block switch */
- st->currEnergyHF_e_fx = 17;
- move32();
- move32();
- move16();
-
- /* TCX-LTP */
- if ( st->hTcxEnc != NULL )
- {
- st->hTcxEnc->tcxltp = getTcxLtp( st->sr_core );
- }
-
- /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/
- st->acelp_autocorr = 1;
- if ( st->total_brate <= ACELP_9k60 && st->sr_core == INT_FS_12k8 )
- {
- st->acelp_autocorr = 0;
- }
-
- /*Get audio bandwidth info*/
- if ( st->narrowBand )
- {
- bwidth = NB;
- }
- else if ( st->sr_core <= INT_FS_16k )
- {
- bwidth = WB;
- }
- else
- {
- bwidth = SWB;
- }
-
- /*Scale TCX for non-active frames to adjust loudness with ACELP*/
- if ( st->hTcxCfg != NULL )
- {
- st->hTcxCfg->na_scale = 32767;
- if ( bwidth < SWB && !( st->tcxonly ) )
- {
- for ( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ )
- {
- if ( ( bwidth == scaleTcxTable[i].bwmode ) &&
- ( st->total_brate >= scaleTcxTable[i].bitrateFrom ) &&
- ( st->total_brate < scaleTcxTable[i].bitrateTo ) )
- {
- if ( st->rf_mode )
- {
- i--;
- }
- st->hTcxCfg->na_scale = scaleTcxTable[i].scale;
- break;
- }
- }
- }
- }
-
- if ( st->element_mode > IVAS_SCE )
- {
- st->enableTcxLpc = ( st->lpcQuantization == 1 ) && ( st->total_brate <= LOWRATE_TCXLPC_MAX_BR_CPE || st->rf_mode );
- }
- else
- {
- st->enableTcxLpc = ( st->lpcQuantization == 1 ) && ( st->total_brate <= LOWRATE_TCXLPC_MAX_BR || st->rf_mode );
- }
-
- if ( st->ini_frame == 0 || st->last_codec_mode == MODE1 )
- {
- st->envWeighted = 0;
- }
-
- if ( st->bwidth == SWB && ( st->total_brate == ACELP_16k40 || st->total_brate == ACELP_24k40 ) && st->element_mode == EVS_MONO )
- {
- if ( st->tec_tfa == 0 )
- {
- set16_fx( st->hTECEnc->loBuffer, 0, MAX_TEC_SMOOTHING_DEG );
- }
- st->tec_tfa = 1;
- }
- else
- {
- st->tec_tfa = 0;
- }
-
- st->enablePlcWaveadjust = 0;
- if ( st->total_brate >= HQ_48k )
- {
- st->enablePlcWaveadjust = 1;
- }
-
- st->glr = 0;
- if ( ( st->total_brate == ACELP_9k60 || st->total_brate == ACELP_16k40 || st->total_brate == ACELP_24k40 ) && st->element_mode == EVS_MONO )
- {
- st->glr = 1;
- }
-
- if ( st->glr )
- {
- st->nb_bits_header_ace += G_LPC_RECOVERY_BITS;
- }
-
- if ( hTcxEnc != NULL )
- {
- if ( st->bwidth == NB || st->bwidth == WB )
- {
- index = min( N_TCX_STARTLINE_NOISE_WB - 1, (uint16_t) max( 0, ( st->rf_mode == 0 ) ? st->frame_size_index : st->frame_size_index - 1 ) );
- hTcxEnc->nmStartLine = startLineWB[index];
- }
- else /* (st->bwidth == SWB || st->bwidth == FB) */
- {
- index = min( N_TCX_STARTLINE_NOISE_SWB - 1, (uint16_t) max( 3, ( st->rf_mode == 0 ) ? st->frame_size_index : st->frame_size_index - 1 ) - 3 );
- if ( st->total_brate >= IVAS_96k && st->total_brate <= IVAS_192k && st->element_mode > IVAS_SCE )
- {
- index--;
- }
- hTcxEnc->nmStartLine = startLineSWB[index];
- if ( st->total_brate == IVAS_48k && st->element_mode == IVAS_CPE_MDCT && hTcxEnc->nmStartLine * 5 < st->L_frame * 4 )
- {
- hTcxEnc->nmStartLine = ( hTcxEnc->nmStartLine * 5 ) >> 2; /* low-rate stereo is more efficient than dual-mono due to stereo processing */
- }
- }
- }
-
- if ( hTcxEnc != NULL )
- {
- if ( st->total_brate < ACELP_24k40 && ( ( st->total_brate > last_total_brate ) || ( st->last_codec_mode == MODE1 ) ) )
- {
- /* low-freq memQuantZeros must be reset partially if bitrate increased */
- set_c( hTcxEnc->memQuantZeros, 0, hTcxEnc->nmStartLine );
- }
- else
- {
- if ( st->total_brate >= ACELP_24k40 && st->total_brate <= ACELP_32k && last_total_brate >= ACELP_13k20 && last_total_brate < ACELP_24k40 )
- {
- set_c( hTcxEnc->memQuantZeros, 0, st->L_frame );
- }
- }
- }
-
- return;
-}
-
void core_coder_reconfig_ivas_fx(
Encoder_State *st )
{
@@ -270,6 +76,7 @@ void core_coder_reconfig_ivas_fx(
move16();
move16();
move16();
+ move16();
}
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
@@ -305,8 +112,8 @@ void core_coder_reconfig_ivas_fx(
/*Switch off TCX or ACELP?*/
IF( EQ_32( st->sr_core, INT_FS_12k8 ) )
{
- st->acelpEnabled = (Word16) EQ_16( ( s_and( st->restrictedMode, 1 ) ), 1 );
- st->tcx20Enabled = (Word16) EQ_16( ( s_and( st->restrictedMode, 2 ) ), 2 );
+ st->acelpEnabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 1 ) ), 1 ) );
+ st->tcx20Enabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 2 ) ), 2 ) );
move16();
move16();
}
@@ -455,7 +262,7 @@ void core_coder_reconfig_ivas_fx(
test();
test();
test();
- if ( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
+ if ( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( st->element_mode == EVS_MONO ) )
{
move16();
st->glr = 1;
@@ -502,7 +309,7 @@ void core_coder_reconfig_ivas_fx(
move16();
test();
test();
- if ( EQ_32( st->total_brate, IVAS_48k ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LT_16( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), shl( st->L_frame, 2 ) ) )
+ IF( EQ_32( st->total_brate, IVAS_48k ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LT_16( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), shl( st->L_frame, 2 ) ) )
{
hTcxEnc->nmStartLine = shr( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), 2 ); /* low-rate stereo is more efficient than dual-mono due to stereo processing */
move16();
diff --git a/lib_enc/core_enc_reconf_fx.c b/lib_enc/core_enc_reconf_fx.c
index c11dd9959af47ec89ff3c687936dd24f2926d496..3140422be5d88531fba60b90693049aa84388a8b 100644
--- a/lib_enc/core_enc_reconf_fx.c
+++ b/lib_enc/core_enc_reconf_fx.c
@@ -31,7 +31,7 @@ void core_coder_reconfig_fx(
BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) );
/*Configuration of partial copy*/
- if ( st->Opt_RF_ON )
+ IF( st->Opt_RF_ON )
{
st->hRF->acelp_cfg_rf.mode_index = 1;
st->hRF->acelp_cfg_rf.midLpc = 0;
@@ -58,6 +58,7 @@ void core_coder_reconfig_fx(
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
st->nb_bits_header_tcx = 2; /* signal class */
+ move16();
}
ELSE IF( st->tcxonly == 0 )
{
@@ -71,6 +72,7 @@ void core_coder_reconfig_fx(
{
/*st->nb_bits_header_ace--;*/ /*No Last_mode*/
st->nb_bits_header_ace = sub( st->nb_bits_header_ace, 1 );
+ move16();
}
}
}
@@ -78,6 +80,7 @@ void core_coder_reconfig_fx(
if ( st->tcxonly )
{
st->nb_bits_header_tcx = add( st->nb_bits_header_tcx, 2 );
+ move16();
}
@@ -109,11 +112,11 @@ void core_coder_reconfig_fx(
st->currEnergyHF_e_fx = 17;
/*Sanity check : don't need to be instrumented*/
- if ( st->tcxonly == 0 )
+ IF( st->tcxonly == 0 )
{
assert( st->acelpEnabled || st->tcx20Enabled || st->frame_size_index == 0 );
}
- else
+ ELSE
{
assert( st->tcx10Enabled || st->tcx20Enabled || st->frame_size_index == 0 );
}
@@ -122,6 +125,7 @@ void core_coder_reconfig_fx(
IF( st->hTcxEnc != NULL )
{
hTcxEnc->tcxltp = getTcxLtp( st->sr_core );
+ move16();
}
/*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/
@@ -157,6 +161,7 @@ void core_coder_reconfig_fx(
IF( st->hTcxCfg != NULL )
{
st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/;
+ move16();
test();
IF( LT_16( bwidth, 2 ) && ( st->tcxonly == 0 ) )
@@ -174,7 +179,7 @@ void core_coder_reconfig_fx(
{
if ( st->rf_mode )
{
- i--;
+ i = sub( i, 1 );
}
move16();
st->hTcxCfg->na_scale = scaleTcxTable[i].scale;
@@ -242,11 +247,11 @@ void core_coder_reconfig_fx(
move16();
st->glr = 0;
+
test();
test();
test();
- test();
- if ( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
+ if ( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( st->element_mode == EVS_MONO ) )
{
move16();
st->glr = 1;
@@ -256,13 +261,14 @@ void core_coder_reconfig_fx(
{
st->nb_bits_header_ace = add( st->nb_bits_header_ace, G_LPC_RECOVERY_BITS );
+ move16();
}
IF( hTcxEnc != NULL )
{
test();
IF( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, WB ) )
{
- test();
+
IF( st->rf_mode == 0 )
{
index = s_min( N_TCX_STARTLINE_NOISE_WB - 1, s_max( 3, st->frame_size_index ) );
@@ -292,9 +298,12 @@ void core_coder_reconfig_fx(
}
hTcxEnc->nmStartLine = startLineSWB[index];
move16();
+ test();
+ test();
if ( EQ_32( st->total_brate, IVAS_48k ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LT_16( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), shl( st->L_frame, 2 ) ) )
{
hTcxEnc->nmStartLine = shr( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), 2 ); /* low-rate stereo is more efficient than dual-mono due to stereo processing */
+ move16();
}
}
}
diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c
index f5a2e1245547d834d87ff8b2404103c6ddc8e265..e5c3903a1789031ba9481c8f483235735965d117 100644
--- a/lib_enc/core_enc_switch.c
+++ b/lib_enc/core_enc_switch.c
@@ -68,7 +68,7 @@ void core_coder_mode_switch_ivas_fx(
move16();
- IF( EQ_16( st->last_core, AMR_WB_CORE ) )
+ if ( EQ_16( st->last_core, AMR_WB_CORE ) )
{
bSwitchFromAmrwbIO = 1;
move16();
@@ -99,7 +99,7 @@ void core_coder_mode_switch_ivas_fx(
st->sr_core = sr_core;
move16();
Word16 tmp = BASOP_Util_Divide3232_Scale( sr_core, FRAMES_PER_SEC, &exp_res );
- st->L_frame = shr( tmp, 15 - exp_res );
+ st->L_frame = shr( tmp, sub( 15, exp_res ) ); // Q0
move16();
st->tcxonly = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format );
@@ -119,7 +119,7 @@ void core_coder_mode_switch_ivas_fx(
Word32 tmp4 = L_mult0( tmp1, tmp2 ); // exp_tmp1 + exp_tmp2
Word32 tmp5 = L_shl( Mpy_32_16_1( tmp4, tmp3 ), 1 ); // exp_tmp1 + exp_tmp2 + exp_tmp3
- st->bits_frame_nominal = (Word16) L_shr( tmp5, sub( 31, ( add( add( exp_tmp1, exp_tmp2 ), exp_tmp3 ) ) ) );
+ st->bits_frame_nominal = extract_l( L_shr( tmp5, sub( 31, ( add( add( exp_tmp1, exp_tmp2 ), exp_tmp3 ) ) ) ) );
move16();
st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode );
move16();
@@ -133,12 +133,30 @@ void core_coder_mode_switch_ivas_fx(
st->hTcxCfg->bandwidth = getTcxBandwidth( st->bwidth );
move16();
- st->hTcxCfg->tcxRateLoopOpt = ( st->tcxonly ) ? 2 : 0;
- st->hTcxCfg->tcxRateLoopOpt = ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) ? 3 : st->hTcxCfg->tcxRateLoopOpt;
+ if ( st->tcxonly )
+ {
+ st->hTcxCfg->tcxRateLoopOpt = 2;
+ move16();
+ }
+ else
+ {
+ st->hTcxCfg->tcxRateLoopOpt = 0;
+ move16();
+ }
+ if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ st->hTcxCfg->tcxRateLoopOpt = 3;
+ move16();
+ }
st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode );
st->hTcxCfg->resq = getResq( st->total_brate );
hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode );
- st->hTcxCfg->tcxRateLoopOpt = ( st->hTcxCfg->resq && !st->tcxonly ) ? 1 : st->hTcxCfg->tcxRateLoopOpt;
+ test();
+ if ( st->hTcxCfg->resq && !st->tcxonly )
+ {
+ st->hTcxCfg->tcxRateLoopOpt = 1;
+ move16();
+ }
st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->total_brate, st->igf, st->element_mode );
move16();
move16();
@@ -174,7 +192,7 @@ void core_coder_mode_switch_ivas_fx(
FOR( i = 0; i < FRAME_SIZE_NB; i++ )
{
- IF( FrameSizeConfig[i].frame_bits == st->bits_frame_nominal )
+ IF( EQ_32( FrameSizeConfig[i].frame_bits, st->bits_frame_nominal ) )
{
st->frame_size_index = i;
st->bits_frame = FrameSizeConfig[i].frame_bits;
@@ -182,7 +200,7 @@ void core_coder_mode_switch_ivas_fx(
move16();
move16();
move16();
- break;
+ BREAK;
}
}
@@ -201,6 +219,8 @@ void core_coder_mode_switch_ivas_fx(
}
st->currEnergyHF_fx = 0;
move32();
+ st->currEnergyHF_e_fx = 0;
+ move16();
Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM );
Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift );
st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift );
@@ -210,7 +230,7 @@ void core_coder_mode_switch_ivas_fx(
st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift );
move16();
init_coder_ace_plus_ivas_fx( st, last_total_brate, MCT_flag );
- IF( st->hLPDmem != NULL )
+ if ( st->hLPDmem != NULL )
{
st->hLPDmem->q_lpd_old_exc = st->prev_Q_new;
move16();
@@ -268,7 +288,7 @@ void core_coder_mode_switch_ivas_fx(
test();
test();
- IF( ( GT_32( last_total_brate, HQ_32k ) || EQ_16( st->last_codec_mode, MODE1 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
+ if ( ( GT_32( last_total_brate, HQ_32k ) || EQ_16( st->last_codec_mode, MODE1 ) ) && ( st->element_mode == EVS_MONO ) )
{
st->glr_reset = 1;
move16();
diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c
index b3738eef9b47869bba55402da711c34d8187f4d8..1096cfb492cb75edc8ad6ba65069ae4690ec5ef6 100644
--- a/lib_enc/core_enc_switch_fx.c
+++ b/lib_enc/core_enc_switch_fx.c
@@ -29,8 +29,7 @@ void core_coder_mode_switch_fx(
TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD;
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
- move16();
- move16();
+
move16();
move16();
@@ -43,7 +42,7 @@ void core_coder_mode_switch_fx(
}
sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format );
- move16();
+ move32();
fscale = sr2fscale( sr_core );
move16();
@@ -59,7 +58,6 @@ void core_coder_mode_switch_fx(
tcxonly_tmp = getTcxonly( st->total_brate );
#endif
- test();
if ( NE_16( tcxonly_tmp, st->tcxonly ) )
{
move16();
@@ -85,9 +83,9 @@ void core_coder_mode_switch_fx(
/* 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 */
st->bits_frame_nominal = extract_l( L_shr( Mpy_32_16_1( tmp32, 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */
-
+ move16();
st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode );
-
+ move16();
/* switch IGF configuration */
IF( st->igf )
{
@@ -111,7 +109,7 @@ void core_coder_mode_switch_fx(
st->hTcxCfg->resq = getResq( st->total_brate );
move16();
hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode );
-
+ move16();
test();
if ( st->hTcxCfg->resq != 0 && st->tcxonly == 0 )
{
@@ -119,6 +117,7 @@ void core_coder_mode_switch_fx(
move16();
}
st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->total_brate, st->igf, st->element_mode );
+ move16();
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 );
@@ -126,7 +125,6 @@ void core_coder_mode_switch_fx(
SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, EQ_16( st->element_mode, IVAS_CPE_MDCT ) );
#endif
}
- move16();
st->narrowBand = 0;
move16();
@@ -166,12 +164,13 @@ void core_coder_mode_switch_fx(
}
st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, 0 );
-
+ move16();
core_coder_reconfig_fx( st, last_total_bitrate );
}
ELSE
{
st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode );
+ move16();
init_coder_ace_plus_fx( st, last_total_bitrate, shift, MCT_flag );
}
@@ -218,7 +217,7 @@ void core_coder_mode_switch_fx(
}
test();
- IF( ( GT_32( last_total_bitrate, HQ_32k ) || EQ_32( st->last_codec_mode, MODE1 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
+ IF( ( GT_32( last_total_bitrate, HQ_32k ) || EQ_32( st->last_codec_mode, MODE1 ) ) && ( st->element_mode == EVS_MONO ) )
{
move16();
st->glr_reset = 1;
diff --git a/lib_enc/core_enc_updt.c b/lib_enc/core_enc_updt.c
index ff9f3762844609e86afe28c847175b2b4a861714..95f1c67b6cf9ded0a25f18b7436bb3b776894959 100644
--- a/lib_enc/core_enc_updt.c
+++ b/lib_enc/core_enc_updt.c
@@ -72,17 +72,18 @@ void core_encode_update_ivas_fx(
test();
test();
test();
- IF( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) )
+ IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) )
{
- Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, hTcxEnc->exp_buf_speech_ltp );
- Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, -( max_e - st->hTcxEnc->exp_buf_speech_ltp ) );
- Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, -( max_e - st->exp_buf_speech_enc ) );
+ Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc );
+ Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e)
+ Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e)
st->hTcxEnc->exp_buf_speech_ltp = max_e;
+ move16();
}
}
n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc );
- Copy( st->buf_synth + st->L_frame, st->buf_synth, st->L_frame + L_SUBFR );
+ Copy( st->buf_synth + st->L_frame, st->buf_synth, add( st->L_frame, L_SUBFR ) );
IF( hTcxEnc != NULL )
{
Copy( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n );
@@ -105,7 +106,8 @@ void core_encode_update_ivas_fx(
test();
test();
test();
- IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && ( EQ_16( st->codec_mode, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) ) )
+ test();
+ IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && ( EQ_16( st->codec_mode, MODE2 ) || ( st->element_mode > EVS_MONO ) ) ) )
{
/* reset LP memories */
set16_fx( st->mem_MA_fx, 0, M );
diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c
index bd6f5b5482e700c59c0be1cca2375df718a2e21f..125f0cd524c024eacb7ba95c1e8df1394853be01 100644
--- a/lib_enc/core_enc_updt_fx.c
+++ b/lib_enc/core_enc_updt_fx.c
@@ -38,7 +38,7 @@ void core_encode_update_fx( Encoder_State *st )
IF( hTcxEnc != NULL )
{
- IF( EQ_16( st->core, ACELP_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core, AMR_WB_CORE ) )
+ IF( ( st->core == ACELP_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core, AMR_WB_CORE ) )
{
Copy( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame );
}
@@ -146,7 +146,7 @@ void core_encode_update_cng_fx(
IF( EQ_32( st->core_brate, SID_2k40 ) )
{
/*IVAS_CODE CNG_att is missing */
- enr = cng_energy_fx( st->element_mode, st->bwidth, hDtxEnc->CNG_mode, /*st->hTdCngEnc->CNG_att*/ 0, hLPDmem->old_exc + s_max( L_EXC_MEM - st->L_frame, 0 ), st->L_frame, Q_new );
+ enr = cng_energy_fx( st->element_mode, st->bwidth, hDtxEnc->CNG_mode, /*st->hTdCngEnc->CNG_att*/ 0, hLPDmem->old_exc + s_max( sub( L_EXC_MEM, st->L_frame ), 0 ), st->L_frame, Q_new );
/* calculate the energy quantization index */
enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */
@@ -157,24 +157,24 @@ void core_encode_update_cng_fx(
enr_index = s_max( enr_index, 0 );
hTdCngEnc->old_enr_index = enr_index;
+ move16();
}
/* Update weighted synthesis memory */
- move16();
p_A = Aw;
FOR( i = 0; i < st->L_frame; i += L_SUBFR )
{
Residu3_fx( p_A, &synth[i], &wsyn[i], L_SUBFR, 0 );
p_A += ( M + 1 );
}
- move16();
tmp = sub( st->wspeech_enc[-1], shl( hLPDmem->mem_w0, shift ) );
- E_UTIL_deemph2( -shift, wsyn, st->preemph_fac, st->L_frame, &tmp );
+ E_UTIL_deemph2( negate( shift ), wsyn, st->preemph_fac, st->L_frame, &tmp );
hLPDmem->mem_w0 = sub( st->wspeech_enc[st->L_frame - 1], tmp );
hLPDmem->mem_w0 = shr( hLPDmem->mem_w0, shift );
-
+ move16();
+ move16();
/* Update LPC-related memories */
Copy( lsp, st->lsp_old_fx, M );
@@ -193,7 +193,9 @@ void core_encode_update_cng_fx(
hLPDmem->dm_fx.prev_state = 0;
hLPDmem->tilt_code = TILT_CODE;
hLPDmem->gc_threshold = L_deposit_l( 0 );
-
+ move16();
+ move16();
+ move16();
/* Update ace/tcx mode */
move16();
st->core = ACELP_CORE;
diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c
index d53e0892a1176136e9b67d43b5294876981d39c5..1b69de26d8a6fcfbcc65d8b07999bf079d6e867d 100644
--- a/lib_enc/core_switching_enc.c
+++ b/lib_enc/core_switching_enc.c
@@ -48,9 +48,9 @@
void core_switching_pre_enc_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz */
+ const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz q_old_inp_12k8 */
const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */
- const Word16 *old_inp_16k, /* i : old input signal @16kHz */
+ const Word16 *old_inp_16k, /* i : old input signal @16kHz q_old_inp_16k */
const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */
const Word16 active_cnt, /* i : active frame counter */
const Word16 last_element_mode /* i : last_element_mode */
@@ -70,7 +70,7 @@ void core_switching_pre_enc_ivas_fx(
test();
test();
test();
- IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && GT_16( st_fx->element_mode, EVS_MONO ) ) ) )
+ IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && ( st_fx->element_mode > EVS_MONO ) ) ) )
{
IF( hLPDmem != NULL )
{
@@ -87,11 +87,12 @@ void core_switching_pre_enc_ivas_fx(
IF( hBWE_TD != NULL )
{
- IF( NE_16( st_fx->last_core, ACELP_CORE ) )
+ IF( st_fx->last_core != ACELP_CORE )
{
/* reset BWE memories */
set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
+ move32();
}
set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
@@ -99,7 +100,7 @@ void core_switching_pre_enc_ivas_fx(
test();
IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) )
{
- if ( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode == EVS_MONO )
{
st_fx->last_core = HQ_CORE;
move16();
@@ -122,8 +123,9 @@ void core_switching_pre_enc_ivas_fx(
hHQ_core->prev_stab_hfe2 = 0;
move16();
}
+ test();
/*ALDO overlap windowed past: also used in MODE2 but for other MDCT-LB*/
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) && hTcxEnc != NULL )
+ IF( ( st_fx->element_mode == EVS_MONO ) && hTcxEnc != NULL )
{
set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k );
}
@@ -135,6 +137,7 @@ void core_switching_pre_enc_ivas_fx(
Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M );
st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 );
+ move16();
}
st_fx->use_acelp_preq = 0;
@@ -144,7 +147,7 @@ void core_switching_pre_enc_ivas_fx(
test();
test();
test();
- IF( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) )
+ if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) )
{
/* very first frame is HQ_CORE */
st_fx->last_core = HQ_CORE;
@@ -153,7 +156,7 @@ void core_switching_pre_enc_ivas_fx(
test();
test();
- IF( EQ_16( st_fx->core, HQ_CORE ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* HQ init */
+ IF( EQ_16( st_fx->core, HQ_CORE ) && ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* HQ init */
{
set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
@@ -171,7 +174,7 @@ void core_switching_pre_enc_ivas_fx(
hHQ_core->prev_stab_hfe2 = 0;
move16();
- if ( hTcxEnc != NULL )
+ IF( hTcxEnc != NULL )
{
set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k );
}
@@ -181,7 +184,7 @@ void core_switching_pre_enc_ivas_fx(
within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */
test();
test();
- IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) )
+ IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) )
{
IF( hSC_VBR != NULL )
{
@@ -197,7 +200,7 @@ void core_switching_pre_enc_ivas_fx(
test();
test();
test();
- IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) )
+ IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) )
{
st_fx->act_count = 3;
move16();
@@ -207,7 +210,12 @@ void core_switching_pre_enc_ivas_fx(
test();
test();
- IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ||
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ||
( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) )
{
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
@@ -222,6 +230,7 @@ void core_switching_pre_enc_ivas_fx(
}
st_fx->mem_deemph_fx = 0;
+ move16();
/* Reset ACELP parameters */
IF( hLPDmem != NULL )
{
@@ -255,7 +264,6 @@ void core_switching_pre_enc_ivas_fx(
move16();
tmp16 = add( NB_SUBFR, 1 );
- move16();
if ( EQ_16( st_fx->L_frame, L_FRAME ) )
{
@@ -268,7 +276,7 @@ void core_switching_pre_enc_ivas_fx(
/* Reset old ACELP buffers */
test();
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) && hLPDmem != NULL )
+ IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL )
{
set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM );
}
@@ -278,6 +286,7 @@ void core_switching_pre_enc_ivas_fx(
/* reset BWE memories */
hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move32();
}
IF( hBWE_FD != NULL )
{
@@ -287,7 +296,7 @@ void core_switching_pre_enc_ivas_fx(
test();
test();
test();
- IF( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) )
+ IF( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) )
{
/* Reset the ACELP core in case of TCX->ACELP core switching */
st_fx->Nb_ACELP_frames = 0;
@@ -305,7 +314,8 @@ void core_switching_pre_enc_ivas_fx(
set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 );
hLPDmem->dm_fx.prev_state = 0;
move16();
- hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 );
+ hLPDmem->dm_fx.prev_gain_code = 0;
+ move32();
}
st_fx->last_coder_type = GENERIC;
@@ -320,7 +330,7 @@ void core_switching_pre_enc_ivas_fx(
{
set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move16();
+ move32();
}
/* reset BWE memories */
@@ -361,7 +371,7 @@ void core_switching_pre_enc_ivas_fx(
{
Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS );
Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS );
- IF( GT_16( st_fx->element_mode, EVS_MONO ) )
+ IF( ( st_fx->element_mode > EVS_MONO ) )
{
IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
@@ -371,11 +381,11 @@ void core_switching_pre_enc_ivas_fx(
}
IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) )
{
- Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) );
+ Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp
}
ELSE
{
- Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) );
+ Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8
hBWE_FD->prev_Q_input_lp = q_old_inp_12k8;
move16();
Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
@@ -395,19 +405,19 @@ void core_switching_pre_enc_ivas_fx(
}
IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) )
{
- Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) );
+ Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp
}
ELSE
{
- Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) );
+ Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k
hBWE_FD->prev_Q_input_lp = q_old_inp_16k;
+ move16();
Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
}
}
tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP );
Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP );
- add( 0, 0 );
IF( NE_16( st_fx->last_extl, WB_BWE ) )
{
@@ -416,7 +426,8 @@ void core_switching_pre_enc_ivas_fx(
hBWE_FD->modeCount = 0;
move16();
}
- hBWE_FD->EnergyLF_fx = L_deposit_l( 0 );
+ hBWE_FD->EnergyLF_fx = 0;
+ move32();
hBWE_FD->prev_L_swb_norm1 = 8;
move16(); /*8.0 in Q0 */
st_fx->EnergyLT_fx_exp = 30;
@@ -425,19 +436,21 @@ void core_switching_pre_enc_ivas_fx(
/*---------------------------------------------------------------------*
* band-width switching from WB -> SWB/FB
*---------------------------------------------------------------------*/
- IF( GT_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode > EVS_MONO )
{
IF( st_fx->bwidth_sw_cnt == 0 )
{
+ test();
IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) )
{
st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 );
+ move16();
}
}
ELSE
{
st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 );
-
+ move16();
IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) )
{
st_fx->bwidth_sw_cnt = 0;
@@ -532,7 +545,7 @@ void core_switching_post_enc_ivas_fx(
test();
test();
test();
- test();
+
IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) &&
( EQ_16( st->last_core, HQ_CORE ) || NE_16( st->L_frame, st->last_L_frame ) || ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) ) )
{
@@ -573,14 +586,10 @@ void core_switching_post_enc_ivas_fx(
/* Fade towards init value for non HQ_CORE */
IF( st->hHQ_core != NULL )
{
- st->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( 2147483647, HQ_CREST_FAC_SM_FX ), HQ_CREST_THRESHOLD_FX ) ); /*Q28*/
+ st->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/
move32();
- st->hHQ_core->crest_lp_q = Q28;
- move16();
- st->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( 2147483647, HQ_CREST_FAC_SM_FX ), HQ_CREST_MOD_THRESHOLD_FX ) ); /*Q29*/
+ st->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/
move32();
- st->hHQ_core->crest_mod_lp_q = Q29;
- move16();
}
}
diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c
index fe470af2df29bc6a5dc5242a86f45f6985fcf17b..07468363f7f5f2e537499e8ebf549bbd6d09fef8 100644
--- a/lib_enc/core_switching_enc_fx.c
+++ b/lib_enc/core_switching_enc_fx.c
@@ -20,10 +20,10 @@
void core_switching_pre_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz */
- const Word16 *old_inp_16k, /* i : old input signal @16kHz */
- const Word16 active_cnt, /* i : active frame counter */
- const Word16 last_element_mode /* i : last_element_mode */
+ const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/
+ const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/
+ const Word16 active_cnt, /* i : active frame counter Q0*/
+ const Word16 last_element_mode /* i : last_element_mode Q0*/
)
{
Word16 Sample_Delay_HP, Sample_Delay_LP;
@@ -46,7 +46,7 @@ void core_switching_pre_enc_fx(
{
st_fx->mem_deemph_fx = hLPDmem->syn[M];
move16();
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M );
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); /*hLPDmem->q_mem_syn*/
}
if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
@@ -102,9 +102,9 @@ void core_switching_pre_enc_fx(
test();
IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) )
{
- Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M );
+ Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); /*Q15*/
- st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 );
+ st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); /*Q0*/
}
st_fx->use_acelp_preq = 0;
@@ -141,7 +141,7 @@ void core_switching_pre_enc_fx(
hHQ_core->prev_stab_hfe2 = 0;
move16();
- if ( hTcxEnc != NULL )
+ IF( hTcxEnc != NULL )
{
set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k );
}
@@ -151,7 +151,7 @@ void core_switching_pre_enc_fx(
within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */
test();
test();
- IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) )
+ IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) )
{
IF( hSC_VBR != NULL )
{
@@ -167,7 +167,7 @@ void core_switching_pre_enc_fx(
test();
test();
test();
- IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) )
+ IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) )
{
st_fx->act_count = 3;
move16();
@@ -177,17 +177,17 @@ void core_switching_pre_enc_fx(
test();
test();
- IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ||
+ IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ||
( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) )
{
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
- Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */
+ Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP Qlog2(2.56)*/
lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k );
}
ELSE
{
- Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */
+ Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP Qlog2(2.56)*/
lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX );
}
@@ -217,7 +217,7 @@ void core_switching_pre_enc_fx(
move16();
set16_fx( st_fx->mem_MA_fx, 0, M );
- Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M );
+ Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); /*Qlog2(2.56)*/
init_gp_clip_fx( st_fx->clip_var_fx );
st_fx->last_coder_type = GENERIC;
move16();
@@ -231,7 +231,7 @@ void core_switching_pre_enc_fx(
move16();
}
- Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 );
+ Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/
set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 );
/* Reset old ACELP buffers */
@@ -280,7 +280,7 @@ void core_switching_pre_enc_fx(
move16();
tmp16 = shr( st_fx->L_frame, 6 );
- Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 );
+ Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/
set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 );
/* Reset old TD BWE buffers */
@@ -337,7 +337,7 @@ void core_switching_pre_enc_fx(
}
Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
}
- Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
+ Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
}
ELSE
{
@@ -352,11 +352,11 @@ void core_switching_pre_enc_fx(
Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
}
- Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
+ Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
}
tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP );
- Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP );
+ Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); /*Q(Q_shb_spch)*/
add( 0, 0 );
IF( NE_16( st_fx->last_extl, WB_BWE ) )
@@ -367,8 +367,8 @@ void core_switching_pre_enc_fx(
move16();
}
hBWE_FD->EnergyLF_fx = L_deposit_l( 0 );
- hBWE_FD->prev_L_swb_norm1 = 8;
- move16(); /*8.0 in Q0 */
+ hBWE_FD->prev_L_swb_norm1 = 8; /*8.0 in Q0 */
+ move16();
st_fx->EnergyLT_fx_exp = 30;
move16(); /* Set to a High Exponent so it is 1^-30 */
}
@@ -428,7 +428,7 @@ void core_switching_post_enc_fx(
test();
test();
- IF( ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* core switching ==> CELP subframe encoding */
+ IF( ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* core switching ==> CELP subframe encoding */
{
acelp_core_switch_enc_fx( st_fx, old_inp_12k8 + L_INP_MEM - NS2SA_FX2( INT_FS_FX, ACELP_LOOK_NS ),
old_inp_16k + L_INP_MEM - NS2SA_FX2( INT_FS_16k, ACELP_LOOK_NS ), A, Qshift, Q_new );
@@ -513,8 +513,8 @@ void core_switching_post_enc_fx(
set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD );
set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER );
set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER );
- hBWE_TD->gain_prec_swb_fx = 16384;
- move16(); /*Q14 = 1 */
+ hBWE_TD->gain_prec_swb_fx = 16384; /*Q14 = 1 */
+ move16();
}
ELSE IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) )
{
@@ -522,6 +522,8 @@ void core_switching_post_enc_fx(
}
test();
test();
+ test();
+ test();
IF( EQ_16( st_fx->extl, FB_TBE ) && ( ( NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) ) )
{
set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER );
@@ -551,10 +553,10 @@ void core_switching_post_enc_fx(
void core_switching_hq_prepare_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- Word16 *num_bits, /* i/o: bit budget update */
- const Word16 input_frame, /* i : frame length */
+ Word16 *num_bits, /* i/o: bit budget update Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */
- const Word16 *audio )
+ const Word16 *audio /*q_audio*/ )
{
Word16 delta, Loverlapp, i;
Word16 tmp16;
@@ -568,22 +570,22 @@ void core_switching_hq_prepare_enc_fx(
case L_FRAME8k:
delta = 1;
move16();
- pt_cos = sin_switch_8;
+ pt_cos = sin_switch_8; /*Q15*/
BREAK;
case L_FRAME16k:
delta = 2;
move16();
- pt_cos = sin_switch_16;
+ pt_cos = sin_switch_16; /*Q15*/
BREAK;
case L_FRAME32k:
delta = 4;
move16();
- pt_cos = sin_switch_32;
+ pt_cos = sin_switch_32; /*Q15*/
BREAK;
default:
delta = 6;
move16();
- pt_cos = sin_switch_48;
+ pt_cos = sin_switch_48; /*Q15*/
BREAK;
}
@@ -642,25 +644,25 @@ void core_switching_hq_prepare_enc_fx(
}
/* Transition window at the encoder */
- n = i_mult2( N_ZERO_8, delta );
- Loverlapp = i_mult2( SWITCH_OVERLAP_8k, delta );
+ n = i_mult2( N_ZERO_8, delta ); /*Q0*/
+ Loverlapp = i_mult2( SWITCH_OVERLAP_8k, delta ); /*Q0*/
/*Overflow=0; */
- pt_32 = wtda_audio + shr( input_frame, 1 );
- pt_16 = audio + sub( n, 1 );
+ pt_32 = wtda_audio + shr( input_frame, 1 ); /*q_audio+15*/
+ pt_16 = audio + sub( n, 1 ); /*q_audio*/
tmp16 = sub( shr( input_frame, 1 ), Loverlapp );
FOR( i = 0; i < tmp16; i++ )
{
/* wtda_audio[i+input_frame/2] = - audio[n-i-1]; */
- *pt_32++ = L_negate( L_shr( L_deposit_h( *pt_16-- ), 1 ) ); /* Q +16 -1 */
+ *pt_32++ = L_negate( L_shr( L_deposit_h( *pt_16-- ), 1 ) ); /*q_audio+15*/
}
- pt_cos = pt_cos + Loverlapp - 1;
+ pt_cos = pt_cos + Loverlapp - 1; /*Q15*/
FOR( i = tmp16; i < shr( input_frame, 1 ); i++ )
{
/* *pt_32++ = - audio[n-i-1] *(float)cos((i+1-input_frame/2+Loverlapp)*EVS_PI/(2*(Loverlapp+1))); win=cos() */
- *pt_32++ = L_negate( L_mult0( *pt_16--, *pt_cos-- ) );
+ *pt_32++ = L_negate( L_mult0( *pt_16--, *pt_cos-- ) ); /*q_audio+15*/
}
IF( hTcxEnc != NULL )
diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c
index 5a4eeb528251ece46f6ee4f514eb3be63e1b076d..8a1c8c483903fcce7a46e09de2ab947077822b88 100644
--- a/lib_enc/corr_xh_fx.c
+++ b/lib_enc/corr_xh_fx.c
@@ -24,9 +24,9 @@
* y[i]=sum(j=i,l-1) x[j]*h[j-i], i=0,l-1
*-------------------------------------------------------------------*/
void corr_xh_fx(
- const Word16 x[], /* i : target signal */
- Word16 dn[], /* o : correlation between x[] and h[] */
- const Word16 h[] /* i : impulse response (of weighted synthesis filter) */
+ const Word16 x[], /* i : target signal Qx*/
+ Word16 dn[], /* o : correlation between x[] and h[] Qdn = Qx+j-1*/
+ const Word16 h[] /* i : impulse response (of weighted synthesis filter) Q14*/
)
{
Word16 i, j, k;
@@ -44,20 +44,20 @@ void corr_xh_fx(
L_maxloc = L_deposit_l( 0 );
FOR( i = k; i < L_SUBFR; i += STEP )
{
- L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] */
+ L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/
FOR( j = i; j < L_SUBFR - 1; j++ )
{
#ifdef BASOP_NOGLOB
- L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow );
+ L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/
#else
L_tmp = L_mac( L_tmp, x[j + 1], h[j + 1 - i] );
#endif
}
- y32[i] = L_tmp;
+ y32[i] = L_tmp; /*Qx+15*/
move32();
L_tmp = L_abs( L_tmp );
- L_maxloc = L_max( L_tmp, L_maxloc );
+ L_maxloc = L_max( L_tmp, L_maxloc ); /*Qx+15*/
}
/* tot += 3*max / 8 */
L_maxloc = L_shr( L_maxloc, 2 );
@@ -77,7 +77,7 @@ void corr_xh_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
- dn[i] = round_fx( L_shl( y32[i], j ) );
+ dn[i] = round_fx( L_shl( y32[i], j ) ); /*Qx+15+j-16*/
}
return;
}
@@ -86,7 +86,7 @@ void corr_hh_ivas_fx(
const Word16 *h, /* i : target signal e(norm_s(h1[0])+1) */
Word16 *y, /* o : correlation between x[] and h[] Q_new + 1 */
Word16 *Qy,
- const Word16 L_subfr /* i : length of the subframe */
+ const Word16 L_subfr /* i : length of the subframe Q0*/
)
{
Word16 i, j, k;
@@ -114,10 +114,10 @@ void corr_hh_ivas_fx(
#endif
}
- y32[i] = L_tmp;
+ y32[i] = L_tmp; // 2*(15 - norm_s(h[0]) -3) - 1
move32();
L_tmp = L_abs( L_tmp );
- L_maxloc = L_max( L_tmp, L_maxloc );
+ L_maxloc = L_max( L_tmp, L_maxloc ); // 2*(15 - norm_s(h[0]) -3) - 1
}
/* tot += 3*max / 8 */
L_maxloc = L_shr( L_maxloc, 2 );
@@ -147,12 +147,12 @@ void corr_hh_ivas_fx(
}
void corr_xh_ivas_fx(
- const Word16 x[], /* i : target signal */
+ const Word16 x[], /* i : target signal Qx*/
const Word16 Qx,
- Word16 dn[], /* o : correlation between x[] and h[] */
+ Word16 dn[], /* o : correlation between x[] and h[] Qdn*/
Word16 *Qdn,
- const Word16 h[], /* i : impulse response (of weighted synthesis filter) */
- const Word16 L_subfr /* i : length of the subframe */
+ const Word16 h[], /* i : impulse response (of weighted synthesis filter) (Q15 - norm_s(h[0]))*/
+ const Word16 L_subfr /* i : length of the subframe Q0*/
)
{
Word16 i, j, k;
@@ -180,10 +180,10 @@ void corr_xh_ivas_fx(
#endif
}
- y32[i] = L_tmp;
+ y32[i] = L_tmp; // Qx+(15 - norm_s(h[0]))
move32();
L_tmp = L_abs( L_tmp );
- L_maxloc = L_max( L_tmp, L_maxloc );
+ L_maxloc = L_max( L_tmp, L_maxloc ); // Qx+(15 - norm_s(h[0]))
}
/* tot += 3*max / 8 */
L_maxloc = L_shr( L_maxloc, 2 );
diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c
index b2b464988df33c1dd42eb6a634cede07ad7669be..2ebb7289a2196a79839f2a2021cec8d13b32f608 100644
--- a/lib_enc/decision_matrix_enc_fx.c
+++ b/lib_enc/decision_matrix_enc_fx.c
@@ -82,7 +82,7 @@
void decision_matrix_enc_fx(
Encoder_State *st_fx, /* i : encoder state structure */
- Word16 *hq_core_type /* o : HQ core type */
+ Word16 *hq_core_type /* o : HQ core type Q0*/
)
{
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
@@ -107,7 +107,7 @@ void decision_matrix_enc_fx(
move16();
test();
- if ( GE_32( st_fx->input_Fs, 32000 ) && GE_16( st_fx->bwidth, SWB ) )
+ IF( GE_32( st_fx->input_Fs, 32000 ) && GE_16( st_fx->bwidth, SWB ) )
{
st_fx->extl = SWB_CNG;
move16();
@@ -155,7 +155,7 @@ void decision_matrix_enc_fx(
test();
test();
IF( EQ_16( st_fx->coder_type, UNVOICED ) && EQ_16( st_fx->vad_flag, 1 ) &&
- ( ( GE_16( st_fx->last_bwidth, SWB ) && st_fx->last_Opt_SC_VBR == 1 ) || LT_16( st_fx->last_bwidth, SWB ) ) &&
+ ( ( GE_16( st_fx->last_bwidth, SWB ) && EQ_16( st_fx->last_Opt_SC_VBR, 1 ) ) || LT_16( st_fx->last_bwidth, SWB ) ) &&
( NE_16( st_fx->last_core, HQ_CORE ) || NE_16( st_fx->bwidth, NB ) ) )
{
/* NELP mode */
@@ -195,7 +195,7 @@ void decision_matrix_enc_fx(
}
#else
test();
- if ( GE_32( st_fx->total_brate, HQCORE_NB_MIN_RATE ) && EQ_16( st_fx->sp_aud_decision1, 1 ) )
+ IF( GE_32( st_fx->total_brate, HQCORE_NB_MIN_RATE ) && EQ_16( st_fx->sp_aud_decision1, 1 ) )
{
st_fx->core = HQ_CORE;
move16();
@@ -395,9 +395,9 @@ void decision_matrix_enc_fx(
* write MODE1 TCX20 signalling information into the bitstream
*---------------------------------------------------------------------*/
-Word16 signalling_mode1_tcx20_enc(
+Word16 signalling_mode1_tcx20_enc_fx(
Encoder_State *st, /* i : encoder state structure */
- Word16 push )
+ Word16 push /*Q0*/ )
{
Word16 num_bits;
Word16 nBits, idx, start_idx;
@@ -422,7 +422,7 @@ Word16 signalling_mode1_tcx20_enc(
/* retrieve the number of bits for signalling */
idx = add( idx, 1 );
- nBits = extract_l( acelp_sig_tbl[idx] );
+ nBits = extract_l( acelp_sig_tbl[idx] ); /*Q0*/
/* retrieve the signalling index */
idx = add( idx, 1 );
@@ -519,7 +519,7 @@ void signalling_enc_fx(
/* write ACELP->HQ core switching flag */
test();
- IF( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) )
+ IF( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) )
{
push_indice_fx( hBstr, IND_HQ_SWITCHING_FLG, 1, 1 );
@@ -540,7 +540,7 @@ void signalling_enc_fx(
return;
}
- IF( EQ_16( st_fx->core, ACELP_CORE ) )
+ IF( ( st_fx->core == ACELP_CORE ) )
{
Word16 ppp_mode, nelp_mode, sig;
@@ -588,7 +588,7 @@ void signalling_enc_fx(
push_indice_fx( hBstr, IND_PPP_NELP_MODE, 3, 2 );
}
}
- ELSE IF( NE_32( st_fx->core_brate, SID_2k40 ) && NE_32( st_fx->core_brate, FRAME_NO_DATA ) )
+ ELSE IF( NE_32( st_fx->core_brate, SID_2k40 ) && ( st_fx->core_brate != FRAME_NO_DATA ) )
{
/* write the ACELP/HQ core selection bit */
IF( GE_32( st_fx->total_brate, ACELP_24k40 ) )
@@ -607,7 +607,7 @@ void signalling_enc_fx(
}
idx++;
}
- total_brate_temp = brate_tbl[idx];
+ total_brate_temp = brate_tbl[idx]; /*Q0*/
move32();
idx = 0;
@@ -618,7 +618,7 @@ void signalling_enc_fx(
}
/* retrieve the number of bits for signalling */
- nBits = (Word16) acelp_sig_tbl[++idx];
+ nBits = (Word16) acelp_sig_tbl[++idx]; /*Q0*/
move16();
/* retrieve the signalling index */
@@ -627,11 +627,11 @@ void signalling_enc_fx(
IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->bwidth, SWB ) && LE_32( st_fx->total_brate, ACELP_9k60 ) )
{
/* patch to signal SWB as NB in Stereo */
- sig = (Word16) SIG2IND( st_fx->coder_type, NB, st_fx->sharpFlag, st_fx->rf_mode );
+ sig = (Word16) SIG2IND( st_fx->coder_type, NB, st_fx->sharpFlag, st_fx->rf_mode ); /*Q0*/
}
ELSE
{
- sig = (Word16) SIG2IND( st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, st_fx->rf_mode );
+ sig = (Word16) SIG2IND( st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, st_fx->rf_mode ); /*Q0*/
}
WHILE( NE_16( (Word16) acelp_sig_tbl[idx], sig ) )
@@ -663,7 +663,7 @@ void signalling_enc_fx(
{
/* write ACELP->HQ switching frame flag */
test();
- IF( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) )
+ IF( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) )
{
push_indice_fx( hBstr, IND_HQ_SWITCHING_FLG, 1, 1 );
/* write ACELP L_frame info */
@@ -695,12 +695,12 @@ void signalling_enc_fx(
}
/* retrieve the number of bits for signalling */
- nBits = extract_l( acelp_sig_tbl[++idx] );
+ nBits = extract_l( acelp_sig_tbl[++idx] ); /*Q0*/
/* retrieve the signalling index */
start_idx = ++idx;
move16();
- k = SIG2IND_fx( LR_MDCT, st_fx->bwidth, 0, 0 );
+ k = SIG2IND_fx( LR_MDCT, st_fx->bwidth, 0, 0 ); /*Q0*/
WHILE( NE_32( acelp_sig_tbl[idx], k ) )
{
idx++;
@@ -757,7 +757,7 @@ void signaling_enc_rf_fx(
IF( EQ_16( st->rf_mode, 1 ) )
{
enc_prm_rf_ivas_fx( st, hRF->rf_indx_frametype[st->rf_fec_offset], st->rf_fec_offset );
- hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind;
+ hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind; /*Q0*/
move16();
}
@@ -819,7 +819,7 @@ void signaling_enc_rf_fx(
return;
}
-void signalling_enc_rf(
+void signalling_enc_rf_fx(
Encoder_State *st /* i : encoder state structure */
)
{
@@ -831,7 +831,7 @@ void signalling_enc_rf(
IF( EQ_16( st->rf_mode, 1 ) )
{
enc_prm_rf_fx( st, hRF->rf_indx_frametype[st->rf_fec_offset], st->rf_fec_offset );
- hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind;
+ hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind; /*Q0*/
}
/* Shift the RF indices such that the partial copy associated with
diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c
index e21579cd0acce22f264bab94c352c0bb40480af5..c4dbc6fe71357024ffcb49b4659f0b10cee8c14c 100644
--- a/lib_enc/detect_transient_fx.c
+++ b/lib_enc/detect_transient_fx.c
@@ -58,24 +58,25 @@ static void hp_filter_fx(
Word16 *y, /*Q_new */
Word16 *oldy, /*Q_new */
Word16 *oldx, /*Q_new */
- const Word16 L )
+ const Word16 L /*Q0*/ )
{
Word16 i;
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*y[0] = 0.4931f * *oldy + 0.7466f*(x[0] - *oldx); */
#ifdef BASOP_NOGLOB
- L_tmp = L_mult( sub_o( x[0], *oldx, &Overflow ), 24465 ); /*Q_new+16 */
-#else /* BASOP_NOGLOB */
+ L_tmp = L_mult( sub_o( x[0], *oldx, &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */
+#else /* BASOP_NOGLOB */
L_tmp = L_mult( sub( x[0], *oldx ), 24465 ); /*Q_new+16 */
-#endif /* BASOP_NOGLOB */
+#endif /* BASOP_NOGLOB */
#ifdef BASOP_NOGLOB
- L_tmp = L_mac_sat( L_tmp, *oldy, 16158 ); /*Q_new+16 */
- y[0] = round_fx_sat( L_tmp ); /*Q_new */
+ L_tmp = L_mac_sat( L_tmp, *oldy, 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */
+ y[0] = round_fx_sat( L_tmp ); /*Q_new */
#else
L_tmp = L_mac( L_tmp, *oldy, 16158 ); /*Q_new+16 */
y[0] = round_fx( L_tmp ); /*Q_new */
@@ -84,14 +85,14 @@ static void hp_filter_fx(
{
/*y[i] = 0.4931f*y[i-1] + 0.7466f*(x[i] - x[i-1]); */
#ifdef BASOP_NOGLOB
- L_tmp = L_mult( sub_o( x[i], x[i - 1], &Overflow ), 24465 ); /*Q_new+16 */
- L_tmp = L_mac_o( L_tmp, y[i - 1], 16158, &Overflow ); /*Q_new+16 */
- y[i] = round_fx_o( L_tmp, &Overflow ); /*Q_new */
-#else /* BASOP_NOGLOB */
+ L_tmp = L_mult( sub_o( x[i], x[i - 1], &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */
+ L_tmp = L_mac_o( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/, &Overflow ); /*Q_new+16 */
+ y[i] = round_fx_o( L_tmp, &Overflow ); /*Q_new */
+#else /* BASOP_NOGLOB */
L_tmp = L_mult( sub( x[i], x[i - 1] ), 24465 ); /*Q_new+16 */
L_tmp = L_mac( L_tmp, y[i - 1], 16158 ); /*Q_new+16 */
y[i] = round_fx( L_tmp ); /*Q_new */
-#endif /* BASOP_NOGLOB */
+#endif /* BASOP_NOGLOB */
}
*oldx = x[L - 1];
@@ -114,7 +115,7 @@ static void hp_filter_fx(
Word16 detect_transient_fx(
const Word16 *in_fx, /*Q_new */
- const Word16 L,
+ const Word16 L, /*Q0*/
Word16 Q_new,
Encoder_State *st_fx )
{
@@ -133,6 +134,7 @@ Word16 detect_transient_fx(
Word16 exp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
shift = 0;
@@ -177,7 +179,7 @@ Word16 detect_transient_fx(
}
IF( EQ_16( L, L_FRAME8k ) )
{
- Energy_in_fx[0] = st_fx->Energy_Old_fx;
+ Energy_in_fx[0] = st_fx->Energy_Old_fx; /*Q0*/
move32();
/* Compute block energy */
FOR( blk = 0; blk < 4; blk++ )
@@ -192,9 +194,9 @@ Word16 detect_transient_fx(
#else
Energy_fx = L_add( Energy_fx, L_mult0( temp16, temp16 ) );
#endif
- temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new );
+ temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); /*Q0*/
#ifdef BASOP_NOGLOB
- Energy_in_fx[blk + 1] = L_add_o( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ), &Overflow );
+ Energy_in_fx[blk + 1] = L_add_o( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ), &Overflow ); /*Q0*/
#else
Energy_in_fx[blk + 1] = L_add( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ) );
#endif
@@ -202,14 +204,14 @@ Word16 detect_transient_fx(
}
#ifdef BASOP_NOGLOB
- E_in_fx = L_add_o( E_in_fx, Energy_in_fx[blk + 1], &Overflow );
- E_out_fx = L_add_o( E_out_fx, Energy_fx, &Overflow );
+ E_in_fx = L_add_o( E_in_fx, Energy_in_fx[blk + 1], &Overflow ); /*Q0*/
+ E_out_fx = L_add_o( E_out_fx, Energy_fx, &Overflow ); /*Q0*/
#else
E_in_fx = L_add( E_in_fx, Energy_in_fx[blk + 1] );
E_out_fx = L_add( E_out_fx, Energy_fx );
#endif
- Thres_fx = 2185; /*1 /15 */
+ Thres_fx = 2185; /*1 /15 Q15*/
move16();
IF( GT_32( Mult_32_16( Energy_fx, 5461 ), EnergyLT ) )
{
@@ -219,7 +221,7 @@ Word16 detect_transient_fx(
move16();
}
- EnergyLT = L_add( Mult_32_16( EnergyLT, 24576 ), Mult_32_16( Energy_fx, 8192 ) );
+ EnergyLT = L_add( Mult_32_16( EnergyLT, 24576 /*Q15*/ ), Mult_32_16( Energy_fx, 8192 /*Q15*/ ) ); /*2Q_new*/
}
}
ELSE
@@ -249,8 +251,8 @@ Word16 detect_transient_fx(
}
Overflow = 0;
move16();
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- Energy = L_add_o( L_tmp, L_tmp2, &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ Energy = L_add_o( L_tmp, L_tmp2, &Overflow ); /*2Q_new */
#else
Energy = L_add( L_tmp, L_tmp2 );
#endif
@@ -263,8 +265,8 @@ Word16 detect_transient_fx(
Overflow = 0;
move16();
-#ifdef BASOP_NOGLOB /* shift is >= 0, not overflow possible for shr */
- Energy = L_add_o( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ), &Overflow );
+#ifdef BASOP_NOGLOB /* shift is >= 0, not overflow possible for shr */
+ Energy = L_add_o( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ), &Overflow ); /*2Q_new - shift*/
#else
Energy = L_add( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ) );
#endif
@@ -309,8 +311,8 @@ Word16 detect_transient_fx(
/*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */
/*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */
#ifdef BASOP_NOGLOB
- EnergyLT = L_add_o( Mult_32_16( EnergyLT, 24576 ), Mult_32_16( Energy, shl( 8192, shift ) ), &Overflow ); /*2Q_new */
-#else /* BASOP_NOGLOB */
+ EnergyLT = L_add_o( Mult_32_16( EnergyLT, 24576 /*0.75f in Q15*/ ), Mult_32_16( Energy, shl( 8192 /*0.25 in Q15*/, shift ) ), &Overflow ); /*2Q_new */
+#else /* BASOP_NOGLOB */
EnergyLT = L_add( Mult_32_16( EnergyLT, 24576 ), Mult_32_16( Energy, shl( 8192, shift ) ) ); /*2Q_new */
#endif
}
@@ -341,7 +343,7 @@ Word16 detect_transient_fx(
/*blk++; */
blk = add( blk, 1 );
#ifdef BASOP_NOGLOB
- E_low_fx = L_add_sat( E_low_fx, Energy_in_fx[i] );
+ E_low_fx = L_add_sat( E_low_fx, Energy_in_fx[i] ); /*Q0*/
#else
E_low_fx = L_add( E_low_fx, Energy_in_fx[i] );
#endif
@@ -361,7 +363,7 @@ Word16 detect_transient_fx(
/*blk++; */
blk = add( blk, 1 );
#ifdef BASOP_NOGLOB
- E_high_fx = L_add_sat( E_high_fx, Energy_in_fx[i] );
+ E_high_fx = L_add_sat( E_high_fx, Energy_in_fx[i] ); /*Q0*/
#else
E_high_fx = L_add( E_high_fx, Energy_in_fx[i] );
#endif
@@ -375,7 +377,7 @@ Word16 detect_transient_fx(
test();
test();
- IF( LT_32( L_shr( E_high_fx, 1 ), E_low_fx ) && GT_32( E_high_fx, Mult_32_16( E_low_fx, 22938 ) ) && GT_32( Mult_32_16( E_in_fx, Thres_fx ), E_out_fx ) )
+ IF( LT_32( L_shr( E_high_fx, 1 ), E_low_fx ) && GT_32( E_high_fx, Mult_32_16( E_low_fx, 22938 /*0.7 in Q15*/ ) ) && GT_32( Mult_32_16( E_in_fx, Thres_fx ), E_out_fx ) )
{
IsTransient = 0;
move16();
@@ -395,7 +397,7 @@ Word16 detect_transient_fx(
{
IF( IsTransient )
{
- IF( EQ_16( position, 3 ) )
+ if ( EQ_16( position, 3 ) )
{
/* Set Hangover */
st_fx->TransientHangOver = 1;
@@ -433,9 +435,9 @@ Word16 detect_transient_fx(
}
}
- IF( EQ_16( L, L_FRAME8k ) )
+ if ( EQ_16( L, L_FRAME8k ) )
{
- st_fx->Energy_Old_fx = Energy_in_fx[4];
+ st_fx->Energy_Old_fx = Energy_in_fx[4]; /*Q0*/
move32();
}
diff --git a/lib_enc/diffcod_fx.c b/lib_enc/diffcod_fx.c
index 7ff48d81667335768cc737aa75033fd6b998d258..51a31fa8ae82ba811147417ac2efaec44079eaa6 100644
--- a/lib_enc/diffcod_fx.c
+++ b/lib_enc/diffcod_fx.c
@@ -17,9 +17,9 @@
/*--------------------------------------------------------------------------*/
void diffcod_fx(
- const Word16 N, /* i : number of sub-vectors */
- Word16 *y, /* i/o: indices of quantized norms */
- Word16 *difidx /* o : differential code */
+ const Word16 N, /* i : number of sub-vectors Q0*/
+ Word16 *y, /* i/o: indices of quantized norms Q0*/
+ Word16 *difidx /* o : differential code Q0*/
)
{
Word16 i, k, r;
@@ -27,7 +27,9 @@ void diffcod_fx(
FOR( i = N - 1; i > 0; i-- )
{
r = sub( i, 1 );
+ move16();
k = sub( y[i], y[r] );
+ move16();
if ( LT_16( k, -15 ) )
{
y[r] = add( y[i], 15 );
@@ -38,7 +40,9 @@ void diffcod_fx(
FOR( i = 1; i < N; i++ )
{
r = sub( i, 1 );
+ move16();
k = sub( y[i], y[r] );
+ move16();
IF( GT_16( k, 16 ) )
{
k = 16;
@@ -61,11 +65,11 @@ void diffcod_fx(
*--------------------------------------------------------------------------*/
void diffcod_lrmdct_fx(
- const Word16 N, /* i : number of sub-vectors */
- const Word16 be_ref, /* i : band energy reference */
- Word16 *y, /* i/o: indices of quantized norms */
- Word16 *difidx, /* o : differential code */
- const Word16 is_transient /* i : transient flag */
+ const Word16 N, /* i : number of sub-vectors Q0*/
+ const Word16 be_ref, /* i : band energy reference Q0*/
+ Word16 *y, /* i/o: indices of quantized norms Q0*/
+ Word16 *difidx, /* o : differential code Q0*/
+ const Word16 is_transient /* i : transient flag Q0*/
)
{
Word16 i, m, r;
@@ -106,9 +110,11 @@ void diffcod_lrmdct_fx(
}
m = sub( N, 1 );
+ move16();
FOR( i = m; i > 0; i-- )
{
r = sub( i, 1 );
+ move16();
k = sub( y[i], y[r] );
move16();
if ( LT_16( k, thr_l ) )
@@ -121,7 +127,9 @@ void diffcod_lrmdct_fx(
FOR( i = 1; i < N; i++ )
{
r = sub( i, 1 );
+ move16();
k = sub( y[i], y[r] );
+ move16();
IF( GT_16( k, thr_h ) )
{
k = thr_h;
diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c
index a052a11969b3cf803b55ccdaac7d4377e5c499dd..a8978c49717a631fe207a39ac9cbf7eab95126b6 100644
--- a/lib_enc/dtx_fx.c
+++ b/lib_enc/dtx_fx.c
@@ -41,7 +41,7 @@
* Local function prototypes
*-------------------------------------------------------------------*/
-static void update_SID_cnt( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, const Word16 Opt_AMR_WB );
+static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, const Word16 Opt_AMR_WB );
/*==================================================================================*/
/* FUNCTION : dtx_ivas_fx() */
/*----------------------------------------------------------------------------------*/
@@ -65,9 +65,9 @@ static void update_SID_cnt( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, con
/*==================================================================================*/
void dtx_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word32 ivas_total_brate, /* i : IVAS total bitrate */
- const Word16 vad, /* i : vad flag for DTX */
- const Word16 speech[], /* i : Pointer to the speech frame */
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/
+ const Word16 vad, /* i : vad flag for DTX Q0*/
+ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/
Word16 Q_speech /* i : Q factor for speech */
)
{
@@ -262,7 +262,7 @@ void dtx_ivas_fx(
test();
test();
- if ( ( st_fx->core_brate == FRAME_NO_DATA ) && ( st_fx->last_core != ACELP_CORE ) && !st_fx->Opt_AMR_WB )
+ IF( ( st_fx->core_brate == FRAME_NO_DATA ) && ( st_fx->last_core != ACELP_CORE ) && !st_fx->Opt_AMR_WB )
{
/* force SID frame when switching from HQ core or AMR-WB IO mode into inactive frame in ACELP core when DTX is on */
st_fx->core_brate = SID_2k40;
@@ -281,7 +281,7 @@ void dtx_ivas_fx(
test();
test();
test();
- if ( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) || EQ_32( st_fx->total_brate, ACELP_48k ) || EQ_32( st_fx->total_brate, HQ_96k ) || EQ_32( st_fx->total_brate, HQ_128k ) ) )
+ IF( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) || EQ_32( st_fx->total_brate, ACELP_48k ) || EQ_32( st_fx->total_brate, HQ_96k ) || EQ_32( st_fx->total_brate, HQ_128k ) ) )
{
st_fx->codec_mode = MODE2;
move16();
@@ -298,7 +298,7 @@ void dtx_ivas_fx(
test();
test();
test();
- if ( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) ) )
+ IF( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) ) )
{
st_fx->codec_mode = MODE2;
move16();
@@ -448,15 +448,15 @@ void dtx_ivas_fx(
Q_speech2 = add( shl( Q_speech, 1 ), 7 );
FOR( j = 0; j < 16; j++ )
{
- L_tmp = L_mult0( *speech, *speech );
+ L_tmp = L_mult0( *speech, *speech ); /*2*Q_speech*/
speech++;
FOR( i = 1; i < L_FRAME / 16; i++ )
{
#ifdef BASOP_NOGLOB
- L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow );
-#else /* BASOP_NOGLOB */
+ L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/
+#else /* BASOP_NOGLOB */
L_tmp = L_mac0( L_tmp, *speech, *speech );
-#endif /* BASOP_NOGLOB */
+#endif /* BASOP_NOGLOB */
speech++;
}
hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /* Q(-7) */
@@ -467,17 +467,17 @@ void dtx_ivas_fx(
IF( EQ_16( st_fx->clas, VOICED_CLAS ) )
{
- alpha = ALPHA_ENER_SLOW_FX;
+ alpha = ALPHA_ENER_SLOW_FX; /*Q15 */
move16();
if ( GT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_voiced_fx ) )
{
- alpha = ALPHA_ENER_FAST_FX;
- move16(); /*Q15 */
+ alpha = ALPHA_ENER_FAST_FX; /*Q15 */
+ move16();
}
/*st_fx->lt_ener_voiced_fx = alpha * st_fx->lt_ener_voiced_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/
- L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx );
- L_tmp = Mult_32_16( L_tmp, alpha );
+ L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
+ L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/
hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /* Q(-7) */
move32();
@@ -490,17 +490,17 @@ void dtx_ivas_fx(
/* Background noise */
ELSE IF( !st_fx->Opt_AMR_WB )
{
- alpha = ALPHA_ENER_SLOW_FX;
+ alpha = ALPHA_ENER_SLOW_FX; /*Q15*/
move16();
if ( LT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_noise_fx ) )
{
- alpha = ALPHA_ENER_FAST_FX;
+ alpha = ALPHA_ENER_FAST_FX; /*Q15*/
move16();
}
/*st_fx->lt_ener_noise_fx = alpha * st_fx->lt_ener_noise_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/
- L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx );
- L_tmp = Mult_32_16( L_tmp, alpha );
+ L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); /* Q(-7) */
+ L_tmp = Mult_32_16( L_tmp, alpha ); /* Q(-7) */
hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /* Q(-7) */
move32();
@@ -514,7 +514,7 @@ void dtx_ivas_fx(
}
/* Update of the SID counter */
- update_SID_cnt( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB );
+ update_SID_cnt_fx( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB );
/* Update encoded bandwidth */
test();
@@ -525,7 +525,7 @@ void dtx_ivas_fx(
st_fx->bwidth = st_fx->last_bwidth;
move16();
test();
- if ( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) )
+ IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) )
{
st_fx->bwidth = st_fx->last_bwidth_cng;
move16();
@@ -614,8 +614,8 @@ void dtx_ivas_fx(
/*==================================================================================*/
void dtx_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 vad, /* i : vad flag for DTX */
- const Word16 speech[], /* i : Pointer to the speech frame */
+ const Word16 vad, /* i : vad flag for DTX Q0*/
+ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/
Word16 Q_speech /* i : Q factor for speech */
)
@@ -628,6 +628,7 @@ void dtx_fx(
Word16 last_br_cng_flag, last_br_flag, br_dtx_flag;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
#ifdef IVAS_CODE
@@ -661,7 +662,7 @@ void dtx_fx(
st_fx->cng_type = FD_CNG;
move16();
test();
- if ( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && EQ_16( st_fx->element_mode, IVAS_SCE ) && EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && EQ_16( st_fx->element_mode, IVAS_SCE ) && EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
st_fx->cng_type = LP_CNG;
move16();
@@ -684,7 +685,7 @@ void dtx_fx(
st_fx->total_brate = st_fx->last_total_brate_cng;
move32();
test();
- if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
+ IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
{
st_fx->Opt_SC_VBR = 0;
move16();
@@ -704,7 +705,7 @@ void dtx_fx(
st_fx->total_brate = st_fx->last_total_brate;
move32();
test();
- if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
+ IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
{
st_fx->Opt_SC_VBR = 0;
move16();
@@ -715,7 +716,7 @@ void dtx_fx(
test();
test();
test();
- if ( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32( st_fx->total_brate, ACELP_13k20 ) && NE_16( st_fx->bwidth, NB ) )
+ IF( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32( st_fx->total_brate, ACELP_13k20 ) && NE_16( st_fx->bwidth, NB ) )
{
st_fx->Opt_RF_ON = 1;
move16();
@@ -724,7 +725,7 @@ void dtx_fx(
move16();
st_fx->bwidth = st_fx->last_bwidth;
move32();
- IF( GT_16( st_fx->element_mode, EVS_MONO ) )
+ IF( ( st_fx->element_mode > EVS_MONO ) )
{
st_fx->codec_mode = MODE1;
move16();
@@ -763,6 +764,7 @@ void dtx_fx(
{
st_fx->last_total_brate_cng = -1;
st_fx->last_rf_mode_cng = st_fx->rf_mode;
+ move32();
move16();
}
ELSE
@@ -770,6 +772,9 @@ void dtx_fx(
st_fx->last_total_brate_cng = st_fx->total_brate;
st_fx->last_bwidth_cng = st_fx->bwidth;
st_fx->last_codec_mode_cng = st_fx->codec_mode;
+ move32();
+ move16();
+ move16();
}
IF( hDtxEnc->cnt_SID == 0 )
@@ -795,7 +800,7 @@ void dtx_fx(
test();
test();
- IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) && NE_16( st_fx->last_core, ACELP_CORE ) && !st_fx->Opt_AMR_WB )
+ IF( ( st_fx->core_brate == FRAME_NO_DATA ) && ( st_fx->last_core != ACELP_CORE ) && !st_fx->Opt_AMR_WB )
{
/* force SID frame when switching from HQ core or AMR-WB IO mode into inactive frame in ACELP core when DTX is on */
st_fx->core_brate = SID_2k40;
@@ -820,7 +825,7 @@ void dtx_fx(
test();
test();
test();
- IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, ACELP_24k40 ) || ( NE_16( st_fx->element_mode, EVS_MONO ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */
+ IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, ACELP_24k40 ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */
{
test();
test();
@@ -863,7 +868,7 @@ void dtx_fx(
/* NB core bit rate can be "-1" at startup , so one can not use core_brate_fx <=2400 */
test();
test();
- IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( NE_32( st_fx->core_brate, FRAME_NO_DATA ) ) )
+ IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( st_fx->core_brate != FRAME_NO_DATA ) )
{
IF( hDtxEnc != NULL )
{
@@ -968,15 +973,15 @@ void dtx_fx(
Q_speech2 = add( shl( Q_speech, 1 ), 7 );
FOR( j = 0; j < 16; j++ )
{
- L_tmp = L_mult0( *speech, *speech );
+ L_tmp = L_mult0( *speech, *speech ); /*2*Q_speech*/
speech++;
FOR( i = 1; i < L_FRAME / 16; i++ )
{
#ifdef BASOP_NOGLOB
- L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow );
-#else /* BASOP_NOGLOB */
+ L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/
+#else /* BASOP_NOGLOB */
L_tmp = L_mac0( L_tmp, *speech, *speech );
-#endif /* BASOP_NOGLOB */
+#endif /* BASOP_NOGLOB */
speech++;
}
hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /*Q(-7) */
@@ -990,14 +995,14 @@ void dtx_fx(
move16();
if ( GT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_voiced_fx ) )
{
- alpha = ALPHA_ENER_FAST_FX;
- move16(); /*Q15 */
+ alpha = ALPHA_ENER_FAST_FX; /*Q15 */
+ move16();
}
/*st_fx->lt_ener_voiced_fx = alpha * st_fx->lt_ener_voiced_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/
- L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx );
- L_tmp = Mult_32_16( L_tmp, alpha );
- hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7) */
+ L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
+ L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/
+ hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
hDtxEnc->VarDTX_cnt_voiced = add( hDtxEnc->VarDTX_cnt_voiced, 1 );
@@ -1006,19 +1011,19 @@ void dtx_fx(
/* Background noise */
ELSE IF( !st_fx->Opt_AMR_WB )
{
- alpha = ALPHA_ENER_SLOW_FX;
+ alpha = ALPHA_ENER_SLOW_FX; /*Q15 */
move16();
if ( LT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_noise_fx ) )
{
- alpha = ALPHA_ENER_FAST_FX;
+ alpha = ALPHA_ENER_FAST_FX; /*Q15 */
move16();
}
/*st_fx->lt_ener_noise_fx = alpha * st_fx->lt_ener_noise_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/
- L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx );
- L_tmp = Mult_32_16( L_tmp, alpha );
- hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx );
- move32(); /*Q(-7) */
+ L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
+ L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/
+ hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
+ move32();
hDtxEnc->VarDTX_cnt_noise = add( hDtxEnc->VarDTX_cnt_noise, 1 );
@@ -1028,7 +1033,7 @@ void dtx_fx(
}
/* Update of the SID counter */
- update_SID_cnt( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB );
+ update_SID_cnt_fx( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB );
/* Update encoded bandwidth */
test();
@@ -1039,7 +1044,7 @@ void dtx_fx(
st_fx->bwidth = st_fx->last_bwidth;
move16();
test();
- if ( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) )
+ IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) )
{
st_fx->bwidth = st_fx->last_bwidth_cng;
move16();
@@ -1067,6 +1072,7 @@ void dtx_fx(
st_fx->Opt_RF_ON = 0;
move16();
st_fx->rf_mode = 0;
+ move16();
}
/* Set and limit the encoded bandwidth */
@@ -1109,10 +1115,10 @@ void dtx_fx(
* Update of the SID counter
*---------------------------------------------------------------------*/
-static void update_SID_cnt(
+static void update_SID_cnt_fx(
DTX_ENC_HANDLE hDtxEnc, /* i/o: common DTX handle */
- const Word32 core_brate, /* i : core coder core bitrate */
- const Word16 Opt_AMR_WB /* i : AMR BW IO mode? */
+ const Word32 core_brate, /* i : core coder core bitrate Q0*/
+ const Word16 Opt_AMR_WB /* i : AMR BW IO mode? Q0*/
)
{
Word16 EstimatedSNR, delta, frac, exp;
@@ -1133,12 +1139,12 @@ static void update_SID_cnt(
exp = norm_l( L_tmp1 );
frac = Log2_norm_lc( L_shl( L_tmp1, exp ) );
exp = sub( 30, exp );
- L_tmp1 = L_Comp( exp, frac );
+ L_tmp1 = L_Comp( exp, frac ); /*Q16*/
L_tmp2 = L_max( hDtxEnc->lt_ener_noise_fx, 1 );
exp = norm_l( L_tmp2 );
frac = Log2_norm_lc( L_shl( L_tmp2, exp ) );
exp = sub( 30, exp );
- L_tmp1 = L_sub( L_tmp1, L_Comp( exp, frac ) );
+ L_tmp1 = L_sub( L_tmp1, L_Comp( exp, frac ) ); /*Q16*/
/* 10 x Log10(a/b) = 10 x Log10(2) x [Log2(a) - Log2(b)] */
/* 10 x Log10(2) = ~3.0103 */
L_tmp1 = Mpy_32_16_1( L_tmp1, 24660 ); /* mult by 3.0103 / 4 in Q15 */
@@ -1162,7 +1168,7 @@ static void update_SID_cnt(
test();
- if ( Opt_AMR_WB == 0 || NE_16( hDtxEnc->max_SID, 3 ) )
+ IF( Opt_AMR_WB == 0 || NE_16( hDtxEnc->max_SID, 3 ) )
{
hDtxEnc->max_SID = hDtxEnc->interval_SID;
move16(); /* change SID update rate */
@@ -1175,12 +1181,12 @@ static void update_SID_cnt(
exp = norm_l( L_tmp1 );
frac = Log2_norm_lc( L_shl( L_tmp1, exp ) );
exp = sub( 30, exp );
- L_tmp1 = L_Comp( exp, frac );
+ L_tmp1 = L_Comp( exp, frac ); /*Q16*/
L_tmp2 = L_max( hDtxEnc->lt_ener_last_SID_fx, 1 );
exp = norm_l( L_tmp2 );
frac = Log2_norm_lc( L_shl( L_tmp2, exp ) );
exp = sub( 30, exp );
- L_tmp1 = L_sub( L_tmp1, L_Comp( exp, frac ) );
+ L_tmp1 = L_sub( L_tmp1, L_Comp( exp, frac ) ); /*Q16*/
/* 10 x Log10(a/b) = 10 x Log10(2) x [Log2(a) - Log2(b)] */
/* 10 x Log10(2) = ~3.0103 */
L_tmp1 = Mpy_32_16_1( L_tmp1, 24660 ); /* mult by 3.0103 / 4 in Q15 */
@@ -1188,10 +1194,10 @@ static void update_SID_cnt(
delta = round_fx( L_tmp1 ); /* now in Q8 */
test();
test();
- if ( LT_16( delta, LTE_VAR_FX ) && EQ_16( hDtxEnc->VarDTX_cnt_voiced, MIN_CNT ) && EQ_16( hDtxEnc->VarDTX_cnt_noise, MIN_CNT ) )
+ IF( LT_16( delta, LTE_VAR_FX ) && EQ_16( hDtxEnc->VarDTX_cnt_voiced, MIN_CNT ) && EQ_16( hDtxEnc->VarDTX_cnt_noise, MIN_CNT ) )
{
/* Send SID frame, and reset lt_ener_noise */
- hDtxEnc->lt_ener_noise_fx = hDtxEnc->frame_ener_fx;
+ hDtxEnc->lt_ener_noise_fx = hDtxEnc->frame_ener_fx; /* Q(-7) */
move32();
}
}
@@ -1209,7 +1215,7 @@ static void update_SID_cnt(
test();
test();
- if ( Opt_AMR_WB != 0 && EQ_16( hDtxEnc->max_SID, 3 ) && EQ_16( hDtxEnc->cnt_SID, 3 ) )
+ IF( Opt_AMR_WB != 0 && EQ_16( hDtxEnc->max_SID, 3 ) && EQ_16( hDtxEnc->cnt_SID, 3 ) )
{
/* set the size of CNG history buffer for averaging to DTX_HIST_SIZE frames */
/* be sure that DTX_HIST_SIZE >= INT_L */
@@ -1253,7 +1259,7 @@ static void update_SID_cnt(
void dtx_hangover_control_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 lsp_new_fx[M] /* i : current frame LSPs */
+ const Word16 lsp_new_fx[M] /* i : current frame LSPs Q15*/
)
{
Word16 ptr;
@@ -1288,7 +1294,7 @@ void dtx_hangover_control_fx(
exp = norm_l( hTdCngEnc->ho_ener_circ_fx[hTdCngEnc->ho_circ_ptr] );
fra = Log2_norm_lc( L_shl( hTdCngEnc->ho_ener_circ_fx[hTdCngEnc->ho_circ_ptr], exp ) );
exp = sub( sub( 30, exp ), 6 );
- L_tmp = L_Comp( exp, fra );
+ L_tmp = L_Comp( exp, fra ); /*Q16*/
enr_new = round_fx( L_shl( L_tmp, 8 ) ); /*Q8 */
if ( enr_new < 0 )
@@ -1298,17 +1304,17 @@ void dtx_hangover_control_fx(
}
/* get energies and lsps of hangover frames */
- ptr = sub( hTdCngEnc->ho_circ_ptr, sub( hTdCngEnc->burst_ho_cnt, 1 ) );
+ ptr = sub( hTdCngEnc->ho_circ_ptr, sub( hTdCngEnc->burst_ho_cnt, 1 ) ); /*Q0*/
IF( ptr < 0 )
{
- ptr = add( hTdCngEnc->ho_circ_size, ptr );
+ ptr = add( hTdCngEnc->ho_circ_size, ptr ); /*Q0*/
}
FOR( i = 0; i < hTdCngEnc->burst_ho_cnt - 1; i++ )
{
- Copy( &( hTdCngEnc->ho_lsp_circ_fx[ptr * M] ), &( tmp_lsp[i * M] ), M );
- tmp_enr[i] = hTdCngEnc->ho_ener_circ_fx[ptr];
- move32(); /*Q6 */
+ Copy( &( hTdCngEnc->ho_lsp_circ_fx[ptr * M] ), &( tmp_lsp[i * M] ), M ); /*Q15*/
+ tmp_enr[i] = hTdCngEnc->ho_ener_circ_fx[ptr]; /*Q6 */
+ move32();
ptr = add( ptr, 1 );
if ( EQ_16( ptr, hTdCngEnc->ho_circ_size ) )
@@ -1321,8 +1327,8 @@ void dtx_hangover_control_fx(
/* get estimated CNG energy and lsps assuming terminate hangover at current frame */
ptr = sub( hTdCngEnc->burst_ho_cnt, 2 );
enr_est = Mpy_32_16_1( tmp_enr[ptr], W_DTX_HO_FX[0] ); /*Q6 */
- weights = W_DTX_HO_FX[0];
- move16(); /*Q15 */
+ weights = W_DTX_HO_FX[0]; /*Q15 */
+ move16();
Copy( &( tmp_lsp[ptr * M] ), tmp, M );
m = 1;
move16();
@@ -1335,38 +1341,38 @@ void dtx_hangover_control_fx(
{
enr_est = L_add( enr_est, Mpy_32_16_1( tmp_enr[ptr - i], W_DTX_HO_FX[i] ) ); /*Q6 */
weights = add( weights, W_DTX_HO_FX[i] ); /*Q15 */
- Copy( &tmp_lsp[( ptr - i ) * M], &tmp[m * M], M );
+ Copy( &tmp_lsp[( ptr - i ) * M], &tmp[m * M], M ); /*Q15*/
m = add( m, 1 );
}
}
exp = norm_l( enr_est );
#ifdef BASOP_NOGLOB
- fra = round_fx_sat( L_shl_sat( enr_est, exp ) );
+ fra = round_fx_sat( L_shl_sat( enr_est, exp ) ); /*Q6+exp-16*/
#else
fra = round_fx( L_shl( enr_est, exp ) );
#endif
exp2 = norm_s( weights );
- fra2 = shl( weights, exp2 );
+ fra2 = shl( weights, exp2 ); /*Q15+exp2*/
exp = sub( sub( exp, 16 ), exp2 );
IF( GT_16( fra, fra2 ) )
{
fra = shr( fra, 1 );
exp = sub( exp, 1 );
}
- L_tmp = L_deposit_l( div_s( fra, fra2 ) );
- enr_est = L_shr( L_tmp, exp ); /*Q6 */
+ L_tmp = L_deposit_l( div_s( fra, fra2 ) ); /*Q6+exp*/
+ enr_est = L_shr( L_tmp, exp ); /*Q6 */
if ( LT_32( enr_est, 64 ) )
{
- enr_est = 64;
- move16(); /*Q6 */
+ enr_est = 64; /*Q6 */
+ move16();
}
exp = norm_l( enr_est );
fra = Log2_norm_lc( L_shl( enr_est, exp ) );
exp = sub( sub( 30, exp ), 6 );
- L_tmp = L_Comp( exp, fra );
+ L_tmp = L_Comp( exp, fra ); /*Q16*/
enr_est_log = round_fx( L_shl( L_tmp, 8 ) ); /*Q8 */
Denr_n2e = abs_s( sub( enr_new, enr_est_log ) ); /*Q8 */
@@ -1382,7 +1388,7 @@ void dtx_hangover_control_fx(
exp = norm_l( enr_est );
fra = Log2_norm_lc( L_shl( enr_est, exp ) );
exp = sub( sub( 30, exp ), 6 );
- L_tmp = L_Comp( exp, fra );
+ L_tmp = L_Comp( exp, fra ); /*Q16*/
enr_est_log = round_fx( L_shl( L_tmp, 8 ) ); /*Q8 */
if ( enr_est_log < 0 )
@@ -1399,7 +1405,7 @@ void dtx_hangover_control_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
+ ftmp_fx = 964; /*6400.0f / ( M + 1 ) * 2.56*/
move16(); /*QX2.56 */
S_tmp = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
C[i] = L_mult0( S_tmp, S_tmp ); /*QX6.5536 */
@@ -1407,7 +1413,7 @@ void dtx_hangover_control_fx(
ELSE
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205;
+ ftmp_fx = 1205; /*8000.0f/ ( M + 1 ) * 2.56*/
move16(); /*QX2.56 */
S_tmp = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
C[i] = L_mult0( S_tmp, S_tmp ); /*QX6.5536 */
@@ -1421,22 +1427,22 @@ void dtx_hangover_control_fx(
C[i] = L_mac0( C[i], S_tmp, S_tmp ); /*QX6.5536 */
}
- C[i] = Mpy_32_16_1( C[i], 1928 ); /*QX6.5536 */
+ C[i] = Mpy_32_16_1( C[i], 1928 /*Q15*/ ); /*QX6.5536 */
IF( GT_32( C[i], max_val[0] ) )
{
- max_val[1] = max_val[0];
+ max_val[1] = max_val[0]; /*x6.5536*/
move16();
- max_idx[1] = max_idx[0];
+ max_idx[1] = max_idx[0]; /*Q0*/
move16();
- max_val[0] = C[i];
+ max_val[0] = C[i]; /*x6.5536*/
move16();
max_idx[0] = i;
move16();
}
ELSE IF( GT_32( C[i], max_val[1] ) )
{
- max_val[1] = C[i];
+ max_val[1] = C[i]; /*x6.5536*/
move16();
max_idx[1] = i;
move16();
@@ -1445,14 +1451,14 @@ void dtx_hangover_control_fx(
IF( EQ_16( m, 1 ) )
{
- Copy( tmp, lsp_est, M );
+ Copy( tmp, lsp_est, M ); /*Q15*/
}
ELSE IF( LT_16( m, 4 ) )
{
FOR( i = 0; i < M; i++ )
{
- lsp_est[i] = 0;
- move16(); /*Q15 */
+ lsp_est[i] = 0; /*Q15 */
+ move16();
FOR( j = 0; j < m; j++ )
{
#ifdef BASOP_NOGLOB
@@ -1471,8 +1477,8 @@ void dtx_hangover_control_fx(
{
FOR( i = 0; i < M; i++ )
{
- lsp_est[i] = 0;
- move16(); /*Q15 */
+ lsp_est[i] = 0; /*Q15 */
+ move16();
FOR( j = 0; j < m; j++ )
{
#ifdef BASOP_NOGLOB
@@ -1492,8 +1498,8 @@ void dtx_hangover_control_fx(
}
}
- Dlsp_n2e = 0;
- move16(); /*Q15 */
+ Dlsp_n2e = 0; /*Q15 */
+ move16();
FOR( i = 0; i < M; i++ )
{
#ifdef BASOP_NOGLOB
@@ -1527,13 +1533,13 @@ void dtx_hangover_control_fx(
exp = norm_l( hTdCngEnc->lp_ener_fx );
fra = Log2_norm_lc( L_shl( hTdCngEnc->lp_ener_fx, exp ) );
exp = sub( sub( 30, exp ), 6 );
- L_tmp = L_Comp( exp, fra );
+ L_tmp = L_Comp( exp, fra ); /*Q16*/
S_tmp = round_fx( L_shl( L_tmp, 8 ) ); /*Q8 */
Denr = abs_s( sub( S_tmp, enr_est_log ) ); /*Q8 */
/* make decision if DTX hangover can be terminated */
- hVAD->hangover_terminate_flag = 0;
- move16(); /*Q0 */
+ hVAD->hangover_terminate_flag = 0; /*Q0 */
+ move16();
test();
test();
@@ -1550,8 +1556,8 @@ void dtx_hangover_control_fx(
( LT_16( Dlsp, 13107 ) && LT_16( Denr, 205 ) && LT_16( S_max, 3277 ) && LT_16( Dlsp_n2e, 13107 ) && LT_16( Denr_n2e, 205 ) && st_fx->Opt_SC_VBR == 0 ) )
{
- hVAD->hangover_terminate_flag = 1;
- move16(); /*Q0 */
+ hVAD->hangover_terminate_flag = 1; /*Q0 */
+ move16();
}
return;
@@ -1565,8 +1571,8 @@ void dtx_hangover_control_fx(
void td_cng_enc_init_fx(
TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */
- const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation */
- const Word16 max_bwidth /* i : maximum encoded bandwidth */
+ const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/
+ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/
)
{
@@ -1638,14 +1644,14 @@ void td_cng_enc_init_fx(
set32_fx( hTdCngEnc->old_env_fx, 0, NUM_ENV_CNG );
/* SWB CNG/DTX */
- hTdCngEnc->last_wb_cng_ener_fx = -1541;
- move16(); /* Q8 */
- hTdCngEnc->last_shb_cng_ener_fx = -1541;
- move16(); /* Q8 */
- hTdCngEnc->mov_wb_cng_ener_fx = -1541;
- move16(); /* Q8 */
- hTdCngEnc->mov_shb_cng_ener_fx = -1541;
- move16(); /* Q8 */
+ hTdCngEnc->last_wb_cng_ener_fx = -1541; /* Q8 */
+ move16();
+ hTdCngEnc->last_shb_cng_ener_fx = -1541; /* Q8 */
+ move16();
+ hTdCngEnc->mov_wb_cng_ener_fx = -1541; /* Q8 */
+ move16();
+ hTdCngEnc->mov_shb_cng_ener_fx = -1541; /* Q8 */
+ move16();
hTdCngEnc->shb_cng_ini_cnt = 1;
move16();
hTdCngEnc->shb_NO_DATA_cnt = 0;
@@ -1659,8 +1665,8 @@ void td_cng_enc_init_fx(
void td_cng_enc_init_ivas_fx(
TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */
- const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation */
- const Word16 max_bwidth /* i : maximum encoded bandwidth */
+ const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/
+ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/
)
{
@@ -1732,14 +1738,14 @@ void td_cng_enc_init_ivas_fx(
set16_fx( hTdCngEnc->cng_Qexc_buf, Q15, HO_HIST_SIZE );
/* SWB CNG/DTX */
- hTdCngEnc->last_wb_cng_ener_fx = -1541;
- move16(); /* Q8 */
- hTdCngEnc->last_shb_cng_ener_fx = -1541;
- move16(); /* Q8 */
- hTdCngEnc->mov_wb_cng_ener_fx = -1541;
- move16(); /* Q8 */
- hTdCngEnc->mov_shb_cng_ener_fx = -1541;
- move16(); /* Q8 */
+ hTdCngEnc->last_wb_cng_ener_fx = -1541; /* Q8 */
+ move16();
+ hTdCngEnc->last_shb_cng_ener_fx = -1541; /* Q8 */
+ move16();
+ hTdCngEnc->mov_wb_cng_ener_fx = -1541; /* Q8 */
+ move16();
+ hTdCngEnc->mov_shb_cng_ener_fx = -1541; /* Q8 */
+ move16();
hTdCngEnc->shb_cng_ini_cnt = 1;
move16();
hTdCngEnc->shb_NO_DATA_cnt = 0;
@@ -1762,8 +1768,8 @@ void td_cng_enc_init_ivas_fx(
void dtx_enc_init_fx(
Encoder_State *st, /* i : Encoder state handle */
- const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */
- const Word16 interval_SID /* i : interval for SID update */
+ const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate Q0*/
+ const Word16 interval_SID /* i : interval for SID update Q0*/
)
{
DTX_ENC_HANDLE hDtxEnc;
@@ -1792,7 +1798,7 @@ void dtx_enc_init_fx(
move32();
hDtxEnc->last_CNG_L_frame = L_FRAME;
move16();
- hDtxEnc->var_SID_rate_flag = var_SID_rate_flag;
+ hDtxEnc->var_SID_rate_flag = var_SID_rate_flag; /*Q0*/
move16();
hDtxEnc->last_active_brate = ACELP_7k20;
move32();
diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c
index ee57efffe3b2735dcd2abba7fb1da5d9d236c078..0826880458f9a802528c4cdb2843932f7fa204a7 100644
--- a/lib_enc/enc_acelp_fx.c
+++ b/lib_enc/enc_acelp_fx.c
@@ -20,19 +20,19 @@
#define _1_ 0x2000 /*Q12*/
#define _1_Q9 0x200
-static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Word16 *p );
+static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, UWord32 *ps /*Q0*/, Word16 *p /*Q0*/ );
-void E_ACELP_h_vec_corr1( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 ( *rrixix )[16], Word16 cor[], Word16 dn2_pos[], Word16 nb_pulse );
+void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 track /*Q0*/, Word16 sign[] /*Q15*/, Word16 ( *rrixix )[16] /*Q9*/, Word16 cor[] /*Q9*/, Word16 dn2_pos[] /*Q0*/, Word16 nb_pulse /*Q0*/ );
-void E_ACELP_h_vec_corr2( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 ( *rrixix )[16], Word16 cor[] );
+void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 track /*Q0*/, Word16 sign[] /*Q15*/, Word16 ( *rrixix )[16] /*Q9*/, Word16 cor[] /*Q9*/ );
-Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16 norm_flag, Word16 L_subfr, Word16 exp_xn );
+Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn*/, ACELP_CbkCorr *g_corr, Word16 norm_flag /*Q0*/, Word16 L_subfr /*Q0*/, Word16 exp_xn );
-void E_ACELP_codebook_target_update( Word16 *x, Word16 *x2, Word16 *y, Word16 gain, Word16 L_subfr );
+void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, Word16 *y /*Q_xn*/, Word16 gain /*Q14*/, Word16 L_subfr /*Q0*/ );
-void E_ACELP_vec_neg( Word16 h[], Word16 h_inv[], Word16 L_subfr );
+void E_ACELP_vec_neg_fx( Word16 h[] /*Qx*/, Word16 h_inv[] /*Qx*/, Word16 L_subfr /*Q0*/ );
-void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[4][16], Word16 rrixiy[4][256] );
+void E_ACELP_corrmatrix_fx( Word16 h[] /*Q12*/, Word16 sign[] /*Q0*/, Word16 vec[] /*Q15*/, Word16 rrixix[4][16] /*Q9*/, Word16 rrixiy[4][256] /*Q9*/ );
/*
* E_ACELP_h_vec_corrx
@@ -51,7 +51,7 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
* Returns:
* void
*/
-void E_ACELP_h_vec_corr1( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 ( *rrixix )[16], Word16 cor[], Word16 dn2_pos[], Word16 nb_pulse )
+void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 track /*Q0*/, Word16 sign[] /*Q15*/, Word16 ( *rrixix )[16] /*Q9*/, Word16 cor[] /*Q9*/, Word16 dn2_pos[] /*Q0*/, Word16 nb_pulse /*Q0*/ )
{
Word16 i, j;
Word16 dn, corr;
@@ -60,22 +60,23 @@ void E_ACELP_h_vec_corr1( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[],
Word32 L_sum;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
- dn2 = &dn2_pos[shl( track, 3 )];
- p0 = rrixix[track];
+ dn2 = &dn2_pos[( track * 8 )]; /*Q0*/
+ p0 = rrixix[track]; /*Q9*/
FOR( i = 0; i < nb_pulse; i++ )
{
- dn = dn2[i];
+ dn = dn2[i]; /*Q0*/
move16();
L_sum = L_deposit_l( 0 );
- p1 = h;
- p2 = &vec[dn];
+ p1 = h; /*Qx*/
+ p2 = &vec[dn]; /*Qx*/
FOR( j = dn; j < L_SUBFR - 1; j++ )
{
#ifdef BASOP_NOGLOB
- L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow );
+ L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /*2*Qx+1*/
#else
L_sum = L_mac( L_sum, *p1++, *p2++ );
#endif
@@ -92,7 +93,7 @@ void E_ACELP_h_vec_corr1( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[],
if ( sign[dn] > 0 )
{
#ifdef BASOP_NOGLOB
- corr = add_o( p0[j], corr, &Overflow );
+ corr = add_o( p0[j], corr, &Overflow ); /*Q9*/
#else
corr = add( p0[j], corr );
#endif
@@ -100,40 +101,41 @@ void E_ACELP_h_vec_corr1( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[],
if ( sign[dn] < 0 )
{
#ifdef BASOP_NOGLOB
- corr = sub_o( p0[j], corr, &Overflow );
-#else /* BASOP_NOGLOB */
+ corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/
+#else /* BASOP_NOGLOB */
corr = sub( p0[j], corr );
-#endif /* BASOP_NOGLOB */
+#endif /* BASOP_NOGLOB */
}
- cor[j] = corr;
+ cor[j] = corr; /*Q9*/
move16();
}
return;
}
-void E_ACELP_h_vec_corr2( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 ( *rrixix )[16], Word16 cor[] )
+void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 track /*Q0*/, Word16 sign[] /*Q15*/, Word16 ( *rrixix )[16] /*Q9*/, Word16 cor[] /*Q9*/ )
{
Word16 i, j, pos, corr;
Word16 *p0, *p1, *p2;
Word32 L_sum;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
- p0 = rrixix[track];
+ p0 = rrixix[track]; /*Q9*/
- pos = track;
+ pos = track; /*Q0*/
move16();
FOR( i = 0; i < 16; i++ )
{
L_sum = L_deposit_l( 0 );
- p1 = h;
- p2 = &vec[pos];
+ p1 = h; /*Qx*/
+ p2 = &vec[pos]; /*Qx*/
FOR( j = pos; j < L_SUBFR - 1; j++ )
{
#ifdef BASOP_NOGLOB
- L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow );
+ L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /* 2*Qx+1 */
#else
L_sum = L_mac( L_sum, *p1++, *p2++ );
#endif
@@ -149,7 +151,7 @@ void E_ACELP_h_vec_corr2( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[],
if ( sign[pos] > 0 )
{
#ifdef BASOP_NOGLOB
- corr = add_o( *p0++, corr, &Overflow );
+ corr = add_o( *p0++, corr, &Overflow ); /*Q9*/
#else
corr = add( *p0++, corr );
#endif
@@ -157,12 +159,12 @@ void E_ACELP_h_vec_corr2( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[],
if ( sign[pos] < 0 )
{
#ifdef BASOP_NOGLOB
- corr = sub_o( *p0++, corr, &Overflow );
+ corr = sub_o( *p0++, corr, &Overflow ); /*Q9*/
#else
corr = sub( *p0++, corr );
#endif
}
- cor[i] = corr;
+ cor[i] = corr; /*Q9*/
move16();
pos = add( pos, 4 );
@@ -194,7 +196,7 @@ void E_ACELP_h_vec_corr2( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[],
* Returns:
* void
*/
-static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 track_y, Word16 *ps, Word16 *alp, Word16 *ix, Word16 *iy, Word16 dn[], Word16 *dn2, Word16 cor_x[], Word16 cor_y[], Word16 ( *rrixiy )[256] )
+static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*/, UWord8 track_y /*Q0*/, Word16 *ps /*Qdn*/, Word16 *alp /*Qx*/, Word16 *ix /*Q0*/, Word16 *iy /*Q0*/, Word16 dn[] /*Qdn*/, Word16 *dn2 /*Q0*/, Word16 cor_x[] /*Qx*/, Word16 cor_y[] /*Qx*/, Word16 ( *rrixiy )[256] /*Q9*/ )
{
Word16 x, x2, y, i, *pos_x;
Word16 ps0, ps1, alp2_16, ps2, sq;
@@ -203,28 +205,30 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 trac
Word16 sqk[2], alpk[2], ik;
Word32 xy_save;
Word16 check = 0; /* debug code not instrumented */
+
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* eight dn2 max positions per track */
/*pos_x = &dn2[track_x << 3]; SHIFT(1); PTR_INIT(1);*/
- pos_x = &dn2[shl( track_x, 3 )];
+ pos_x = &dn2[( track_x * 8 )]; /*Qdn*/
move16();
/* save these to limit memory searches */
- alp0 = L_deposit_h( *alp );
- ps0 = *ps;
+ alp0 = L_deposit_h( *alp ); /*Qx-16*/
+ ps0 = *ps; /*Qdn*/
move16();
alpk[0] = 1;
move16();
sqk[0] = -1;
move16();
- x2 = shr( pos_x[0], 2 );
+ x2 = shr( pos_x[0], 2 ); /*Qdn*/
#ifdef BASOP_NOGLOB
- if ( mac_ro( L_mac_o( L_mac_o( alp0, cor_x[x2], _1_, &Overflow ), cor_y[0], _1_, &Overflow ), rrixiy[track_x][shl( x2, 4 )], _1_, &Overflow ) < 0 )
+ if ( mac_ro( L_mac_o( L_mac_o( alp0, cor_x[x2], _1_, &Overflow ), cor_y[0], _1_, &Overflow ), rrixiy[track_x][( x2 * 16 )], _1_, &Overflow ) < 0 )
#else /* BASOP_NOGLOB */
if ( mac_r( L_mac( L_mac( alp0, cor_x[x2], _1_ ), cor_y[0], _1_ ), rrixiy[track_x][shl( x2, 4 )], _1_ ) < 0 )
#endif /* BASOP_NOGLOB */
@@ -234,17 +238,17 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 trac
}
ik = 0;
move16();
- xy_save = L_mac0( L_deposit_l( track_y ), track_x, L_SUBFR );
+ xy_save = L_mac0( L_deposit_l( track_y ), track_x, L_SUBFR ); /*Q0*/
/* loop track 1 */
FOR( i = 0; i < nb_pos_ix; i++ )
{
- x = pos_x[i];
+ x = pos_x[i]; /*Qdn*/
move16();
x2 = shr( x, 2 );
/* dn[x] has only nb_pos_ix positions saved */
/*ps1 = ps0 + dn[x];*/
- ps1 = add( ps0, dn[x] );
+ ps1 = add( ps0, dn[x] ); /*Qdn*/
/*alp1 = alp0 + cor_x[x2];*/
#ifdef BASOP_NOGLOB
@@ -253,28 +257,29 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 trac
alp1 = L_mac( alp0, cor_x[x2], _1_ ); /*Q22*/
#endif /* BASOP_NOGLOB */
- p1 = cor_y;
- p2 = &rrixiy[track_x][shl( x2, 4 )];
+ p1 = cor_y; /*Qx*/
+ p2 = &rrixiy[track_x][( x2 * 16 )]; /*Q9*/
FOR( y = track_y; y < L_SUBFR; y += 4 )
{
/*ps2 = ps1 + dn[y];*/
- ps2 = add( ps1, dn[y] );
+ ps2 = add( ps1, dn[y] ); /*Qdn*/
+ move16();
/*alp2 = alp1 + (*p1++) + (*p2++);*/
#ifdef BASOP_NOGLOB
- alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow );
+ alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow ); /*Qx+12+1*/
alp2_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/
#else /* BASOP_NOGLOB */
alp2 = L_mac( alp1, *p1++, _1_ );
alp2_16 = mac_r( alp2, *p2++, _1_ ); /*Q6*/
#endif /* BASOP_NOGLOB */
- alpk[1 - ik] = alp2_16;
+ alpk[1 - ik] = alp2_16; /*Q6*/
move16();
/*sq = ps2 * ps2;*/
- sq = mult( ps2, ps2 );
- sqk[1 - ik] = sq;
+ sq = mult( ps2, ps2 ); /*2*Qdn+1*/
+ sqk[1 - ik] = sq; /*2*Qdn+1*/
move16();
/*s = (alpk[ik] * sq) - (sqk[0] * alp2);*/
@@ -283,28 +288,30 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 trac
if ( s > 0 )
{
ik = sub( 1, ik );
+ move16();
check = 1; /* debug code not instrumented */
+ move16();
}
if ( s > 0 )
{
- xy_save = L_mac0( y, x, L_SUBFR );
+ xy_save = L_mac0( y, x, L_SUBFR ); /*Qdn*/
}
}
}
assert( check ); /* debug code not instrumented */
- ps2 = extract_l( xy_save );
- *iy = s_and( ps2, L_SUBFR - 1 );
+ ps2 = extract_l( xy_save ); /*Qdn*/
+ *iy = s_and( ps2, L_SUBFR - 1 ); /*Q0*/
move16();
- *ix = lshr( ps2, 6 );
+ *ix = lshr( ps2, 6 ); /*Q0*/
move16();
/**ps = ps0 + dn[*ix] + dn[*iy];*/
- *ps = add( ps0, add( dn[*ix], dn[*iy] ) );
+ *ps = add( ps0, add( dn[*ix], dn[*iy] ) ); /*Qdn*/
move16();
- *alp = alpk[ik];
+ *alp = alpk[ik]; /*Q6*/
move16();
return;
}
@@ -330,12 +337,12 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 trac
* void
*/
static void E_ACELP_1pulse_search( UWord8 tracks[2],
- Word16 *ps,
- Word16 *alp,
- Word16 *ix,
- Word16 dn[],
- Word16 cor_x[],
- Word16 cor_y[] )
+ Word16 *ps, /*Qdn*/
+ Word16 *alp, /*Qx*/
+ Word16 *ix, /*Q0*/
+ Word16 dn[], /*Qdn*/
+ Word16 cor_x[], /*Q6*/
+ Word16 cor_y[] /*Q6*/ )
{
Word16 x, x_save = 0;
Word16 ps0;
@@ -348,14 +355,14 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
/* save these to limit memory searches */
alp0 = L_deposit_h( *alp );
- ps0 = *ps;
+ ps0 = *ps; /*Qdn*/
move16();
alpk[0] = 1;
move16();
sqk[0] = -1;
move16();
- if ( mac_r_sat( alp0, cor_x[shr( tracks[0], 2 )], _1_ ) < 0 )
+ if ( mac_r_sat( alp0, cor_x[( tracks[0] / 4 )], _1_ ) < 0 )
{
sqk[0] = 1;
move16();
@@ -364,6 +371,7 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
move16();
ntracks = 1;
+ move16();
if ( NE_16( tracks[1], tracks[0] ) )
{
ntracks = 2;
@@ -379,16 +387,16 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
FOR( x = tracks[t]; x < L_SUBFR; x += 4 )
{
/*ps1 = ps0 + dn[x]; ADD(1);*/
- ps1 = add( ps0, dn[x] );
+ ps1 = add( ps0, dn[x] ); /*Qdn*/
/*alp1 = alp0 + cor_x[x>>2]; SHIFT(1);ADD(1);*/
- alp1 = mac_r_sat( alp0, cor_x[shr( x, 2 )], _1_ ); /*Q6*/
- alpk[1 - ik] = alp1;
+ alp1 = mac_r_sat( alp0, cor_x[( x / 4 )], _1_ ); /*Q6*/
+ alpk[1 - ik] = alp1; /*Q6*/
move16();
/*sq = ps1 * ps1; MULT(1);*/
- sq = mult( ps1, ps1 );
- sqk[1 - ik] = sq;
+ sq = mult( ps1, ps1 ); /*2*Qdn+1*/
+ sqk[1 - ik] = sq; /*2*Qdn+1*/
move16();
/*s = (alpk * sq) - (sqk * alp1); MULT(1);MAC(1); */
@@ -408,11 +416,11 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
assert( check ); /* debug code not instrumented */
}
- *ps = add( ps0, dn[x_save] );
+ *ps = add( ps0, dn[x_save] ); /*2*Qdn+1*/
move16();
- *alp = alpk[ik];
+ *alp = alpk[ik]; /*Q6*/
move16();
- *ix = x_save;
+ *ix = x_save; /*Q0*/
move16();
return;
}
@@ -437,7 +445,7 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
* Returns:
* void
*/
-static void E_ACELP_xh_corr( Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr )
+static void E_ACELP_xh_corr( Word16 *x /*Qx*/, Word16 *y /*Qy*/, Word16 *h /*Q12*/, Word16 L_subfr /*Q0*/ )
{
Word16 i, j, k;
Word32 L_tmp, y32[L_SUBFR16k], L_maxloc, L_tot;
@@ -452,16 +460,16 @@ static void E_ACELP_xh_corr( Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr )
L_maxloc = L_deposit_l( 0 );
FOR( i = k; i < L_subfr; i += 4 )
{
- L_tmp = L_mac0( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] */
+ L_tmp = L_mac0( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+Q12*/
FOR( j = i; j < L_subfr - 1; j++ )
{
- L_tmp = L_mac0( L_tmp, x[j + 1], h[j + 1 - i] );
+ L_tmp = L_mac0( L_tmp, x[j + 1], h[j + 1 - i] ); /*Qx+Q12*/
}
- y32[i] = L_tmp;
+ y32[i] = L_tmp; /*Qx+Q12*/
move32();
- L_tmp = L_abs( L_tmp );
- L_maxloc = L_max( L_tmp, L_maxloc );
+ L_tmp = L_abs( L_tmp ); /*Qx+Q12*/
+ L_maxloc = L_max( L_tmp, L_maxloc ); /*Qx+Q12*/
}
/* tot += 3*max / 8 */
L_maxloc = L_shr( L_maxloc, 2 );
@@ -482,7 +490,7 @@ static void E_ACELP_xh_corr( Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr )
j = sub( norm_l( L_tot ), 4 + 16 ); /* 4 -> 16 x tot */
- Copy_Scale_sig_32_16( y32, y, L_subfr, j );
+ Copy_Scale_sig_32_16( y32, y, L_subfr, j ); /*Qy = Qx+Q12+j*/
return;
}
@@ -494,7 +502,7 @@ static void E_ACELP_xh_corr( Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr )
* \param bits amount of target headroom bits for y
* \return exponent of y
*/
-Word16 E_ACELP_hh_corr( Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits )
+Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ )
{
Word16 i, j, k = 0; /* initialize just to avoid compiler warning */
Word32 L_tmp, L_sum;
@@ -504,21 +512,21 @@ Word16 E_ACELP_hh_corr( Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits )
Word64 L_tmp_64;
Word64 L_sum_64;
- L_tmp_64 = W_mult0_16_16( x[i], x[0] );
+ L_tmp_64 = W_mult0_16_16( x[i], x[0] ); /*Q22*/
FOR( j = i + 2; j < L_subfr; j += 2 )
{
- L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j - i] );
+ L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j - i] ); /*Q22*/
}
L_sum_64 = L_tmp_64;
move64();
- L_tmp_64 = W_mult0_16_16( x[i + 1], x[1] );
+ L_tmp_64 = W_mult0_16_16( x[i + 1], x[1] ); /*Q22*/
FOR( j = i + 3; j < L_subfr; j += 2 )
{
- L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j - i] );
+ L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j - i] ); /*Q22*/
}
L_sum_64 = W_add_nosat( W_shr( L_sum_64, 1 ), W_shr( L_tmp_64, 1 ) );
- L_sum = W_sat_l( L_sum_64 );
+ L_sum = W_sat_l( L_sum_64 ); /*Q22*/
/* L_sum = L_shr( L_sum, 1 ); */
if ( i == 0 )
{
@@ -529,12 +537,12 @@ Word16 E_ACELP_hh_corr( Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits )
k = sub( k, bits );
}
- y[i] = round_fx( L_shl( L_sum, k ) );
+ y[i] = round_fx( L_shl( L_sum, k ) ); /*Q22+k-16*/
}
- L_tmp = L_mult0( x[i], x[0] );
+ L_tmp = L_mult0( x[i], x[0] ); /*Q22*/
L_sum = L_shr( L_tmp, 1 );
- y[i] = round_fx( L_shl( L_sum, k ) );
+ y[i] = round_fx( L_shl( L_sum, k ) ); /*Qy = Q22+k-16*/
k = add( 1, k );
@@ -560,13 +568,14 @@ Word16 E_ACELP_hh_corr( Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits )
* Returns:
* pitch gain (0 ... 1.2F) (Q14)
*/
-Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16 norm_flag, Word16 L_subfr, Word16 exp_xn )
+Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn*/, ACELP_CbkCorr *g_corr, Word16 norm_flag /*Q0*/, Word16 L_subfr /*Q0*/, Word16 exp_xn )
{
Word16 i, Q_xn;
Word16 xy, yy, exp_xy, exp_yy, gain;
Word32 L_off;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
L_off = L_shr( 10737418l /*0.01f/2.0f Q31*/, s_min( add( exp_xn, exp_xn ), 31 ) );
@@ -574,10 +583,10 @@ Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16
#ifdef BASOP_NOGLOB
/* Compute scalar product t1: */
- yy = round_fx_o( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ), &Overflow );
+ yy = round_fx_o( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ), &Overflow ); /*Q15 - exp_yy*/
/* Compute scalar product t0: */
- xy = round_fx_o( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ), &Overflow );
+ xy = round_fx_o( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ), &Overflow ); /*Q15 - exp_xy*/
#else
/* Compute scalar product t1: */
yy = round_fx( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ) );
@@ -606,8 +615,8 @@ Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16
/* compute gain = xy/yy */
- xy = mult_r( xy, 0x4000 ); /* Be sure xy < yy */
- gain = div_s( xy, yy );
+ xy = mult_r( xy, 0x4000 ); /* Be sure xy < yy Q15 - exp_xy*/
+ gain = div_s( xy, yy ); /*Q14*/
i = add( exp_xy, 1 - 1 ); /* -1 -> gain in Q14 */
i = sub( i, exp_yy );
@@ -622,7 +631,7 @@ Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16
/* if (gain > 1.2) gain = 1.2 in Q14 */
- gain = s_min( 19661 /*1.2f Q14*/ /* 19661 */, gain );
+ gain = s_min( 19661 /*1.2f Q14*/ /* 19661 */, gain ); /*Q14*/
/*Limit the energy of pitch contribution*/
IF( norm_flag )
@@ -631,7 +640,7 @@ Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16
/* Compute scalar product */
#ifdef BASOP_NOGLOB
- tmp = round_fx_o( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ), &Overflow );
+ tmp = round_fx_o( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ), &Overflow ); /*Q15 - exp_tmp*/
#else
tmp = round_fx( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) );
#endif
@@ -639,19 +648,19 @@ Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16
tmp = BASOP_Util_Divide1616_Scale( tmp, yy, &exp_div );
exp_tmp = add( sub( exp_tmp, exp_yy ), exp_div );
- tmp = Sqrt16( tmp, &exp_tmp );
+ tmp = Sqrt16( tmp, &exp_tmp ); /*Q15 - exp_tmp*/
/* Note: shl works as shl or shr. */
exp_tmp = sub( exp_tmp, 1 );
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
- tmp = round_fx_o( L_shl_o( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp, &Overflow ), &Overflow );
-#else /* BASOP_NOGLOB */
+ tmp = round_fx_o( L_shl_o( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp, &Overflow ), &Overflow ); /*Q14*/
+#else /* BASOP_NOGLOB */
tmp = round_fx( L_shl( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp ) );
-#endif /* BASOP_NOGLOB */
+#endif /* BASOP_NOGLOB */
BASOP_SATURATE_WARNING_ON_EVS
- gain = s_min( gain, tmp );
+ gain = s_min( gain, tmp ); /*Q14*/
}
bail:
@@ -679,7 +688,7 @@ bail:
* Returns:
* pitch gain (0 ... 1.2F)
*/
-void E_ACELP_xy2_corr( Word16 xn[], Word16 y1[], Word16 y2[], ACELP_CbkCorr *g_corr, Word16 L_subfr, Word16 exp_xn )
+void E_ACELP_xy2_corr( Word16 xn[] /*Q_xn*/, Word16 y1[] /*Q_xn*/, Word16 y2[] /*Q9*/, ACELP_CbkCorr *g_corr, Word16 L_subfr /*Q0*/, Word16 exp_xn )
{
Word16 xny2, y2y2, y1y2, xx, exp_xny2, exp_y2y2, exp_y1y2, exp_xx;
Word32 L_off;
@@ -687,20 +696,20 @@ void E_ACELP_xy2_corr( Word16 xn[], Word16 y1[], Word16 y2[], ACELP_CbkCorr *g_c
BASOP_SATURATE_ERROR_ON_EVS;
/* Compute scalar product */
- y2y2 = extract_h( Dot_product15_offs( y2, y2, L_subfr, &exp_y2y2, 5243l /*0.01f Q19*/ ) );
+ y2y2 = extract_h( Dot_product15_offs( y2, y2, L_subfr, &exp_y2y2, 5243l /*0.01f Q19*/ ) ); /*Q15-exp_y2y2*/
/* L_off = 1L; */
L_off = L_shr( 10737418l /*0.01f/2.0f Q31*/, sub( 30 - 9, exp_xn ) );
/* Compute scalar product */
- xny2 = extract_h( Dot_product12_offs( xn, y2, L_subfr, &exp_xny2, L_off ) );
+ xny2 = extract_h( Dot_product12_offs( xn, y2, L_subfr, &exp_xny2, L_off ) ); /*Q15-exp_xny2*/
/* Compute scalar product */
- y1y2 = extract_h( Dot_product12_offs( y1, y2, L_subfr, &exp_y1y2, L_off ) );
+ y1y2 = extract_h( Dot_product12_offs( y1, y2, L_subfr, &exp_y1y2, L_off ) ); /*Q15-exp_y1y2*/
/* Compute scalar product */
L_off = L_shr( 21474836l /*0.01f Q31*/, s_min( 31, sub( 30, shl( exp_xn, 1 ) ) ) );
- xx = extract_h( Dot_product12_offs( xn, xn, L_subfr, &exp_xx, L_off ) );
+ xx = extract_h( Dot_product12_offs( xn, xn, L_subfr, &exp_xx, L_off ) ); /*Q15-exp_xx*/
g_corr->y2y2 = y2y2;
@@ -741,12 +750,13 @@ void E_ACELP_xy2_corr( Word16 xn[], Word16 y1[], Word16 y2[], ACELP_CbkCorr *g_c
* Returns:
* void
*/
-void E_ACELP_codebook_target_update( Word16 *x, Word16 *x2, Word16 *y, Word16 gain, Word16 L_subfr )
+void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, Word16 *y /*Q_xn*/, Word16 gain /*Q14*/, Word16 L_subfr /*Q0*/ )
{
Word16 i, Q15_flag;
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
assert( gain >= 0 );
@@ -757,21 +767,21 @@ void E_ACELP_codebook_target_update( Word16 *x, Word16 *x2, Word16 *y, Word16 ga
Q15_flag = 1;
move16();
}
- gain = shl( gain, Q15_flag );
+ gain = shl( gain, Q15_flag ); /*Q14*/
FOR( i = 0; i < L_subfr; i++ )
{
- L_tmp = L_deposit_h( x[i] );
+ L_tmp = L_deposit_h( x[i] ); /*Q_xn+16*/
if ( Q15_flag == 0 )
{
#ifdef BASOP_NOGLOB
- L_tmp = L_msu_o( L_tmp, y[i], gain, &Overflow );
+ L_tmp = L_msu_o( L_tmp, y[i], gain, &Overflow ); /*Q_xn+15*/
#else
L_tmp = L_msu( L_tmp, y[i], gain );
#endif
}
#ifdef BASOP_NOGLOB
- x2[i] = msu_ro( L_tmp, y[i], gain, &Overflow );
+ x2[i] = msu_ro( L_tmp, y[i], gain, &Overflow ); /*Q_xn*/
#else
x2[i] = msu_r( L_tmp, y[i], gain );
#endif
@@ -800,7 +810,7 @@ void E_ACELP_codebook_target_update( Word16 *x, Word16 *x2, Word16 *y, Word16 ga
* Returns:
* void
*/
-void E_ACELP_pulsesign( const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sign[], Word16 vec[], const Word16 alp, const Word16 sign_val, const Word16 L_subfr )
+void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 dn2[] /*Qdn2*/, Word16 sign[] /*Q13*/, Word16 vec[] /*Q15*/, const Word16 alp /*Q13*/, const Word16 sign_val /*Q15*/, const Word16 L_subfr /*Q0*/ )
{
Word16 i;
Word32 Lval, Lcor;
@@ -810,21 +820,22 @@ void E_ACELP_pulsesign( const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sig
Word16 val, index;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* calculate energy for normalization of cn[] and dn[] */
- Lval = L_mac0( 1, cn[0], cn[0] );
- Lcor = L_mac0( 1, dn[0], dn[0] );
+ Lval = L_mac0( 1, cn[0], cn[0] ); /*2*Q_xn*/
+ Lcor = L_mac0( 1, dn[0], dn[0] ); /*2*Qdn*/
FOR( i = 1; i < L_subfr; i++ )
{
#ifdef BASOP_NOGLOB
- Lval = L_mac0_o( Lval, cn[i], cn[i], &Overflow );
-#else /* BASOP_NOGLOB */
+ Lval = L_mac0_o( Lval, cn[i], cn[i], &Overflow ); /*2*Q_xn*/
+#else /* BASOP_NOGLOB */
Lval = L_mac0( Lval, cn[i], cn[i] );
-#endif /* BASOP_NOGLOB */
- Lcor = L_mac0( Lcor, dn[i], dn[i] );
+#endif /* BASOP_NOGLOB */
+ Lcor = L_mac0( Lcor, dn[i], dn[i] ); /*2*Qdn*/
}
e_dn = 31;
@@ -832,8 +843,8 @@ void E_ACELP_pulsesign( const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sig
e_cn = 31;
move16();
- Lval = Sqrt32( Lval, &e_dn );
- Lcor = Sqrt32( Lcor, &e_cn );
+ Lval = Sqrt32( Lval, &e_dn ); /*Q31 - e_dn*/
+ Lcor = Sqrt32( Lcor, &e_cn ); /*Q31 - e_cn*/
i = sub( e_dn, e_cn );
if ( i < 0 )
Lval = L_shl( Lval, i );
@@ -841,55 +852,55 @@ void E_ACELP_pulsesign( const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sig
Lcor = L_shr( Lcor, i );
#ifdef BASOP_NOGLOB
- k_dn = round_fx_o( Lval, &Overflow );
- k_cn = round_fx_o( Lcor, &Overflow );
-#else /* BASOP_NOGLOB */
+ k_dn = round_fx_o( Lval, &Overflow ); /*Q15 - e_dn*/
+ k_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/
+#else /* BASOP_NOGLOB */
k_dn = round_fx( Lval );
k_cn = round_fx( Lcor );
-#endif /* BASOP_NOGLOB */
+#endif /* BASOP_NOGLOB */
k_cn = mult_r( 0x2000, k_cn ); /* 1 in Q13 */
k_dn = mult_r( alp, k_dn ); /* alp in Q13 */
- sign_neg = negate( sign_val );
+ sign_neg = negate( sign_val ); /*Q15*/
- signs[0] = sign_neg;
+ signs[0] = sign_neg; /*Q15*/
move16();
- signs[1] = sign_val;
+ signs[1] = sign_val; /*Q15*/
move16();
- signs[2] = sign_neg;
+ signs[2] = sign_neg; /*Q15*/
move16();
- ptr16 = &signs[1];
+ ptr16 = &signs[1]; /*Q15*/
FOR( i = 0; i < L_subfr; i++ )
{
/*cor = (s * cn[i]) + (alp * dn[i]); MULT(1);MAC(1);*/
- Lcor = L_mult( cn[i], k_cn );
- Lcor = L_mac( Lcor, dn[i], k_dn );
+ Lcor = L_mult( cn[i], k_cn ); /*Q_xn + Q15 - e_cn + 1*/
+ Lcor = L_mac( Lcor, dn[i], k_dn ); /*Qdn + Q15 - e_dn + 1*/
#ifdef BASOP_NOGLOB
- val = round_fx_o( L_shl_o( Lcor, 4, &Overflow ), &Overflow ); /*shifting by 4 may overflow but improves accuracy*/
+ val = round_fx_o( L_shl_o( Lcor, 4, &Overflow ), &Overflow ); /*shifting by 4 may overflow but improves accuracy Qdn + 4 - e_dn*/
#else
val = round_fx( L_shl( Lcor, 4 ) ); /*shifting by 4 may overflow but improves accuracy*/
#endif
index = shr( val, 15 );
- sign[i] = ptr16[index];
- move16(); /* yields -1 (when ps < 0) or 0 (when ps >= 0) */
- vec[i] = ptr16[index + 1];
+ sign[i] = ptr16[index]; /*Q15*/
+ move16(); /* yields -1 (when ps < 0) or 0 (when ps >= 0) */
+ vec[i] = ptr16[index + 1]; /*Q15*/
move16();
if ( val < 0 )
{
- dn[i] = negate( dn[i] );
+ dn[i] = negate( dn[i] ); /*Qdn*/
move16();
}
- dn2[i] = abs_s( val );
- move16(); /* dn2[] = mix of dn[] and cn[] */
+ dn2[i] = abs_s( val ); /*Qdn2 = Qdn + 4 - e_dn*/
+ move16(); /* dn2[] = mix of dn[] and cn[] */
}
}
-void E_ACELP_findcandidates( Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[] )
+void E_ACELP_findcandidates( Word16 dn2[] /*Qx*/, Word16 dn2_pos[] /*Q0*/, Word16 pos_max[] /*Q0*/ )
{
Word16 i, k, j, i8;
Word16 *ps_ptr;
@@ -899,13 +910,13 @@ void E_ACELP_findcandidates( Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[] )
i8 = shl( i, 3 );
FOR( k = i8; k < i8 + 8; k++ )
{
- ps_ptr = &dn2[i];
+ ps_ptr = &dn2[i]; /*Qx*/
FOR( j = i + 4; j < L_SUBFR; j += 4 )
{
if ( GT_16( dn2[j], *ps_ptr ) )
{
- ps_ptr = &dn2[j];
+ ps_ptr = &dn2[j]; /*Qx*/
move16();
}
}
@@ -915,15 +926,15 @@ void E_ACELP_findcandidates( Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[] )
dn2_pos[k] = (Word16) ( ps_ptr - dn2 );
move16();
}
- pos_max[i] = dn2_pos[i8];
+ pos_max[i] = dn2_pos[i8]; /*Q0*/
move16();
}
}
-static void E_ACELP_apply_sign( Word16 *p0, Word16 *psign0 )
+static void E_ACELP_apply_sign( Word16 *p0 /*Qx*/, Word16 *psign0 /*Q15*/ )
{
- p0[0] = mult_r( p0[0], psign0[0] );
+ p0[0] = mult_r( p0[0], psign0[0] ); /*Qx*/
move16();
p0[1] = mult_r( p0[1], psign0[4] );
move16();
@@ -957,7 +968,7 @@ static void E_ACELP_apply_sign( Word16 *p0, Word16 *psign0 )
move16();
}
-void E_ACELP_vec_neg( Word16 h[], Word16 h_inv[], Word16 L_subfr )
+void E_ACELP_vec_neg_fx( Word16 h[] /*Qx*/, Word16 h_inv[] /*Qx*/, Word16 L_subfr /*Q0*/ )
{
Word16 i;
@@ -969,7 +980,7 @@ void E_ACELP_vec_neg( Word16 h[], Word16 h_inv[], Word16 L_subfr )
}
-void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[4][16], Word16 rrixiy[4][256] )
+void E_ACELP_corrmatrix_fx( Word16 h[] /*Q12*/, Word16 sign[] /*Q0*/, Word16 vec[] /*Q15*/, Word16 rrixix[4][16] /*Q9*/, Word16 rrixiy[4][256] /*Q9*/ )
{
Word16 *p0, *p1, *p2, *p3, *psign0, *psign1, *psign2, *psign3;
@@ -989,20 +1000,20 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
p2 = &rrixix[2][16 - 1];
p3 = &rrixix[3][16 - 1];
- ptr_h1 = h;
+ ptr_h1 = h; /*Q12*/
cor = L_deposit_l( 0 );
FOR( i = 0; i < 16; i++ )
{
- cor = L_mac( cor, *ptr_h1, *ptr_h1 );
+ cor = L_mac( cor, *ptr_h1, *ptr_h1 ); /*Q25*/
ptr_h1++;
- *p3-- = round_fx( L_shr( cor, 1 ) );
- cor = L_mac( cor, *ptr_h1, *ptr_h1 );
+ *p3-- = round_fx( L_shr( cor, 1 ) ); /* Q9 */
+ cor = L_mac( cor, *ptr_h1, *ptr_h1 ); /*Q25*/
ptr_h1++;
- *p2-- = round_fx( L_shr( cor, 1 ) );
- cor = L_mac( cor, *ptr_h1, *ptr_h1 );
+ *p2-- = round_fx( L_shr( cor, 1 ) ); /* Q9 */
+ cor = L_mac( cor, *ptr_h1, *ptr_h1 ); /*Q25*/
ptr_h1++;
- *p1-- = round_fx( L_shr( cor, 1 ) );
- cor = L_mac( cor, *ptr_h1, *ptr_h1 );
+ *p1-- = round_fx( L_shr( cor, 1 ) ); /* Q9 */
+ cor = L_mac( cor, *ptr_h1, *ptr_h1 ); /*Q25*/
ptr_h1++;
*p0-- = round_fx( L_shr( cor, 1 ) ); /* Q9 */
}
@@ -1015,77 +1026,88 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
/* storage order --> i2i3, i1i2, i0i1, i3i0 */
pos = 256 - 1;
- ptr_hf = h + 1;
+ move16();
+ ptr_hf = h + 1; /*Q12*/
FOR( k = 0; k < 16; k++ )
{
- p3 = &rrixiy[2][pos];
+ p3 = &rrixiy[2][pos]; /* Q9 */
p2 = &rrixiy[1][pos];
p1 = &rrixiy[0][pos];
p0 = &rrixiy[3][pos - 16];
cor = L_deposit_h( 0 );
- ptr_h1 = h;
- ptr_h2 = ptr_hf;
+ ptr_h1 = h; /*Q12*/
+ ptr_h2 = ptr_hf; /*Q12*/
FOR( i = k; i < 16 - 1; i++ )
{
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p3 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p2 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p1 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p0 = round_fx( cor );
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p3 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p2 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p1 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p0 = round_fx( cor ); /*Q9*/
p3 -= ( 16 + 1 );
p2 -= ( 16 + 1 );
p1 -= ( 16 + 1 );
p0 -= ( 16 + 1 );
}
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p3 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p2 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p1 = round_fx( cor );
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p3 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p2 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p1 = round_fx( cor ); /*Q9*/
+ move16();
+ move16();
+ move16();
pos -= 16;
+ move16();
ptr_hf += 4;
}
/* storage order --> i3i0, i2i3, i1i2, i0i1 */
pos = 256 - 1;
- ptr_hf = h + 3;
+ move16();
+ ptr_hf = h + 3; /*Q12*/
FOR( k = 0; k < 16; k++ )
{
- p3 = &rrixiy[3][pos];
+ p3 = &rrixiy[3][pos]; /*Q9*/
p2 = &rrixiy[2][pos - 1];
p1 = &rrixiy[1][pos - 1];
p0 = &rrixiy[0][pos - 1];
cor = L_deposit_h( 0 );
- ptr_h1 = h;
- ptr_h2 = ptr_hf;
+ ptr_h1 = h; /*Q12*/
+ ptr_h2 = ptr_hf; /*Q12*/
FOR( i = k; i < 16 - 1; i++ )
{
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p3 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p2 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p1 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p0 = round_fx( cor );
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p3 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p2 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p1 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p0 = round_fx( cor ); /*Q9*/
+ move16();
+ move16();
+ move16();
+ move16();
p3 -= ( 16 + 1 );
p2 -= ( 16 + 1 );
p1 -= ( 16 + 1 );
p0 -= ( 16 + 1 );
}
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p3 = round_fx( cor );
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p3 = round_fx( cor ); /*Q9*/
+ move16();
pos--;
ptr_hf += 4;
@@ -1095,7 +1117,7 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
* Modification of rrixiy[][] to take signs into account.
*/
- p0 = &rrixiy[0][0];
+ p0 = &rrixiy[0][0]; /*Q9*/
/* speed-up: 11% */
p1 = &rrixiy[1][0];
@@ -1105,19 +1127,19 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
FOR( i = 0; i < L_SUBFR; i += 4 )
{
- psign0 = &vec[1];
+ psign0 = &vec[1]; /*Q15*/
if ( sign[i + 0] > 0 )
psign0 = &sign[1];
- psign1 = &vec[2];
+ psign1 = &vec[2]; /*Q15*/
if ( sign[i + 1] > 0 )
psign1 = &sign[2];
- psign2 = &vec[3];
+ psign2 = &vec[3]; /*Q15*/
if ( sign[i + 2] > 0 )
psign2 = &sign[3];
- psign3 = &vec[0];
+ psign3 = &vec[0]; /*Q15*/
if ( sign[i + 3] > 0 )
psign3 = &sign[0];
@@ -1136,7 +1158,7 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
return;
}
-void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word16 code[], const PulseConfig *config, Word16 ind[], Word16 y[] )
+void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ )
{
Word16 sign[L_SUBFR], vec[L_SUBFR];
Word16 cor_x[16], cor_y[16], h_buf[4 * L_SUBFR];
@@ -1157,6 +1179,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
Word16 check = 0; /* debug code not instrumented */
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -1197,12 +1220,12 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
FOR( i = 0; i < L_SUBFR; i++ )
{
#ifdef BASOP_NOGLOB
- L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow );
+ L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/
#else
L_tmp = L_mac( L_tmp, H[i], H[i] );
#endif
}
- val = extract_h( L_tmp );
+ val = extract_h( L_tmp ); /*Q9*/
BASOP_SATURATE_WARNING_ON_EVS
if ( GT_16( val, 0x2000 ) )
@@ -1216,15 +1239,15 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
move16();
}
- Copy_Scale_sig( H, h, L_SUBFR, scale );
+ Copy_Scale_sig( H, h, L_SUBFR, scale ); /*Q12+scale*/
- E_ACELP_vec_neg( h, h_inv, L_SUBFR );
+ E_ACELP_vec_neg_fx( h, h_inv, L_SUBFR );
/*
* Compute correlation matrices needed for the codebook search.
*/
- E_ACELP_corrmatrix( h, sign, vec, rrixix, rrixiy );
+ E_ACELP_corrmatrix_fx( h, sign, vec, rrixix, rrixiy );
/*
@@ -1275,25 +1298,25 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
i = shr( ind[0], 2 );
j = shr( ind[1], 2 );
l = add( shl( i, 4 ), j );
- s = L_mult( rrixix[ipos[0]][i], _1_ ); /* Q9+Q12+1 */
- s = L_mac( s, rrixix[ipos[1]][j], _1_ );
- alp = mac_r( s, rrixiy[ipos[0]][l], _1_ );
+ s = L_mult( rrixix[ipos[0]][i], _1_ ); /* Q9+Q12+1 */
+ s = L_mac( s, rrixix[ipos[1]][j], _1_ ); /* Q9+Q12+1 */
+ alp = mac_r( s, rrixiy[ipos[0]][l], _1_ ); /* Q9+Q12+1-16 */
- p0 = h - ind[0];
+ p0 = h - ind[0]; /*Q12+scale*/
if ( sign[ind[0]] < 0 )
{
- p0 = h_inv - ind[0];
+ p0 = h_inv - ind[0]; /*Q12+scale*/
}
- p1 = h - ind[1];
+ p1 = h - ind[1]; /*Q12+scale*/
if ( sign[ind[1]] < 0 )
{
- p1 = h_inv - ind[1];
+ p1 = h_inv - ind[1]; /*Q12+scale*/
}
FOR( i = 0; i < L_SUBFR; i++ )
{
- vec[i] = add( *p0++, *p1++ );
+ vec[i] = add( *p0++, *p1++ ); /*Q12+scale*/
move16();
}
}
@@ -1301,57 +1324,57 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
{
/* first stage: fix 4 pulses */
- ind[0] = pos_max[ipos[0]];
+ ind[0] = pos_max[ipos[0]]; /*Q0*/
move16();
- ind[1] = pos_max[ipos[1]];
+ ind[1] = pos_max[ipos[1]]; /*Q0*/
move16();
- ind[2] = pos_max[ipos[2]];
+ ind[2] = pos_max[ipos[2]]; /*Q0*/
move16();
- ind[3] = pos_max[ipos[3]];
+ ind[3] = pos_max[ipos[3]]; /*Q0*/
move16();
/*ps = dn[ind[0]] + dn[ind[1]] + dn[ind[2]] + dn[ind[3]];*/
ps = add( add( add( dn[ind[0]], dn[ind[1]] ), dn[ind[2]] ), dn[ind[3]] );
- p0 = h - ind[0];
+ p0 = h - ind[0]; /*Q12+scale*/
if ( sign[ind[0]] < 0 )
{
- p0 = h_inv - ind[0];
+ p0 = h_inv - ind[0]; /*Q12+scale*/
}
- p1 = h - ind[1];
+ p1 = h - ind[1]; /*Q12+scale*/
if ( sign[ind[1]] < 0 )
{
- p1 = h_inv - ind[1];
+ p1 = h_inv - ind[1]; /*Q12+scale*/
}
- p2 = h - ind[2];
+ p2 = h - ind[2]; /*Q12+scale*/
if ( sign[ind[2]] < 0 )
{
- p2 = h_inv - ind[2];
+ p2 = h_inv - ind[2]; /*Q12+scale*/
}
- p3 = h - ind[3];
+ p3 = h - ind[3]; /*Q12+scale*/
if ( sign[ind[3]] < 0 )
{
- p3 = h_inv - ind[3];
+ p3 = h_inv - ind[3]; /*Q12+scale*/
}
FOR( i = 0; i < L_SUBFR; i++ )
{
- vec[i] = add( add( add( *p0++, *p1++ ), *p2++ ), *p3++ );
+ vec[i] = add( add( add( *p0++, *p1++ ), *p2++ ), *p3++ ); /*Q12+scale*/
move16();
}
- L_tmp = L_mult( vec[0], vec[0] );
+ L_tmp = L_mult( vec[0], vec[0] ); /*Q25+2*scale*/
FOR( i = 1; i < L_SUBFR; i++ )
#ifdef BASOP_NOGLOB
- L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow );
+ L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow ); /*Q25+2*scale*/
#else
L_tmp = L_mac( L_tmp, vec[i], vec[i] );
#endif
- alp = round_fx( L_shr( L_tmp, 3 ) );
+ alp = round_fx( L_shr( L_tmp, 3 ) ); /*Q6+2*scale*/
/*alp *= 0.5F; */
}
@@ -1368,9 +1391,9 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
* of the next 2 pulses with previous fixed pulses.
* Each pulse can have 16 possible positions.
*/
- E_ACELP_h_vec_corr1( h, vec, ipos[j], sign, rrixix, cor_x, dn2_pos, config->nbpos[st] );
+ E_ACELP_h_vec_corr1_fx( h, vec, ipos[j], sign, rrixix, cor_x, dn2_pos, config->nbpos[st] );
- E_ACELP_h_vec_corr2( h, vec, ipos[j + 1], sign, rrixix, cor_y );
+ E_ACELP_h_vec_corr2_fx( h, vec, ipos[j + 1], sign, rrixix, cor_y );
/*
* Find best positions of 2 pulses.
@@ -1380,9 +1403,9 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
}
ELSE /* single pulse search */
{
- E_ACELP_h_vec_corr2( h, vec, ipos[j], sign, rrixix, cor_x );
+ E_ACELP_h_vec_corr2_fx( h, vec, ipos[j], sign, rrixix, cor_x );
- E_ACELP_h_vec_corr2( h, vec, ipos[j + 1], sign, rrixix, cor_y );
+ E_ACELP_h_vec_corr2_fx( h, vec, ipos[j + 1], sign, rrixix, cor_y );
E_ACELP_1pulse_search( &ipos[j], &ps, &alp,
&ind[j], dn, cor_x, cor_y );
@@ -1390,16 +1413,16 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
IF( GT_16( nb_pulse_m2, j ) )
{
- p0 = h - ind[j];
+ p0 = h - ind[j]; /*Q12+scale*/
if ( sign[ind[j]] < 0 )
{
- p0 = h_inv - ind[j];
+ p0 = h_inv - ind[j]; /*Q12+scale*/
}
- p1 = h - ind[j + 1];
+ p1 = h - ind[j + 1]; /*Q12+scale*/
if ( sign[ind[j + 1]] < 0 )
{
- p1 = h_inv - ind[j + 1];
+ p1 = h_inv - ind[j + 1]; /*Q12+scale*/
}
@@ -1428,6 +1451,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
if ( psk < 0 )
{
s = 1;
+ move32();
}
IF( s > 0 )
{
@@ -1435,8 +1459,8 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
move16();
alpk = alp;
move16();
- Copy( ind, codvec, nb_pulse );
- check = 1; /* debug code not instrumented */
+ Copy( ind, codvec, nb_pulse ); /*Q0*/
+ check = 1; /* debug code not instrumented */
}
}
@@ -1451,9 +1475,9 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
set16_fx( y, 0, L_SUBFR );
FOR( k = 0; k < nb_pulse; ++k )
{
- i = codvec[k];
+ i = codvec[k]; /*Q0*/
move16();
- p0 = h_inv - i;
+ p0 = h_inv - i; /*Q12+scale*/
if ( sign[i] > 0 )
{
p0 -= 2 * L_SUBFR;
@@ -1461,7 +1485,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
FOR( i = 0; i < L_SUBFR; i++ )
{
#ifdef BASOP_NOGLOB
- y[i] = add_o( y[i], *p0++, &Overflow );
+ y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/
#else
y[i] = add( y[i], *p0++ );
#endif
@@ -1507,19 +1531,19 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
* void
*/
void E_ACELP_4t_fx(
- Word16 dn[],
+ Word16 dn[], /*Qdn*/
Word16 cn[] /* Q_xn */,
- Word16 H[],
- Word16 R[],
- Word8 acelpautoc,
- Word16 code[],
- Word16 cdk_index,
- Word16 _index[],
- const Word16 L_frame,
- const Word16 last_L_frame,
- const Word32 total_brate,
- const Word16 i_subfr,
- const int16_t cmpl_flag )
+ Word16 H[], /*Q12*/
+ Word16 R[], /*Qx*/
+ Word8 acelpautoc, /*Q0*/
+ Word16 code[], /*Q9*/
+ Word16 cdk_index, /*Q0*/
+ Word16 _index[], /*Q0*/
+ const Word16 L_frame, /*Q0*/
+ const Word16 last_L_frame, /*Q0*/
+ const Word32 total_brate, /*Q0*/
+ const Word16 i_subfr, /*Q0*/
+ const int16_t cmpl_flag /*Q0*/ )
{
PulseConfig config;
Word16 ind[NPMAXPT * 4];
@@ -1570,20 +1594,20 @@ void E_ACELP_4t_fx(
}
void E_ACELP_4t_ivas_fx(
- Word16 dn[],
+ Word16 dn[], /*Qdn*/
Word16 cn[] /* Q_xn */,
- Word16 H[],
- Word16 R[],
- Word8 acelpautoc,
- Word16 code[],
- Word16 cdk_index,
- Word16 _index[],
- const Word16 L_frame,
- const Word16 last_L_frame,
- const Word32 total_brate,
- const Word16 i_subfr,
- const int16_t cmpl_flag,
- Word16 element_mode )
+ Word16 H[], /*Q12*/
+ Word16 R[], /*Qx*/
+ Word8 acelpautoc, /*Q0*/
+ Word16 code[], /*Q9*/
+ Word16 cdk_index, /*Q0*/
+ Word16 _index[], /*Q0*/
+ const Word16 L_frame, /*Q0*/
+ const Word16 last_L_frame, /*Q0*/
+ const Word32 total_brate, /*Q0*/
+ const Word16 i_subfr, /*Q0*/
+ const int16_t cmpl_flag, /*Q0*/
+ Word16 element_mode /*Q0*/ )
{
PulseConfig config;
Word16 ind[NPMAXPT * 4];
@@ -1634,11 +1658,11 @@ void E_ACELP_4t_ivas_fx(
}
static void E_ACELP_indexing_shift(
- Word16 wordcnt, /* i: 16-bit word count including the newly shifted-in bits */
- Word16 shift_bits, /* i: number of bits to shift in from the lsb */
- UWord16 lsb_bits, /* i: bits to shift in from the lsb */
- const UWord16 src[], /* i: source buffer */
- UWord16 dst[] /* o: destination buffer */
+ Word16 wordcnt, /* i: 16-bit word count including the newly shifted-in bits Q0*/
+ Word16 shift_bits, /* i: number of bits to shift in from the lsb Q0*/
+ UWord16 lsb_bits, /* i: bits to shift in from the lsb Q0*/
+ const UWord16 src[], /* i: source buffer Q0*/
+ UWord16 dst[] /* o: destination buffer Q(shift_bits)*/
)
{
Word16 right_shift, i;
@@ -1649,10 +1673,10 @@ static void E_ACELP_indexing_shift(
FOR( i = sub( wordcnt, 1 ); i > 0; --i )
{
- dst[i] = s_or( lshl( src[i], shift_bits ), lshr( src[i - 1], right_shift ) );
+ dst[i] = s_or( lshl( src[i], shift_bits ), lshr( src[i - 1], right_shift ) ); /*Q0+shift_bits*/
move16();
}
- dst[i] = s_or( lshl( src[i], shift_bits ), lsb_bits );
+ dst[i] = s_or( lshl( src[i], shift_bits ), lsb_bits ); /*Q(shift_bits)*/
move16();
return;
}
@@ -1660,10 +1684,10 @@ static void E_ACELP_indexing_shift(
#define MAX_IDX_LEN 9
Word16 E_ACELP_indexing_fx(
- const Word16 code[],
+ const Word16 code[], /*Q9*/
const PulseConfig *config,
- Word16 num_tracks,
- Word16 prm[] )
+ Word16 num_tracks, /*Q0*/
+ Word16 prm[] /*Q(shift_bits)*/ )
{
Word16 track, shift_bits;
Word16 p[NB_TRACK_FCB_4T], wordcnt;
@@ -1716,6 +1740,7 @@ Word16 E_ACELP_indexing_fx(
if ( GT_16( p[3], p[1] ) )
{
track = add( track, 2 );
+ move16();
}
shift_bits = 2;
move16();
@@ -1788,15 +1813,15 @@ Word16 E_ACELP_indexing_fx(
void E_ACELP_adaptive_codebook(
Word16 *exc, /* i/o: pointer to the excitation frame Q_new */
Word16 T0, /* i : integer pitch lag Q0 */
- Word16 T0_frac, /* i : fraction of lag */
- Word16 T0_res, /* i : pitch resolution */
- Word16 T0_res_max, /* i : maximum pitch resolution */
- Word16 mode, /* i : filtering mode (0: no, 1: yes, 2: adaptive) */
+ Word16 T0_frac, /* i : fraction of lag Q0 */
+ Word16 T0_res, /* i : pitch resolution Q0 */
+ Word16 T0_res_max, /* i : maximum pitch resolution Q0 */
+ Word16 mode, /* i : filtering mode (0: no, 1: yes, 2: adaptive) Q0 */
Word16 i_subfr, /* i : subframe index */
- Word16 L_subfr, /* i : subframe length */
- Word16 L_frame, /* i : subframe length */
+ Word16 L_subfr, /* i : subframe length Q0 */
+ Word16 L_frame, /* i : subframe length Q0 */
Word16 *h1, /* i : impulse response of weighted synthesis filter 1Q14+shift */
- Word16 clip_gain, /* i : flag to indicate ??? */
+ Word16 clip_gain, /* i : flag to indicate ??? Q14 */
Word16 *xn, /* i : Close-loop Pitch search target vector Q_xn */
Word16 *y1, /* o : zero-memory filtered adaptive excitation Q_xn */
ACELP_CbkCorr *g_corr, /* o : ACELP correlation values */
@@ -1813,15 +1838,20 @@ void E_ACELP_adaptive_codebook(
Word16 y2[L_SUBFR], xn2[L_SUBFR], code[L_SUBFR];
ACELP_CbkCorr g_corr2;
Word16 gain1 = 0, gain2 = 0, fac_m, fac_n;
+ move16();
+ move16();
Word16 i, select, exp_ener;
Word32 L_tmp, L_ener;
const Word16 *pitch_inter;
Word16 pit_L_interpol, pit_up_samp;
Word16 use_prev_sf_pit_gain = 0;
+ move16();
- if ( rf_mode == 1 && rf_coder_type == 100 )
+ test();
+ IF( EQ_16( rf_mode, 1 ) && EQ_16( rf_coder_type, 100 ) )
{
use_prev_sf_pit_gain = 1;
+ move16();
}
BASOP_SATURATE_ERROR_ON_EVS;
@@ -1830,14 +1860,15 @@ void E_ACELP_adaptive_codebook(
/* find pitch excitation */
/*for &exc[i_subfr]*/
- if ( EQ_16( T0_res, shr( T0_res_max, 1 ) ) )
+ IF( EQ_16( T0_res, shr( T0_res_max, 1 ) ) )
{
- T0_frac = shl( T0_frac, 1 );
+ T0_frac = shl( T0_frac, 1 ); /*Q0*/
}
+ test();
IF( EQ_16( T0_res_max, 6 ) && rf_mode == 0 )
{
- pitch_inter = pitch_inter6_2;
+ pitch_inter = pitch_inter6_2; /*Q14*/
pit_L_interpol = PIT_L_INTERPOL6_2;
move16();
pit_up_samp = PIT_UP_SAMP6;
@@ -1845,7 +1876,7 @@ void E_ACELP_adaptive_codebook(
}
ELSE
{
- pitch_inter = pitch_inter4_2;
+ pitch_inter = pitch_inter4_2; /*Q14*/
pit_L_interpol = L_INTERPOL2;
move16();
pit_up_samp = PIT_UP_SAMP;
@@ -1861,22 +1892,23 @@ void E_ACELP_adaptive_codebook(
IF( use_prev_sf_pit_gain == 0 )
{
- gain1 = E_ACELP_xy1_corr( xn, y1, g_corr, 1, L_subfr, exp_xn );
+ gain1 = E_ACELP_xy1_corr_fx( xn, y1, g_corr, 1, L_subfr, exp_xn ); /*Q14*/
- /* clip gain if necessary to avoid problem at decoder */ test();
- if ( clip_gain && GT_16( gain1, 15565 /*0.95 Q14*/ ) )
+ /* clip gain if necessary to avoid problem at decoder */
+ test();
+ IF( clip_gain && GT_16( gain1, 15565 /*0.95 Q14*/ ) )
{
gain1 = 15565 /*0.95f Q14*/;
move16();
}
- *pitch_gain = gain1;
+ *pitch_gain = gain1; /*Q14*/
move16();
}
/* find energy of new target xn2[] */
- E_ACELP_codebook_target_update( xn, xn2, y1, gain1, L_subfr );
- L_ener = Dot_product12_offs( xn2, xn2, L_subfr, &exp_ener, 0 );
- L_ener = L_shr( L_ener, sub( 31, exp_ener ) );
+ E_ACELP_codebook_target_update_fx( xn, xn2, y1, gain1, L_subfr );
+ L_ener = Dot_product12_offs( xn2, xn2, L_subfr, &exp_ener, 0 ); /*Q31-exp_ener*/
+ L_ener = L_shr( L_ener, sub( 31, exp_ener ) ); /*Q0*/
}
/*-----------------------------------------------------------------*
@@ -1896,28 +1928,29 @@ void E_ACELP_adaptive_codebook(
move16();
}
/* fac_n = 0.5*(1.0-fac_m); */
- fac_n = mult_r( sub( 0x7FFF, fac_m ), 0x4000 );
+ fac_n = mult_r( sub( 0x7FFF, fac_m ), 0x4000 ); /*Q15*/
FOR( i = 0; i < L_subfr; i++ )
{
- L_tmp = L_mult( fac_n, exc[i - 1 + i_subfr] );
- L_tmp = L_mac( L_tmp, fac_m, exc[i + 0 + i_subfr] );
- code[i] = mac_r( L_tmp, fac_n, exc[i + 1 + i_subfr] );
+ L_tmp = L_mult( fac_n, exc[i - 1 + i_subfr] ); /*Q_new+Q16*/
+ L_tmp = L_mac( L_tmp, fac_m, exc[i + 0 + i_subfr] ); /*Q_new+Q16*/
+ code[i] = mac_r( L_tmp, fac_n, exc[i + 1 + i_subfr] ); /*Q_new*/
move16();
}
E_UTIL_f_convolve( code, h1, y2, L_subfr );
- gain2 = E_ACELP_xy1_corr( xn, y2, &g_corr2, 1, L_subfr, exp_xn );
+ gain2 = E_ACELP_xy1_corr_fx( xn, y2, &g_corr2, 1, L_subfr, exp_xn ); /*Q14*/
- /* clip gain if necessary to avoid problem at decoder */ test();
- if ( clip_gain && GT_16( gain2, 15565 /*0.95 Q14*/ ) )
+ /* clip gain if necessary to avoid problem at decoder */
+ test();
+ IF( clip_gain && GT_16( gain2, 15565 /*0.95 Q14*/ ) )
{
gain2 = 15565 /*0.95f Q14*/;
move16();
}
/* find energy of new target xn2[] */
- E_ACELP_codebook_target_update( xn, xn2, y2, gain2, L_subfr );
- L_tmp = Dot_product12_offs( xn2, xn2, L_subfr, &exp_ener, 0 );
- L_tmp = L_shr( L_tmp, sub( 31, exp_ener ) );
+ E_ACELP_codebook_target_update_fx( xn, xn2, y2, gain2, L_subfr );
+ L_tmp = Dot_product12_offs( xn2, xn2, L_subfr, &exp_ener, 0 ); /*Q31 - exp_ener*/
+ L_tmp = L_shr( L_tmp, sub( 31, exp_ener ) ); /*Q0*/
/*-----------------------------------------------------------------*
* use the best prediction (minimise quadratic error). *
@@ -1928,9 +1961,9 @@ void E_ACELP_adaptive_codebook(
/* use the lp filter for pitch excitation prediction */
select = LOW_PASS;
move16();
- Copy( code, &exc[i_subfr], L_subfr );
- Copy( y2, y1, L_subfr );
- *pitch_gain = gain2;
+ Copy( code, &exc[i_subfr], L_subfr ); /*Q_new*/
+ Copy( y2, y1, L_subfr ); /*Q_xn*/
+ *pitch_gain = gain2; /*Q14*/
move16();
g_corr->y1y1 = g_corr2.y1y1;
move16();
@@ -1946,7 +1979,7 @@ void E_ACELP_adaptive_codebook(
/* no filter used for pitch excitation prediction */
select = FULL_BAND;
move16();
- *pitch_gain = gain1;
+ *pitch_gain = gain1; /*Q14*/
move16();
}
@@ -1964,6 +1997,7 @@ void E_ACELP_adaptive_codebook(
move16();
}
*lp_select = select;
+ move16();
BASOP_SATURATE_ERROR_OFF_EVS;
}
@@ -1993,9 +2027,9 @@ void E_ACELP_innovative_codebook_fx(
Word16 **pt_indice, /* i/o: quantization indices pointer */
Word16 *code, /* o : innovative codebook Q9 Q9 */
Word16 shift, /* i : Scaling to get 12 bits */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 last_L_frame, /* i : length of the last frame */
- const Word32 total_brate /* i : ttoal bit-rate */
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 last_L_frame, /* i : length of the last frame Q0*/
+ const Word32 total_brate /* i : ttoal bit-rate Q0*/
)
{
Word16 xn2[L_SUBFR] /* Q_xn */, cn2[L_SUBFR] /* Q_xn */, dn[L_SUBFR] /* Rw2*cn2 */, h2[L_SUBFR] /* 4Q11 */;
@@ -2014,7 +2048,7 @@ void E_ACELP_innovative_codebook_fx(
BASOP_SATURATE_ERROR_ON_EVS;
/* Update target vector for ACELP codebook search */
- E_ACELP_codebook_target_update( xn, xn2, y1, pitch_gain, L_SUBFR );
+ E_ACELP_codebook_target_update_fx( xn, xn2, y1, pitch_gain, L_SUBFR );
/* Include fixed-gain pitch contribution into impulse resp. h1[] */
Copy_Scale_sig( h1, h2, L_SUBFR, sub( -3, shift ) ); /*h2 1Q14+shift -> 4Q11, 1bit of headroom for Residu and xh_corr*/
@@ -2036,7 +2070,7 @@ void E_ACELP_innovative_codebook_fx(
ELSE
{
BASOP_SATURATE_WARNING_OFF_EVS;
- E_ACELP_codebook_target_update( cn, cn2, &exc[i_subfr], pitch_gain, L_SUBFR );
+ E_ACELP_codebook_target_update_fx( cn, cn2, &exc[i_subfr], pitch_gain, L_SUBFR );
BASOP_SATURATE_WARNING_ON_EVS;
Scale_sig( cn2, L_SUBFR, shift );
E_ACELP_xh_corr( xn2, dn, h2, L_SUBFR );
@@ -2073,7 +2107,7 @@ void E_ACELP_innovative_codebook_fx(
* n - (output) range of possible states (0...n-1)
* p - (output) number of pulses found
*--------------------------------------------------------------------------*/
-static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Word16 *p )
+static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, UWord32 *ps /*Q0*/, Word16 *p /*Q0*/ )
{
Word16 k, nb_pulse, i, t, pos[NPMAXPT], posno;
Word16 sign, m;
@@ -2081,6 +2115,8 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
Flag Carry = 0;
+ move32();
+ move32();
#endif
/* Collect different pulse positions to pos[], number of them to posno */
@@ -2096,6 +2132,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
move16();
}
t = add( t, 1 );
+ move16();
if ( sub( posno, NPMAXPT ) >= 0 )
{
BREAK;
@@ -2110,13 +2147,14 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
move16();
FOR( k = 0; k < posno; ++k )
{
- sign = shr( v[shl( pos[k], 2 )], 9 ); /* sign with multiplicity */
- m = abs_s( sign ); /* multiplicity */
+ sign = shr( v[( pos[k] * 4 )], 9 ); /* sign with multiplicity Q0*/
+ m = abs_s( sign ); /* multiplicity */
nb_pulse = add( nb_pulse, m );
/* Code m-1 pulses */
FOR( i = 1; i < m; ++i )
{
Carry = 0;
+ move32();
#ifdef BASOP_NOGLOB
s = L_add_co( s, pulsestostates[pos[k]][t], &Carry, &Overflow );
#else /* BASOP_NOGLOB */
@@ -2133,6 +2171,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
/* We use L_add_c since we want to work with unsigned UWord32 */
/* Therefore, we have to clear carry */
Carry = 0;
+ move32();
s = L_lshl( s, 1 );
if ( sign < 0 )
{
@@ -2145,6 +2184,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
/* Code last pulse */
Carry = 0;
+ move32();
#ifdef BASOP_NOGLOB
s = L_add_co( s, pulsestostates[pos[k]][t], &Carry, &Overflow );
#else /* BASOP_NOGLOB */
@@ -2153,21 +2193,21 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
t = add( t, 1 );
}
- *ps = s;
+ *ps = s; /*Q0*/
move32();
*n = L_deposit_l( 0 );
if ( nb_pulse )
{
- *n = pulsestostates[NB_POS_FCB_4T][nb_pulse - 1];
+ *n = pulsestostates[NB_POS_FCB_4T][nb_pulse - 1]; /*Q0*/
move32();
}
- *p = nb_pulse;
+ *p = nb_pulse; /*Q0*/
move16();
return;
}
-void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num )
+void fcb_pulse_track_joint_fx( UWord16 *idxs /*Q0*/, Word16 wordcnt /*Q0*/, UWord32 *index_n /*Q0*/, Word16 *pulse_num /*Q0*/, Word16 track_num /*Q0*/ )
{
Word16 hi_to_low[10];
UWord32 index, index_mask;
@@ -2176,7 +2216,7 @@ void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n,
Word16 track, track_num1, pulse_num0, pulse_num1;
Word16 indx_flag_2;
- Copy( hi_to_low_tmpl, hi_to_low, 10 );
+ Copy( hi_to_low_tmpl, hi_to_low, 10 ); /*Q0*/
indx_flag = 0;
move16();
@@ -2196,7 +2236,7 @@ void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n,
{
hi_to_low[7] = 9;
move16();
- index_mask = 0xFFFFFF;
+ index_mask = 0xFFFFFF; /*Q0*/
move32();
}
ELSE
@@ -2206,34 +2246,35 @@ void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n,
hi_to_low[4] = 1;
move16();
}
- index_mask = L_shr( 0xFFFF, sub( 9, hi_to_low[4] ) );
+ index_mask = L_shr( 0xFFFF, sub( 9, hi_to_low[4] ) ); /*Q0*/
}
IF( GE_16( indx_flag_1, track_num ) )
{
indx_tmp = L_deposit_l( 0 );
- index = L_shr( index_n[0], low_len[pulse_num[0]] );
+ index = L_shr( index_n[0], low_len[pulse_num[0]] ); /*Q0*/
FOR( track = 1; track < track_num; track++ )
{
- pulse_num0 = pulse_num[track - 1];
+ pulse_num0 = pulse_num[track - 1]; /*Q0*/
move16();
- pulse_num1 = pulse_num[track];
+ pulse_num1 = pulse_num[track]; /*Q0*/
move16();
- indx_tmp = L_lshr( index_n[track], low_len[pulse_num1] );
+ indx_tmp = L_lshr( index_n[track], low_len[pulse_num1] ); /*Q0*/
/* index = index * indx_fact[pulse_num1] + indx_tmp; */
- index = UL_Mpy_32_32( index, UL_deposit_l( indx_fact[pulse_num1] ) );
+ index = UL_Mpy_32_32( index, UL_deposit_l( indx_fact[pulse_num1] ) ); /*Q0*/
index = UL_addNsD( index, indx_tmp );
index_n[track - 1] = L_add( L_and( index_n[track - 1], low_mask[pulse_num0] ),
- L_and( L_lshl( index, low_len[pulse_num0] ), index_mask ) );
+ L_and( L_lshl( index, low_len[pulse_num0] ), index_mask ) ); /*Q0*/
index = L_lshr( index, hi_to_low[pulse_num0] );
}
track_num1 = sub( track_num, 1 );
- pulse_num1 = pulse_num[track_num1];
+ move16();
+ pulse_num1 = pulse_num[track_num1]; /*Q0*/
move16();
index_n[track_num1] = L_and( L_add( L_and( index_n[track_num1], low_mask[pulse_num1] ),
L_lshl( index, low_len[pulse_num1] ) ),
- index_mask );
+ index_mask ); /*Q0*/
index = L_lshr( index, hi_to_low[pulse_num1] );
IF( GE_16( indx_flag, track_num ) )
{
@@ -2266,11 +2307,11 @@ void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n,
}
ELSE
{
- index = index_n[0];
+ index = index_n[0]; /*Q0*/
move32();
FOR( track = 1; track < 4; track++ )
{
- pulse_num1 = pulse_num[track];
+ pulse_num1 = pulse_num[track]; /*Q0*/
index = L_add( L_lshl( index, index_len[pulse_num1] ), index_n[track] );
}
track = 0;
diff --git a/lib_enc/enc_acelp_tcx_main_fx.c b/lib_enc/enc_acelp_tcx_main_fx.c
index 0ee3c51856af219d536d57f65af0ff536d9fa766..3498321646e22d98a77ebd738db6e55f43fdee03 100644
--- a/lib_enc/enc_acelp_tcx_main_fx.c
+++ b/lib_enc/enc_acelp_tcx_main_fx.c
@@ -18,15 +18,15 @@
* encoder function for coding ACELP/TCX
*--------------------------------------------------------------------*/
void enc_acelp_tcx_main_fx(
- const Word16 new_samples[], /* i : new samples */
- Encoder_State *st, /* i/o: encoder state structure */
- Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 lsp_new[M], /* i : LSPs at the end of the frame */
- const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame */
- Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 pitch_buf[], /* o : floating pitch for each subframe */
- Word16 vad_hover_flag, /* i : VAD hangover flag */
+ const Word16 new_samples[], /* i : new samples Q15*/
+ Encoder_State *st, /* i/o: encoder state structure */
+ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
+ const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame Q15*/
+ Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q_new*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 pitch_buf[], /* o : floating pitch for each subframe Q6*/
+ Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
Word16 *Q_new,
Word16 *shift )
{
@@ -39,7 +39,7 @@ void enc_acelp_tcx_main_fx(
IF( EQ_16( st->last_core, ACELP_CORE ) )
{
set16_fx( old_bwe_exc + PIT16k_MAX * 2, 0, ( ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 );
- Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 );
+ Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 ); /*Q_exc*/
}
ELSE
{
@@ -74,7 +74,7 @@ void enc_acelp_tcx_main_fx(
non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame );
/* update the old BWE exe memory */
- Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 );
+ Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/
}
ELSE
{
diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c
index af773cac453fa0e258ffb57e8936fc6cd0c5b302..99c9568ebfc47d055d81a3d9444bf5b7a4d30321 100644
--- a/lib_enc/enc_acelpx_fx.c
+++ b/lib_enc/enc_acelpx_fx.c
@@ -19,13 +19,13 @@
/*--------------------------------------------------------------------------------------*
* E_ACELP_update_cor
*--------------------------------------------------------------------------------------*/
-static void E_ACELP_update_cor(
- const Word16 pos[], /* i */
- Word16 nb_pulse, /* i */
- const Word16 sign[], /* i */
- const Word16 R[], /* i */
- const Word16 cor_in[], /* i */
- Word16 cor_out[] /* o */
+static void E_ACELP_update_cor_fx(
+ const Word16 pos[], /* i Q0*/
+ Word16 nb_pulse, /* i Q0*/
+ const Word16 sign[], /* i Q13*/
+ const Word16 R[], /* i Q9+scale*/
+ const Word16 cor_in[], /* i Q9*/
+ Word16 cor_out[] /* o Q9*/
)
{
Word16 sign_x, sign_y;
@@ -36,9 +36,9 @@ static void E_ACELP_update_cor(
{
/* Update product of autocorrelation and already fixed pulses. with the
* two newly found ones */
- sign_x = sign[pos[0]];
+ sign_x = sign[pos[0]]; /*Q13*/
move16();
- sign_y = sign[pos[1]];
+ sign_y = sign[pos[1]]; /*Q13*/
move16();
IF( s_xor( sign_x, sign_y ) < 0 )
@@ -50,24 +50,24 @@ static void E_ACELP_update_cor(
i = 0;
move16();
}
- pRx = R - pos[i];
- pRy = R - pos[1 - i];
+ pRx = R - pos[i]; /*Q9+scale*/
+ pRy = R - pos[1 - i]; /*Q9+scale*/
/* different sign x and y */
FOR( i = 0; i < L_SUBFR; i++ )
{
tmp = sub( pRx[i], pRy[i] );
if ( cor_in != NULL )
{
- tmp = add( tmp, cor_in[i] );
+ tmp = add( tmp, cor_in[i] ); /* Q9 */
}
- cor_out[i] = tmp;
+ cor_out[i] = tmp; /* Q9 */
move16();
}
}
ELSE
{
- pRx = R - pos[0];
- pRy = R - pos[1];
+ pRx = R - pos[0]; /*Q9+scale*/
+ pRy = R - pos[1]; /*Q9+scale*/
IF( sign_x > 0 )
{
/* sign x and y is positive */
@@ -76,9 +76,9 @@ static void E_ACELP_update_cor(
tmp = add( pRx[i], pRy[i] );
if ( cor_in != NULL )
{
- tmp = add( tmp, cor_in[i] );
+ tmp = add( tmp, cor_in[i] ); /* Q9 */
}
- cor_out[i] = tmp;
+ cor_out[i] = tmp; /* Q9 */
move16();
}
}
@@ -90,13 +90,13 @@ static void E_ACELP_update_cor(
tmp = add( pRx[i], pRy[i] );
if ( cor_in != NULL )
{
- tmp = sub( cor_in[i], tmp );
+ tmp = sub( cor_in[i], tmp ); /* Q9 */
}
if ( cor_in == NULL )
{
tmp = negate( tmp );
}
- cor_out[i] = tmp;
+ cor_out[i] = tmp; /* Q9 */
move16();
}
}
@@ -104,8 +104,8 @@ static void E_ACELP_update_cor(
}
ELSE IF( EQ_16( nb_pulse, 4 ) )
{
- E_ACELP_update_cor( pos, 2, sign, R, cor_in, cor_out );
- E_ACELP_update_cor( pos + 2, 2, sign, R, cor_out, cor_out );
+ E_ACELP_update_cor_fx( pos, 2, sign, R, cor_in, cor_out );
+ E_ACELP_update_cor_fx( pos + 2, 2, sign, R, cor_out, cor_out );
}
else
{
@@ -116,20 +116,20 @@ static void E_ACELP_update_cor(
* E_ACELP_2pulse_searchx
* Iterations: nb_pos_ix*16
*--------------------------------------------------------------------------------------*/
-static void E_ACELP_2pulse_searchx(
- const Word16 nb_pos_ix,
- const Word16 track_x,
- const Word16 track_y,
- Word16 *R,
- Word16 *ps,
- Word16 *alp,
- Word16 *ix,
- Word16 *iy,
- Word16 dn[],
- Word16 *dn2,
- Word16 cor[],
- Word16 sign[],
- Word16 sign_val_2 )
+static void E_ACELP_2pulse_searchx_fx(
+ const Word16 nb_pos_ix, /*Q0*/
+ const Word16 track_x, /*Q0*/
+ const Word16 track_y, /*Q0*/
+ Word16 *R, /*Q9+scale*/
+ Word16 *ps, /*Qdn*/
+ Word16 *alp, /*Q6*/
+ Word16 *ix, /*Q0*/
+ Word16 *iy, /*Q0*/
+ Word16 dn[], /*Qdn*/
+ Word16 *dn2, /*Q0*/
+ Word16 cor[], /*Q9*/
+ Word16 sign[], /*Q13*/
+ Word16 sign_val_2 /*Q15*/ )
{
Word16 i, x;
Word32 y;
@@ -141,18 +141,19 @@ static void E_ACELP_2pulse_searchx(
Word16 sqk[2], alpk[2], ik;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* eight dn2 max positions per track */
- pos_x = &dn2[shl( track_x, 3 )];
+ pos_x = &dn2[( track_x * 8 )]; /*Qdn*/
move16();
/* save these to limit memory searches */
- ps0 = *ps;
+ ps0 = *ps; /*Qdn*/
move16();
/*alp0 = *alp + 2.0f*R[0]; move16();*/
alp0 = L_deposit_h( *alp ); /* Qalp = Q_R*Q_signval */
#ifdef BASOP_NOGLOB
- alp0 = L_mac_sat( alp0, R[0], sign_val_2 );
+ alp0 = L_mac_sat( alp0, R[0], sign_val_2 ); /*Q9+scale+Q15*/
#else
alp0 = L_mac( alp0, R[0], sign_val_2 );
#endif
@@ -164,7 +165,7 @@ static void E_ACELP_2pulse_searchx(
move16();
x = pos_x[0];
move16();
- sgnx = sign[track_y];
+ sgnx = sign[track_y]; /*Q13*/
move16();
if ( sign[x] < 0 )
{
@@ -183,19 +184,19 @@ static void E_ACELP_2pulse_searchx(
ik = 0;
move16();
- xy_save = L_mac0( L_deposit_l( track_y ), track_x, L_SUBFR );
+ xy_save = L_mac0( L_deposit_l( track_y ), track_x, L_SUBFR ); /*Q0*/
/* loop track 1 */
FOR( i = 0; i < nb_pos_ix; i++ )
{
- x = pos_x[i];
+ x = pos_x[i]; /*Q0*/
move16();
- sgnx = sign[x];
+ sgnx = sign[x]; /*Q13*/
move16();
/* dn[x] has only nb_pos_ix positions saved */
/*ps1 = ps0 + dn[x]; INDIRECT(1);ADD(1);*/
#ifdef BASOP_NOGLOB
- ps1 = add_sat( ps0, dn[x] );
+ ps1 = add_sat( ps0, dn[x] ); /*Qdn*/
#else
ps1 = add( ps0, dn[x] );
#endif
@@ -205,13 +206,13 @@ static void E_ACELP_2pulse_searchx(
#else
alp1 = L_mac( alp0, cor[x], sgnx ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#endif
- pR = R - x;
+ pR = R - x; /*Q9+scale*/
FOR( y = track_y; y < L_SUBFR; y += 4 )
{
/*ps2 = ps1 + dn[y]; ADD(1);*/
#ifdef BASOP_NOGLOB
- ps2 = add_sat( ps1, dn[y] );
+ ps2 = add_sat( ps1, dn[y] ); /*Qdn*/
#else
ps2 = add( ps1, dn[y] );
#endif
@@ -244,12 +245,12 @@ static void E_ACELP_2pulse_searchx(
alp2_16 = msu_r( alp2, pR[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#endif
}
- alpk[1 - ik] = alp2_16;
+ alpk[1 - ik] = alp2_16; /* Qalp */
move16();
/*sq = ps2 * ps2; MULT(1);*/
sq = mult_r( ps2, ps2 ); /* (3+3)Q -> 6Q9 */
- sqk[1 - ik] = sq;
+ sqk[1 - ik] = sq; /* Q9 */
move16();
@@ -265,7 +266,7 @@ static void E_ACELP_2pulse_searchx(
}
if ( s > 0 )
{
- xy_save = L_mac0( y, x, L_SUBFR );
+ xy_save = L_mac0( y, x, L_SUBFR ); /* Q0 */
}
assert( ( ( s >= 0 && i == 0 && y == track_y ) ) || ( y > track_y ) || ( i > 0 ) );
}
@@ -273,21 +274,21 @@ static void E_ACELP_2pulse_searchx(
ps1 = extract_l( xy_save );
pos[1] = s_and( ps1, L_SUBFR - 1 );
move16();
- pos[0] = lshr( ps1, 6 );
+ pos[0] = lshr( ps1, 6 ); /* Q0 */
move16();
/* Update numerator */
- *ps = add( add( ps0, dn[pos[0]] ), dn[pos[1]] );
+ *ps = add( add( ps0, dn[pos[0]] ), dn[pos[1]] ); /* Qdn */
move16();
/* Update denominator */
- *alp = alpk[ik];
+ *alp = alpk[ik]; /* Q_alp */
move16();
- E_ACELP_update_cor( pos, 2, sign, R, cor, cor );
+ E_ACELP_update_cor_fx( pos, 2, sign, R, cor, cor );
- *ix = pos[0];
+ *ix = pos[0]; /* Q0 */
move16();
- *iy = pos[1];
+ *iy = pos[1]; /* Q0 */
move16();
assert( ( ( pos[0] & 3 ) == track_x ) && ( ( pos[1] & 3 ) == track_y ) ); /* sanity check */
@@ -296,16 +297,16 @@ static void E_ACELP_2pulse_searchx(
/*--------------------------------------------------------------------------------------*
* E_ACELP_1pulse_searchx
*--------------------------------------------------------------------------------------*/
-static void E_ACELP_1pulse_searchx(
- UWord8 tracks[2],
- Word16 *R,
- Word16 *ps,
- Word16 *alp,
- Word16 *ix,
- Word16 dn[],
- Word16 cor[],
- Word16 sign[],
- Word16 sign_val_1 )
+static void E_ACELP_1pulse_searchx_fx(
+ UWord8 tracks[2], /*Q0*/
+ Word16 *R, /*Q9+scale*/
+ Word16 *ps, /* Qdn */
+ Word16 *alp, /*Q6*/
+ Word16 *ix, /*Q0*/
+ Word16 dn[], /* Qdn */
+ Word16 cor[], /* Q9 */
+ Word16 sign[], /* Q13 */
+ Word16 sign_val_1 /* Q15 */ )
{
Word16 x, x_save = 0;
Word16 ps0;
@@ -315,14 +316,16 @@ static void E_ACELP_1pulse_searchx(
Word32 s;
Word16 ntracks, t;
Word16 sqk[2], alpk[2], ik;
+ move16();
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* save these to limit memory searches */
/*alp0 = *alp + R[0]; INDIRECT(1);*/
- ps0 = *ps;
+ ps0 = *ps; /* Qdn */
move16();
- alp0 = L_deposit_h( *alp );
+ alp0 = L_deposit_h( *alp ); /* Q22 */
alp0 = L_mac( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */
/* Ensure that in the loop below s > 0 in the first iteration, the actual values do not matter. */
@@ -342,10 +345,11 @@ static void E_ACELP_1pulse_searchx(
move16();
}
- x_save = tracks[0];
+ x_save = tracks[0]; /* Q0 */
move16();
ntracks = 1;
+ move16();
if ( NE_16( tracks[1], tracks[0] ) )
{
ntracks = 2;
@@ -364,18 +368,18 @@ static void E_ACELP_1pulse_searchx(
#else
alp1 = mac_r( alp0, cor[x], sign[x] ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#endif
- alpk[1 - ik] = alp1;
+ alpk[1 - ik] = alp1; /* Qalp */
move16();
/*sq = ps1 * ps1; MULT(1);*/
sq = mult_r( ps1, ps1 ); /* 6Q9 */
- sqk[1 - ik] = sq;
+ sqk[1 - ik] = sq; /* Q9 */
move16();
/*s = (alpk[ik] * sq) - (sqk[ik] * alp1); MULT(1);MAC(1);*/
#ifdef BASOP_NOGLOB
- s = L_msu_o( L_mult_o( alpk[ik], sq, &Overflow ), sqk[ik], alp1, &Overflow );
+ s = L_msu_o( L_mult_o( alpk[ik], sq, &Overflow ), sqk[ik], alp1, &Overflow ); /* Q9+Qalp+1 */
#else
s = L_msu( L_mult( alpk[ik], sq ), sqk[ik], alp1 );
#endif
@@ -392,11 +396,11 @@ static void E_ACELP_1pulse_searchx(
}
}
- *ps = add( ps0, dn[x_save] );
+ *ps = add( ps0, dn[x_save] ); /* Qdn */
move16();
- *alp = alpk[ik];
+ *alp = alpk[ik]; /* Qalp */
move16();
- *ix = x_save;
+ *ix = x_save; /* Q0 */
move16();
}
@@ -406,12 +410,12 @@ static void E_ACELP_1pulse_searchx(
* Algorithm is identical to traditional covariance method
*--------------------------------------------------------------------------------------*/
void E_ACELP_4tsearchx_fx(
- Word16 dn[],
- const Word16 cn[],
- Word16 Rw[],
- Word16 code[],
+ Word16 dn[], /*Qdn*/
+ const Word16 cn[], /*Q_new*/
+ Word16 Rw[], /*Q9*/
+ Word16 code[], /*Q9*/
const PulseConfig *config,
- Word16 ind[] )
+ Word16 ind[] /*Q0*/ )
{
Word16 sign[L_SUBFR], vec[L_SUBFR];
Word16 cor[L_SUBFR];
@@ -427,8 +431,11 @@ void E_ACELP_4tsearchx_fx(
Word16 scale;
Word16 sign_val_1, sign_val_2;
Word16 nb_pulse, nb_pulse_m2;
+ move16();
+ move16();
ps = 0; /* to avoid compilation warnings */
+ move16();
alp = config->alp; /* Q13 */
@@ -447,10 +454,10 @@ void E_ACELP_4tsearchx_fx(
scale = 0;
move16();
- s = L_mult0( Rw[0], Rw[0] );
+ s = L_mult0( Rw[0], Rw[0] ); /*Q18*/
FOR( i = 1; i < L_SUBFR; i++ )
{
- s = L_mac0( s, Rw[i], Rw[i] );
+ s = L_mac0( s, Rw[i], Rw[i] ); /*Q18*/
}
if ( s_and( (Word16) GE_16( nb_pulse, 9 ), (Word16) GT_32( s, 0x800000 ) ) )
{
@@ -493,7 +500,7 @@ void E_ACELP_4tsearchx_fx(
/* Set up autocorrelation vector */
R = R_buf + L_SUBFR - 1;
- Copy_Scale_sig( Rw, R, L_SUBFR, scale );
+ Copy_Scale_sig( Rw, R, L_SUBFR, scale ); /*Q9+scale*/
FOR( k = 1; k < L_SUBFR; k++ )
{
R[-k] = R[k];
@@ -501,13 +508,13 @@ void E_ACELP_4tsearchx_fx(
}
/* Sign value */
- sign_val_2 = 0x2000;
+ sign_val_2 = 0x2000; /* Q15 */
move16();
if ( GE_16( nb_pulse, 24 ) )
{
- sign_val_2 = shr( sign_val_2, 1 );
+ sign_val_2 = shr( sign_val_2, 1 ); /* Q15 */
}
- sign_val_1 = shr( sign_val_2, 1 );
+ sign_val_1 = shr( sign_val_2, 1 ); /* Q15 */
/*
* Find sign for each pulse position.
@@ -535,7 +542,7 @@ void E_ACELP_4tsearchx_fx(
E_ACELP_setup_pulse_search_pos( config, k, ipos );
/* index to first non-fixed position */
- pos = config->fixedpulses;
+ pos = config->fixedpulses; /* Q0 */
move16();
IF( config->fixedpulses == 0 ) /* 1100, 11, 1110, 1111, 2211 */
@@ -553,23 +560,23 @@ void E_ACELP_4tsearchx_fx(
/* set fixed positions */
FOR( i = 0; i < pos; ++i )
{
- ind[i] = pos_max[ipos[i]];
+ ind[i] = pos_max[ipos[i]]; /* Q0 */
move16();
}
/* multiplication of autocorrelation with signed fixed pulses */
- E_ACELP_update_cor( ind, config->fixedpulses, sign, R, NULL, cor );
+ E_ACELP_update_cor_fx( ind, config->fixedpulses, sign, R, NULL, cor );
/* normalisation contribution of fixed part */
- s = L_mult0( cor[ind[0]], sign[ind[0]] );
- ps = dn[ind[0]];
+ s = L_mult0( cor[ind[0]], sign[ind[0]] ); /* Q22 */
+ ps = dn[ind[0]]; /* Qdn */
move16();
FOR( i = 1; i < pos; ++i )
{
- s = L_mac0( s, cor[ind[i]], sign[ind[i]] ); /*Q12+Q9+1=Q6 */
- ps = add( ps, dn[ind[i]] );
+ s = L_mac0( s, cor[ind[i]], sign[ind[i]] ); /*Q12+Q9+1=Q22 */
+ ps = add( ps, dn[ind[i]] ); /* Qdn */
}
- alp = round_fx( s ); /*mac0 >>1 sign = 2*/
+ alp = round_fx( s ); /*mac0 >>1 sign = 2 Q6*/
}
/* other stages of 2 pulses */
@@ -585,13 +592,13 @@ void E_ACELP_4tsearchx_fx(
* Each pulse can have 16 possible positions.
*/
- E_ACELP_2pulse_searchx( config->nbpos[st], ipos[j], ipos[j + 1], R, &ps, &alp,
- &ind[j], &ind[j + 1], dn, dn2_pos, cor, sign, sign_val_2 );
+ E_ACELP_2pulse_searchx_fx( config->nbpos[st], ipos[j], ipos[j + 1], R, &ps, &alp,
+ &ind[j], &ind[j + 1], dn, dn2_pos, cor, sign, sign_val_2 );
}
ELSE /* single pulse search */
{
- E_ACELP_1pulse_searchx( &ipos[j], R, &ps, &alp,
- &ind[j], dn, cor, sign, sign_val_1 );
+ E_ACELP_1pulse_searchx_fx( &ipos[j], R, &ps, &alp,
+ &ind[j], dn, cor, sign, sign_val_1 );
}
@@ -600,10 +607,10 @@ void E_ACELP_4tsearchx_fx(
/* memorise the best codevector */
/*ps2 = ps * ps; MULT(1);*/
- ps2 = mult( ps, ps );
+ ps2 = mult( ps, ps ); /* 2*Qdn+1 */
/*s = (alpk * ps2) - (ps2k * alp); MULT(2);ADD(1);*/
- s = L_msu( L_mult( alpk, ps2 ), ps2k, alp );
+ s = L_msu( L_mult( alpk, ps2 ), ps2k, alp ); /* 2*Qdn+8 */
IF( s > 0 )
{
@@ -611,7 +618,7 @@ void E_ACELP_4tsearchx_fx(
move16();
alpk = alp;
move16();
- Copy( ind, codvec, nb_pulse );
+ Copy( ind, codvec, nb_pulse ); /* Q0 */
}
}
@@ -623,12 +630,12 @@ void E_ACELP_4tsearchx_fx(
}
void E_ACELP_4tsearchx_ivas_fx(
- Word16 dn[],
- const Word16 cn[],
- Word16 Rw[],
- Word16 code[],
+ Word16 dn[], /*Qdn*/
+ const Word16 cn[], /*Q_new*/
+ Word16 Rw[], /*Q9*/
+ Word16 code[], /*Q9*/
const PulseConfig *config,
- Word16 ind[],
+ Word16 ind[], /*Q0*/
Word16 element_mode )
{
Word16 sign[L_SUBFR], vec[L_SUBFR];
@@ -670,10 +677,10 @@ void E_ACELP_4tsearchx_ivas_fx(
scale = 0;
move16();
- s = L_mult0( Rw[0], Rw[0] );
+ s = L_mult0( Rw[0], Rw[0] ); /* Q18 */
FOR( i = 1; i < L_SUBFR; i++ )
{
- s = L_mac0( s, Rw[i], Rw[i] );
+ s = L_mac0( s, Rw[i], Rw[i] ); /* Q18 */
}
if ( s_and( (Word16) GE_16( nb_pulse, 9 ), (Word16) GT_32( s, 0x800000 ) ) )
{
@@ -716,7 +723,7 @@ void E_ACELP_4tsearchx_ivas_fx(
/* Set up autocorrelation vector */
R = R_buf + L_SUBFR - 1;
- Copy_Scale_sig( Rw, R, L_SUBFR, scale );
+ Copy_Scale_sig( Rw, R, L_SUBFR, scale ); /* Q9 + scale */
FOR( k = 1; k < L_SUBFR; k++ )
{
R[-k] = R[k];
@@ -724,13 +731,13 @@ void E_ACELP_4tsearchx_ivas_fx(
}
/* Sign value */
- sign_val_2 = 0x2000;
+ sign_val_2 = 0x2000; /* Q15 */
move16();
if ( GE_16( nb_pulse, 24 ) )
{
- sign_val_2 = shr( sign_val_2, 1 );
+ sign_val_2 = shr( sign_val_2, 1 ); /* Q15 */
}
- sign_val_1 = shr( sign_val_2, 1 );
+ sign_val_1 = shr( sign_val_2, 1 ); /* Q15 */
/*
* Find sign for each pulse position.
@@ -758,7 +765,7 @@ void E_ACELP_4tsearchx_ivas_fx(
E_ACELP_setup_pulse_search_pos( config, k, ipos );
/* index to first non-fixed position */
- pos = config->fixedpulses;
+ pos = config->fixedpulses; /* Q0 */
move16();
IF( config->fixedpulses == 0 ) /* 1100, 11, 1110, 1111, 2211 */
@@ -776,23 +783,23 @@ void E_ACELP_4tsearchx_ivas_fx(
/* set fixed positions */
FOR( i = 0; i < pos; ++i )
{
- ind[i] = pos_max[ipos[i]];
+ ind[i] = pos_max[ipos[i]]; /* Q0 */
move16();
}
/* multiplication of autocorrelation with signed fixed pulses */
- E_ACELP_update_cor( ind, config->fixedpulses, sign, R, NULL, cor );
+ E_ACELP_update_cor_fx( ind, config->fixedpulses, sign, R, NULL, cor );
/* normalisation contribution of fixed part */
- s = L_mult0( cor[ind[0]], sign[ind[0]] );
- ps = dn[ind[0]];
+ s = L_mult0( cor[ind[0]], sign[ind[0]] ); /* Q22 */
+ ps = dn[ind[0]]; /* Qdn */
move16();
FOR( i = 1; i < pos; ++i )
{
- s = L_mac0( s, cor[ind[i]], sign[ind[i]] ); /*Q12+Q9+1=Q6 */
+ s = L_mac0( s, cor[ind[i]], sign[ind[i]] ); /*Q12+Q9+1=Q22 */
ps = add( ps, dn[ind[i]] );
}
- alp = round_fx( s ); /*mac0 >>1 sign = 2*/
+ alp = round_fx( s ); /*mac0 >>1 sign = 2 Q6*/
}
/* other stages of 2 pulses */
@@ -808,24 +815,24 @@ void E_ACELP_4tsearchx_ivas_fx(
* Each pulse can have 16 possible positions.
*/
- E_ACELP_2pulse_searchx( config->nbpos[st], ipos[j], ipos[j + 1], R, &ps, &alp,
- &ind[j], &ind[j + 1], dn, dn2_pos, cor, sign, sign_val_2 );
+ E_ACELP_2pulse_searchx_fx( config->nbpos[st], ipos[j], ipos[j + 1], R, &ps, &alp,
+ &ind[j], &ind[j + 1], dn, dn2_pos, cor, sign, sign_val_2 );
}
ELSE /* single pulse search */
{
- E_ACELP_1pulse_searchx( &ipos[j], R, &ps, &alp,
- &ind[j], dn, cor, sign, sign_val_1 );
+ E_ACELP_1pulse_searchx_fx( &ipos[j], R, &ps, &alp,
+ &ind[j], dn, cor, sign, sign_val_1 );
}
IF( GT_16( alp, ONE_IN_Q14 ) )
{
alp = shr( alp, 1 );
- Scale_sig( cor, L_SUBFR, -1 );
- Scale_sig( R_buf, 2 * L_SUBFR - 1, -1 );
+ Scale_sig( cor, L_SUBFR, -1 ); /*Q8*/
+ Scale_sig( R_buf, 2 * L_SUBFR - 1, -1 ); /*Q8+scale*/
#ifndef MSAN_FIX
Scale_sig( dn, 2 * L_SUBFR, -1 );
#else
- Scale_sig( dn, L_SUBFR, -1 );
+ Scale_sig( dn, L_SUBFR, -1 ); /*Qdn-1*/
#endif
}
@@ -835,10 +842,10 @@ void E_ACELP_4tsearchx_ivas_fx(
/* memorise the best codevector */
/*ps2 = ps * ps; MULT(1);*/
- ps2 = mult( ps, ps );
+ ps2 = mult( ps, ps ); /* 2*Qdn+1 */
/*s = (alpk * ps2) - (ps2k * alp); MULT(2);ADD(1);*/
- s = L_msu( L_mult( alpk, ps2 ), ps2k, alp );
+ s = L_msu( L_mult( alpk, ps2 ), ps2k, alp ); /* 2*Qdn+8 */
IF( s > 0 )
{
@@ -848,7 +855,7 @@ void E_ACELP_4tsearchx_ivas_fx(
move16();
alpk = alp;
move16();
- Copy( ind, codvec, nb_pulse );
+ Copy( ind, codvec, nb_pulse ); /*Q0*/
}
}
@@ -868,9 +875,9 @@ void E_ACELP_4tsearchx_ivas_fx(
FOR( k = 0; k < config->nb_pulse; k++ )
{
- i = codvec[k]; /* read pulse position */
+ i = codvec[k]; /* read pulse position Q0*/
move16();
- val = sign[i]; /* read sign */
+ val = sign[i]; /* read sign Q13*/
move16();
index = shr( i, 2 ); /* pos of pulse (0..15) */
@@ -878,16 +885,16 @@ void E_ACELP_4tsearchx_ivas_fx(
track = s_and( i, 3 );
IF( L_mult0( val, psk ) > 0 )
{
- code[i] = add( code[i], ONE_IN_Q9 /*1.0f*/ );
+ code[i] = add( code[i], ONE_IN_Q9 /*1.0f*/ ); /* Q9 */
move16();
- codvec[k] = add( codvec[k], 2 * L_SUBFR );
+ codvec[k] = add( codvec[k], 2 * L_SUBFR ); /* Q0 */
move16();
}
ELSE
{
- code[i] = sub( code[i], ONE_IN_Q9 /*1.0f*/ );
+ code[i] = sub( code[i], ONE_IN_Q9 /*1.0f*/ ); /* Q9 */
move16();
- index = add( index, 16 );
+ index = add( index, 16 ); /* Q0 */
}
i = imult1616( track, NPMAXPT );
diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c
index 5d5ee6c48af075fa34ded5aadf29b936f275607e..edc04bc832fa4f64ef737883f5d9c6ed83b0e5ef 100644
--- a/lib_enc/enc_amr_wb_fx.c
+++ b/lib_enc/enc_amr_wb_fx.c
@@ -18,16 +18,16 @@
*-------------------------------------------------------------------*/
void encod_amr_wb_fx(
Encoder_State *st, /* i/o: state structure */
- const Word16 speech[], /* i : input speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 *res, /* i : residual signal */
- Word16 *syn, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *exc2, /* i/o: current enhanced excitation */
- Word16 *pitch_buf, /* i/o: floating pitch values for each subframe */
- Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */
- const Word16 *speech16k_fx, /* i : input speech @16kHz */
+ const Word16 speech[], /* i : input speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *syn, /* i/o: core synthesis st->Q_syn*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2, /* i/o: current enhanced excitation Q_new*/
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/
+ const Word16 *speech16k_fx, /* i : input speech @16kHz Qx*/
Word16 shift,
Word16 Q_new )
{
@@ -66,6 +66,7 @@ void encod_amr_wb_fx(
LPD_state_HANDLE hLPDmem = st->hLPDmem;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*------------------------------------------------------------------*
@@ -84,31 +85,33 @@ void encod_amr_wb_fx(
unbits = 0;
move16();
- p_Aw = Aw;
- p_Aq = Aq;
- pt_pitch = pitch_buf;
+ p_Aw = Aw; /*Q12*/
+ p_Aq = Aq; /*Q12*/
+ pt_pitch = pitch_buf; /*Q6*/
shift_wsp = add( Q_new, shift );
- Copy( st->pitch, T_op, 2 );
+ Copy( st->pitch, T_op, 2 ); /*Q0*/
if ( LE_16( T_op[0], PIT_MIN ) )
{
- T_op[0] = shl( T_op[0], 1 );
+ T_op[0] = shl( T_op[0], 1 ); /*Q0*/
move16();
}
if ( LE_16( T_op[1], PIT_MIN ) )
{
/*T_op[1] *= 2;*/
- T_op[1] = shl( T_op[1], 1 );
+ T_op[1] = shl( T_op[1], 1 ); /*Q0*/
move16();
}
st->acelp_cfg.fcb_mode = 0; /* flag used in inov_encode() */
+ move16();
/*-----------------------------------------------------------------*
* Select LP filtering flag
*-----------------------------------------------------------------*/
lp_flag = NORMAL_OPERATION;
+ move16();
if ( LT_32( st->core_brate, ACELP_11k60 ) )
{
lp_flag = LOW_PASS;
@@ -126,7 +129,7 @@ void encod_amr_wb_fx(
* target in residual domain "cn"
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res[i_subfr], &exc[i_subfr], L_SUBFR );
+ Copy( &res[i_subfr], &exc[i_subfr], L_SUBFR ); /*Q_new*/
find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
res, L_SUBFR, p_Aw, TILT_FAC_FX, xn, cn, h1 );
@@ -186,18 +189,19 @@ void encod_amr_wb_fx(
gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx );
#ifdef BASOP_NOGLOB
Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx_o( Lgcode, &Overflow );
-#else /* BASOP_NOGLOB */
+ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/
+#else /* BASOP_NOGLOB */
Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
gcode16 = round_fx( Lgcode );
-#endif /* BASOP_NOGLOB */
+#endif /* BASOP_NOGLOB */
- hLPDmem->tilt_code = Est_tilt2( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, shift );
+ hLPDmem->tilt_code = Est_tilt2( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, shift ); /*Q15*/
FOR( i = 0; i < L_SUBFR; i++ )
{
#ifdef BASOP_NOGLOB
- exc2[i + i_subfr] = round_fx_o( L_shl_o( L_mult( gain_pit, exc[i + i_subfr] ), 1, &Overflow ), &Overflow );
+ exc2[i + i_subfr] = round_fx_o( L_shl_o( L_mult( gain_pit, exc[i + i_subfr] ), 1, &Overflow ), &Overflow ); /*Q_new*/
+ move16();
#else /* BASOP_NOGLOB */
exc2[i + i_subfr] = round_fx( L_shl( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) );
#endif /* BASOP_NOGLOB */
@@ -208,14 +212,15 @@ void encod_amr_wb_fx(
*-----------------------------------------------------------------*/
/*st->mem_w0 = xn[L_SUBFR-1] - gain_pit * y1[L_SUBFR-1] - gain_code * y2[L_SUBFR-1];*/
- Ltmp = L_mult( gcode16, y2[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
+ Ltmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /*Q10*/
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15 - shift*/
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 );
- Ltmp = L_msu( Ltmp, y1[L_SUBFR - 1], gain_pit );
+ Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */
+ Ltmp = L_msu( Ltmp, y1[L_SUBFR - 1], gain_pit /*Q14*/ ); /* Q_new-1+shift+14+1 */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new+15 */
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ move16();
#else
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
@@ -225,17 +230,18 @@ void encod_amr_wb_fx(
*-----------------------------------------------------------------*/
FOR( i = 0; i < L_SUBFR; i++ )
{
- L_tmp = L_mult( gcode16, code[i] );
+ L_tmp = L_mult( gcode16, code[i] ); /*Q10*/
#ifdef BASOP_NOGLOB
- L_tmp = L_shl_sat( L_tmp, 5 );
- L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit );
+ L_tmp = L_shl_sat( L_tmp, 5 ); /*Q15*/
+ L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit ); /* Q_new+15 */
#else
L_tmp = L_shl( L_tmp, 5 );
L_tmp = L_mac( L_tmp, exc[i + i_subfr], gain_pit );
#endif
#ifdef BASOP_NOGLOB
- L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow );
+ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q_new+15*/
+ exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /*Q_new*/
+ move16();
#else /* BASOP_NOGLOB */
L_tmp = L_shl( L_tmp, 1 ); /* saturation can occur here */
exc[i + i_subfr] = round_fx( L_tmp );
diff --git a/lib_enc/enc_gain_fx.c b/lib_enc/enc_gain_fx.c
index 3bf3db1aa705c07972ac8d67bb437604ce668cdb..7c9606cfc24bcf592bfd1a0390ea625645414b50 100644
--- a/lib_enc/enc_gain_fx.c
+++ b/lib_enc/enc_gain_fx.c
@@ -14,7 +14,7 @@
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
-void E_GAIN_norm_corr( Word16 exc[], Word16 xn[], Word16 h[], Word16 t_min, Word16 t_max, Word16 corr_norm[], Word16 L_subfr );
+void E_GAIN_norm_corr_fx( Word16 exc[] /*Q_new*/, Word16 xn[] /*(Q_new+shift-1)*/, Word16 h[] /*(Q14+shift)*/, Word16 t_min, Word16 t_max, Word16 corr_norm[] /*(Q15+(Q_new+shift-1)+scale)*/, Word16 L_subfr );
/*
* E_GAIN_norm_corr
@@ -36,7 +36,7 @@ void E_GAIN_norm_corr( Word16 exc[], Word16 xn[], Word16 h[], Word16 t_min, Word
* Returns:
* void
*/
-void E_GAIN_norm_corr( Word16 exc[], Word16 xn[], Word16 h[], Word16 t_min, Word16 t_max, Word16 corr_norm[], Word16 L_subfr )
+void E_GAIN_norm_corr_fx( Word16 exc[] /*Q_new*/, Word16 xn[] /*(Q_new+shift-1)*/, Word16 h[] /*(Q14+shift)*/, Word16 t_min, Word16 t_max, Word16 corr_norm[] /*(Q15+(Q_new+shift-1)+scale)*/, Word16 L_subfr )
{
Word16 excf[L_SUBFR]; /* filtered past excitation (Q_new+shift-1) */
Word16 ps, norm, exp_alp, exp_ps, scale, L_subfr2;
@@ -53,7 +53,8 @@ void E_GAIN_norm_corr( Word16 exc[], Word16 xn[], Word16 h[], Word16 t_min, Word
/* Compute rounded down 1/sqrt(energy of xn[]) */
Dot_product12_offs( xn, xn, L_subfr, &scale, 1 );
- scale = add( scale, 2 + 1 ); /* energy of xn[] x 2 + rounded up */
+ scale = add( scale, 2 + 1 ); /* energy of xn[] x 2 + rounded up */
+ move16();
scale = negate( shr( scale, 1 ) ); /* (1< 0 )
{
t0_min = add( t0_min, 1 );
+ move16();
}
t_min = sub( t0_min, L_INTERPOL1 );
t_max = add( t0_max, L_INTERPOL1 );
+ move16();
+ move16();
/* allocate memory to normalized correlation vector */
corr = &corr_v[negate( t_min )]; /* corr[t_min..t_max] */
/* Compute normalized correlation between target and filtered excitation */
- E_GAIN_norm_corr( exc, xn, h, t_min, t_max, corr_v, L_subfr );
+ E_GAIN_norm_corr_fx( exc, xn, h, t_min, t_max, corr_v, L_subfr );
/* find integer pitch */
- max = corr[t0_min];
+ max = corr[t0_min]; /*(Q15+(Q_new+shift-1)+scale)*/
move16();
- t0 = t0_min;
+ t0 = t0_min; /*Q0*/
move16();
FOR( i = t0_min + 1; i <= t0_max; i++ )
@@ -306,26 +310,28 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
IF( EQ_16( t0_min_max_res, shr( pit_res_max, 1 ) ) )
{
- t0_min_frac = shl( t0_min_frac, 1 );
- t0_max_frac = shl( t0_max_frac, 1 );
+ t0_min_frac = shl( t0_min_frac, 1 ); /*Q0*/
+ t0_max_frac = shl( t0_max_frac, 1 ); /*Q0*/
}
step = 1;
- frac1 = sub( 1, pit_res_max );
- frac2 = sub( pit_res_max, 1 );
+ move16();
+ frac1 = sub( 1, pit_res_max ); /*Q0*/
+ frac2 = sub( pit_res_max, 1 ); /*Q0*/
test();
test();
IF( ( ( i_subfr == 0 ) && GE_16( t0, pit_fr2 ) ) || LE_16( pit_fr2, pit_min ) )
{
step = 2;
- frac1 = sub( 2, pit_res_max );
- frac2 = sub( pit_res_max, 2 );
+ move16();
+ frac1 = sub( 2, pit_res_max ); /*Q0*/
+ frac2 = sub( pit_res_max, 2 ); /*Q0*/
}
test();
IF( ( EQ_16( t0, t0_min ) ) && ( t0_min_frac == 0 ) )
{
- frac1 = t0_min_frac;
+ frac1 = t0_min_frac; /*Q0*/
move16();
}
ELSE
@@ -333,28 +339,29 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
test();
IF( ( EQ_16( t0, t0_min ) ) && ( LT_16( add( frac1, pit_res_max ), t0_min_frac ) ) )
{
- frac1 = sub( t0_min_frac, pit_res_max );
+ frac1 = sub( t0_min_frac, pit_res_max ); /*Q0*/
}
}
if ( EQ_16( t0, t0_max ) )
{
- frac2 = t0_max_frac;
+ frac2 = t0_max_frac; /*Q0*/
move16();
}
assert( frac1 <= 0 && frac2 >= 0 && frac2 > frac1 );
IF( EQ_16( pit_res_max, 6 ) )
{
- cor_max = E_GAIN_norm_corr_interpolate6( &corr[t0], frac1 );
- fraction = frac1;
+ cor_max = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/
+ fraction = frac1; /*Q0*/
+ move16();
FOR( i = ( frac1 + step ); i <= frac2; i += step )
{
- temp = E_GAIN_norm_corr_interpolate6( &corr[t0], i );
+ temp = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/
IF( GT_16( temp, cor_max ) )
{
- cor_max = temp;
+ cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/
move16();
fraction = i;
move16();
@@ -363,15 +370,16 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
}
ELSE
{
- cor_max = E_GAIN_norm_corr_interpolate( &corr[t0], frac1 );
- fraction = frac1;
+ cor_max = E_GAIN_norm_corr_interpolate_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/
+ fraction = frac1; /*Q0*/
+ move16();
FOR( i = ( frac1 + step ); i <= frac2; i += step )
{
- temp = E_GAIN_norm_corr_interpolate( &corr[t0], i );
+ temp = E_GAIN_norm_corr_interpolate_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/
IF( GT_16( temp, cor_max ) )
{
- cor_max = temp;
+ cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/
move16();
fraction = i;
move16();
@@ -382,23 +390,23 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
/* limit the fraction value */
IF( fraction < 0 )
{
- fraction = add( fraction, pit_res_max );
+ fraction = add( fraction, pit_res_max ); /*Q0*/
t0 = sub( t0, 1 );
}
test();
test();
IF( ( ( i_subfr == 0 ) && GE_16( t0, pit_fr2 ) ) || LE_16( pit_fr2, pit_min ) )
{
- *pit_res = shr( pit_res_max, 1 );
+ *pit_res = shr( pit_res_max, 1 ); /*Q0*/
move16();
- *pit_frac = shr( fraction, 1 );
+ *pit_frac = shr( fraction, 1 ); /*Q0*/
move16();
}
ELSE
{
- *pit_res = pit_res_max;
+ *pit_res = pit_res_max; /*Q0*/
move16();
- *pit_frac = fraction;
+ *pit_frac = fraction; /*Q0*/
move16();
}
return ( t0 );
diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c
index 856a4312fb88a0c92bbb3fb5228cada468bf8512..243b9f0490e6d58847c2b4b4de4daf7f46733798 100644
--- a/lib_enc/enc_gen_voic_fx.c
+++ b/lib_enc/enc_gen_voic_fx.c
@@ -51,20 +51,20 @@
void encod_gen_voic_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits_fx, /* i/o: number of unused bits */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
+ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 shift,
Word16 Q_new )
{
@@ -77,23 +77,32 @@ void encod_gen_voic_fx(
Word16 y1_fx[L_SUBFR] = { 0 }; /* Filtered adaptive excitation */
Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */
Word16 gain_pit_fx = 0; /* Pitch gain */
- Word16 voice_fac_fx; /* Voicing factor */
- Word32 gain_code_fx = 0; /* Gain of code */
- Word16 gain_inov_fx = 0; /* inovation gain */
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
- Word16 i, i_subfr_fx; /* tmp variables */
- Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
- Word16 T0_min_fx, T0_max_fx; /* pitch variables */
- Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
- Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
- Word16 clip_gain_fx; /* LSF clip gain */
- const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
+ move16();
+ Word16 voice_fac_fx; /* Voicing factor */
+ Word32 gain_code_fx = 0; /* Gain of code */
+ move32();
+ Word16 gain_inov_fx = 0; /* inovation gain */
+ move16();
+ Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
+ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
+ Word16 i, i_subfr_fx; /* tmp variables */
+ Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
+ move16();
+ move16();
+ Word16 T0_min_fx, T0_max_fx; /* pitch variables */
+ Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
+ Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
+ Word16 clip_gain_fx; /* LSF clip gain */
+ const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
Word16 error_fx = 0;
- Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
+ Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
+ move16();
+ move16();
Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */
Word16 unbits_PI_fx = 0; /* number of unused bits for PI */
Word32 norm_gain_code_fx = 0;
+ move16();
+ move32();
Word16 pitch_limit_flag;
Word16 gcode16;
Word32 Ltmp;
@@ -105,6 +114,7 @@ void encod_gen_voic_fx(
Word16 lp_select, lp_flag, L_frame;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
@@ -148,9 +158,9 @@ void encod_gen_voic_fx(
*unbits_fx = 0;
move16();
- p_Aw_fx = Aw_fx;
- p_Aq_fx = Aq_fx;
- pt_pitch_fx = pitch_buf_fx;
+ p_Aw_fx = Aw_fx; /* Q12 */
+ p_Aq_fx = Aq_fx; /* Q12 */
+ pt_pitch_fx = pitch_buf_fx; /* Q6 */
gain_preQ_fx = 0;
move16();
set16_fx( code_preQ_fx, 0, L_SUBFR );
@@ -186,19 +196,19 @@ void encod_gen_voic_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR );
+ Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
- Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 );
- Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
+ Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/
+ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/
/* scaling of xn[] to limit dynamic at 12 bits */
Scale_sig( xn_fx, L_SUBFR, shift );
*pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
- L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx );
@@ -283,7 +293,7 @@ void encod_gen_voic_fx(
if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) )
{
/* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */
- st_fx->clip_var_fx[1] = gain_pit_fx;
+ st_fx->clip_var_fx[1] = gain_pit_fx; /*Q14*/
move16();
}
}
@@ -291,13 +301,14 @@ void encod_gen_voic_fx(
#ifdef BASOP_NOGLOB
Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx_o( Lgcode, &Overflow );
+ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/
#else
Lgcode = L_shl( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/
gcode16 = round_fx( Lgcode );
#endif
- hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift );
+ hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */
+ move16();
/*-----------------------------------------------------------------*
* Transform domain contribution encoding - inactive frames
@@ -315,14 +326,15 @@ void encod_gen_voic_fx(
*-----------------------------------------------------------------*/
/* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
+ Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] ); /*Q10*/
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 );
- Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx );
+ Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */
+ Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); /* Q_new-1+shift+14+1 */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ move16();
#else
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
@@ -339,8 +351,9 @@ void encod_gen_voic_fx(
Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Q16 + Q_exc */
/* Compute exc2 */
- Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow );
- exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
+ Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q16 */
+ exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */
+ move16();
#else
/* Contribution from AVQ layer */
Ltmp1 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/
@@ -352,12 +365,12 @@ void encod_gen_voic_fx(
#endif
/* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code_fx[i] );
- Ltmp = L_shl( Ltmp, 5 );
- Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx );
+ Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */
+ Ltmp = L_shl( Ltmp, 5 ); /* Q15 */
+ Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
+ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/
+ exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */
#else
Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */
@@ -374,12 +387,12 @@ void encod_gen_voic_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
/* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code_fx[i] );
+ Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 5, &Overflow );
- Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow );
+ Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 */
+ Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */
+ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/
+ exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */
#else
Ltmp = L_shl( Ltmp, 5 );
Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx );
@@ -418,9 +431,9 @@ void encod_gen_voic_fx(
IF( st_fx->Opt_SC_VBR )
{
/* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
return;
@@ -428,20 +441,20 @@ void encod_gen_voic_fx(
void encod_gen_voic_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits_fx, /* i/o: number of unused bits */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
+ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 shift,
Word16 Q_new )
{
@@ -454,23 +467,32 @@ void encod_gen_voic_ivas_fx(
Word16 y1_fx[L_SUBFR] = { 0 }; /* Filtered adaptive excitation */
Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */
Word16 gain_pit_fx = 0; /* Pitch gain */
- Word16 voice_fac_fx; /* Voicing factor */
- Word32 gain_code_fx = 0; /* Gain of code */
- Word16 gain_inov_fx = 0; /* inovation gain */
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
- Word16 i, i_subfr_fx; /* tmp variables */
- Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
- Word16 T0_min_fx, T0_max_fx; /* pitch variables */
- Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
- Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
- Word16 clip_gain_fx; /* LSF clip gain */
- const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
+ move16();
+ Word16 voice_fac_fx; /* Voicing factor */
+ Word32 gain_code_fx = 0; /* Gain of code */
+ Word16 gain_inov_fx = 0; /* inovation gain */
+ move32();
+ move16();
+ Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
+ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
+ Word16 i, i_subfr_fx; /* tmp variables */
+ Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
+ move16();
+ move16();
+ Word16 T0_min_fx, T0_max_fx; /* pitch variables */
+ Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
+ Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
+ Word16 clip_gain_fx; /* LSF clip gain */
+ const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
Word16 error_fx = 0;
- Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
+ Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
+ move16();
+ move16();
Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */
Word16 unbits_PI_fx = 0; /* number of unused bits for PI */
Word32 norm_gain_code_fx = 0;
+ move16();
+ move32();
Word16 pitch_limit_flag;
Word16 gcode16;
Word32 Ltmp;
@@ -482,6 +504,7 @@ void encod_gen_voic_ivas_fx(
Word16 lp_select, lp_flag, L_frame;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
@@ -525,9 +548,9 @@ void encod_gen_voic_ivas_fx(
*unbits_fx = 0;
move16();
- p_Aw_fx = Aw_fx;
- p_Aq_fx = Aq_fx;
- pt_pitch_fx = pitch_buf_fx;
+ p_Aw_fx = Aw_fx; /*Q12*/
+ p_Aq_fx = Aq_fx; /*Q12*/
+ pt_pitch_fx = pitch_buf_fx; /*Q6*/
gain_preQ_fx = 0;
move16();
set16_fx( code_preQ_fx, 0, L_SUBFR );
@@ -563,19 +586,19 @@ void encod_gen_voic_ivas_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR );
+ Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
- Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 );
- Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
+ Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/
+ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/
/* scaling of xn[] to limit dynamic at 12 bits */
Scale_sig( xn_fx, L_SUBFR, shift );
*pt_pitch_fx = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
- L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
// tbe_celp_exc(L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx);
tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag );
@@ -603,8 +626,8 @@ void encod_gen_voic_ivas_fx(
* LP filtering of the adaptive excitation, codebook target computation
*-----------------------------------------------------------------*/
- lp_select = lp_filt_exc_enc_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx,
- xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag );
+ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx,
+ xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag );
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
@@ -613,7 +636,8 @@ void encod_gen_voic_ivas_fx(
/*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/
#ifdef BASOP_NOGLOB
- hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/
+ hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /* Q14 */
+ move16();
#else
hSpMusClas->lowrate_pitchGain = round_fx( L_mac( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/
#endif
@@ -661,7 +685,7 @@ void encod_gen_voic_ivas_fx(
if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) )
{
/* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */
- st_fx->clip_var_fx[1] = gain_pit_fx;
+ st_fx->clip_var_fx[1] = gain_pit_fx; /* Q14 */
move16();
}
}
@@ -669,13 +693,14 @@ void encod_gen_voic_ivas_fx(
#ifdef BASOP_NOGLOB
Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx_o( Lgcode, &Overflow );
+ gcode16 = round_fx_o( Lgcode, &Overflow ); /* Q0 */
#else
Lgcode = L_shl( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/
gcode16 = round_fx( Lgcode );
#endif
- hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift );
+ hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */
+ move16();
/*-----------------------------------------------------------------*
* Transform domain contribution encoding - inactive frames
@@ -693,14 +718,15 @@ void encod_gen_voic_ivas_fx(
*-----------------------------------------------------------------*/
/* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) ); // Q_new+14+shift
+ Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] ); /* Q9 */
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); // Q_new+14+shift
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 ); // Q_new-1+15+shift
- Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx ); // Q_new-1+15+shift
+ Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); // Q_new-1+15+shift
+ Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); // Q_new-1+15+shift
#ifdef BASOP_NOGLOB
Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15
hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ move16();
#else
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
@@ -717,8 +743,9 @@ void encod_gen_voic_ivas_fx(
Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Q16 + Q_exc */
/* Compute exc2 */
- Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow );
- exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
+ Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q0 */
+ exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */
+ move16();
#else
/* Contribution from AVQ layer */
Ltmp1 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/
@@ -730,12 +757,13 @@ void encod_gen_voic_ivas_fx(
#endif
/* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code_fx[i] );
- Ltmp = L_shl( Ltmp, 5 );
- Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx );
+ Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */
+ Ltmp = L_shl( Ltmp, 5 ); /* Q15 */
+ Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
+ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/
+ exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */
+ move16();
#else
Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */
@@ -752,12 +780,12 @@ void encod_gen_voic_ivas_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
/* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code_fx[i] );
+ Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 5, &Overflow );
- Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow );
+ Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 */
+ Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */
+ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/
+ exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */
#else
Ltmp = L_shl( Ltmp, 5 );
Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx );
diff --git a/lib_enc/enc_gen_voic_rf.c b/lib_enc/enc_gen_voic_rf.c
deleted file mode 100644
index 33df891b88cc405395df6c65726cdab8fcfcb354..0000000000000000000000000000000000000000
--- a/lib_enc/enc_gen_voic_rf.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c
index ae70dc6b33a5f4761cc65573c624c993b2f5394b..7d1aac5af606d013baa03454f41609eb5e4d025b 100644
--- a/lib_enc/enc_gen_voic_rf_fx.c
+++ b/lib_enc/enc_gen_voic_rf_fx.c
@@ -5,11 +5,9 @@
#include
#include "options.h"
#include "cnst.h"
-//#include "prot_fx.h"
#include "rom_com_fx.h"
#include "stl.h"
#include "rom_basop_util.h"
-//#include "basop_mpy.h"
#include "rom_com.h" /* Common constants */
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
@@ -50,7 +48,7 @@ void reset_rf_indices_fx(
hRF->rf_target_bits = 0;
move16();
- hRF->rf_tcxltp_pitch_int_past = st->L_frame;
+ hRF->rf_tcxltp_pitch_int_past = st->L_frame; /* Q0 */
move16();
hRF->rf_last_tns_active = 0;
move16();
@@ -117,18 +115,18 @@ void reset_rf_indices_fx(
*-------------------------------------------------------------------*/
void coder_acelp_rf_fx(
ACELP_config *acelp_cfg, /*input/output: configuration of the ACELP coding*/
- const Word16 coder_type, /* input: coding type */
- const Word16 A[], /* input: coefficients 4xAz[M+1] */
- const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] */
- Word16 speech[], /* input: speech[-M..lg] */
- const Word16 voicing[], /* input: open-loop LTP gain */
- const Word16 T_op[], /* input: open-loop LTP lag */
- Word16 stab_fac,
+ const Word16 coder_type, /* input: coding type Q0*/
+ const Word16 A[], /* input: coefficients 4xAz[M+1] Q12*/
+ const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] Q12*/
+ Word16 speech[], /* input: speech[-M..lg] Q_new-1*/
+ const Word16 voicing[], /* input: open-loop LTP gain Q15*/
+ const Word16 T_op[], /* input: open-loop LTP lag Q0*/
+ Word16 stab_fac, /* Q15 */
Encoder_State *st,
- Word16 target_bits, /* i/o : coder memory state */
- const Word16 rf_frame_type, /* i : rf_frame_type */
- Word16 *exc_rf, /* i/o: pointer to RF excitation */
- Word16 *syn_rf, /* i/o: pointer to RF synthesis */
+ Word16 target_bits, /* i/o : coder memory state Q0*/
+ const Word16 rf_frame_type, /* i : rf_frame_type Q0*/
+ Word16 *exc_rf, /* i/o: pointer to RF excitation Q_new*/
+ Word16 *syn_rf, /* i/o: pointer to RF synthesis Q_new-1*/
Word16 Q_new,
Word16 shift )
{
@@ -169,6 +167,7 @@ void coder_acelp_rf_fx(
Word16 lp_select;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
RF_ENC_HANDLE hRF = st->hRF;
@@ -184,16 +183,26 @@ void coder_acelp_rf_fx(
voice_fac = 0;
prev_gain_pit = 0;
Es_pred_rf = 0;
+ move32();
+ move32();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
set16_fx( code, 0, L_SUBFR );
/*-----------------------------------------------------------------------*
* Configure ACELP partial copy *
*------------------------------------------------------------------------*/
- tmp2 = BITS_ALLOC_config_acelp( target_bits, rf_frame_type, &( hRF->acelp_cfg_rf ), 0, st->nb_subfr );
+ tmp2 = BITS_ALLOC_config_acelp( target_bits, rf_frame_type, &( hRF->acelp_cfg_rf ), 0, st->nb_subfr ); /* Q0 */
/* Init Framing parameters */
- L_frame = st->L_frame;
-
+ L_frame = st->L_frame; /* Q0 */
+ move16();
/*------------------------------------------------------------------------*
* Initialize buffers *
*------------------------------------------------------------------------*/
@@ -219,10 +228,13 @@ void coder_acelp_rf_fx(
*------------------------------------------------------------------------*/
Es_pred_rf = 0;
+ move16();
+
+ test();
IF( acelp_cfg->nrg_mode > 0 && NE_16( rf_frame_type, RF_NELP ) )
{
Es_pred_enc_fx( &Es_pred_rf, &hRF->rf_indx_EsPred[0], L_frame, exc_rf, voicing,
- acelp_cfg->nrg_bits, acelp_cfg->nrg_mode > 1, Q_new );
+ acelp_cfg->nrg_bits, extract_l( GT_16( acelp_cfg->nrg_mode, 1 ) ), Q_new );
}
/*------------------------------------------------------------------------*
@@ -275,7 +287,7 @@ void coder_acelp_rf_fx(
Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* Q13+1-shift */
/* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn, L_SUBFR, shift );
+ Scale_sig( xn, L_SUBFR, shift ); /* Q_new + shift */
}
@@ -290,12 +302,12 @@ void coder_acelp_rf_fx(
{
nelp_encoder_fx( st, exc_rf, exc_nelp, &Q_new, 0 );
}
- Copy( &exc_nelp[i_subfr], exc2, L_SUBFR );
- Copy( &exc_nelp[i_subfr], exc_rf, L_SUBFR );
+ Copy( &exc_nelp[i_subfr], exc2, L_SUBFR ); /* Q_new */
+ Copy( &exc_nelp[i_subfr], exc_rf, L_SUBFR ); /* Q_new */
}
ELSE
{
- clip_gain = Mode2_gp_clip( voicing, i_subfr, coder_type, xn, hRF->rf_clip_var, L_SUBFR, Q_xn );
+ clip_gain = Mode2_gp_clip_fx( voicing, i_subfr, coder_type, xn, hRF->rf_clip_var, L_SUBFR, Q_xn ); // Q0
/*-----------------------------------------------------------------*
* - find unity gain pitch excitation (adaptive codebook entry) *
@@ -311,7 +323,7 @@ void coder_acelp_rf_fx(
IF( acelp_cfg->ltp_bits != 0 )
{
- prm_rf = &hRF->rf_indx_pitch[0][nSubfr];
+ prm_rf = &hRF->rf_indx_pitch[0][nSubfr]; /* Q0 */
/* Adaptive Codebook (GC and VC) */
Mode2_pit_encode_fx( acelp_cfg->ltp_mode, i_subfr, &prm_rf, &exc_rf[i_subfr],
@@ -324,7 +336,7 @@ void coder_acelp_rf_fx(
move16();
if ( acelp_cfg->gains_mode[i_subfr / L_SUBFR] > 0 )
{
- rf_coder_type = acelp_cfg->gains_mode[i_subfr / L_SUBFR];
+ rf_coder_type = acelp_cfg->gains_mode[i_subfr / L_SUBFR]; /* Q0 */
move16();
}
@@ -335,7 +347,7 @@ void coder_acelp_rf_fx(
if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
{
- hRF->rf_indx_ltfMode[0][nSubfr] = lp_select;
+ hRF->rf_indx_ltfMode[0][nSubfr] = lp_select; /* Q0 */
move16();
}
}
@@ -402,7 +414,7 @@ void coder_acelp_rf_fx(
*----------------------------------------------------------*/
IF( acelp_cfg->gains_mode[i_subfr / L_SUBFR] != 0 )
{
- prm_rf = &hRF->rf_indx_gain[0][nSubfr];
+ prm_rf = &hRF->rf_indx_gain[0][nSubfr]; /* Q0 */
encode_acelp_gains_fx( code, acelp_cfg->gains_mode[j_subfr], Es_pred_rf,
clip_gain, &g_corr, &gain_pit, &gain_code, &prm_rf, &past_gcode,
@@ -428,20 +440,20 @@ void coder_acelp_rf_fx(
* Update memory of the weighting filter
*-----------------------------------------------------------------*/
/* st_fx->_rf_mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] );
+ Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] ); /* Q10 */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, add( 5, Q_xn ), &Overflow );
- Ltmp = L_mac_o( Ltmp, y1[L_SUBFR - 1], gain_pit, &Overflow );
+ Ltmp = L_shl_o( Ltmp, add( 5, Q_xn ), &Overflow ); /* Q15 + Q_xn */
+ Ltmp = L_mac_o( Ltmp, y1[L_SUBFR - 1], gain_pit, &Overflow ); /* Q15 + Q_xn */
#else
Ltmp = L_shl( Ltmp, add( 5, Q_xn ) );
Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit );
#endif
/* Add Gaussian contribution*/
- Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] );
+ Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */
#ifdef BASOP_NOGLOB
- Ltmp2 = L_shl_o( Ltmp2, add( 5, Q_xn ), &Overflow );
- Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow );
- hRF->rf_mem_w0 = sub_o( xn[L_SUBFR - 1], round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ), &Overflow );
+ Ltmp2 = L_shl_o( Ltmp2, add( 5, Q_xn ), &Overflow ); /* Q15 + Q_xn */
+ Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow ); /* Q15 + Q_xn */
+ hRF->rf_mem_w0 = sub_o( xn[L_SUBFR - 1], round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ), &Overflow ); /* Q_xn */
move16();
hRF->rf_mem_w0 = shr_o( hRF->rf_mem_w0, shift, &Overflow ); /*Qnew-1*/
#else
@@ -465,11 +477,12 @@ void coder_acelp_rf_fx(
FOR( i = sub( tmp2, shr( L_SUBFR, 1 ) ); i < tmp2; i++ )
{
/* code in Q9, gain_pit in Q14; exc Q_new */
- Ltmp = Mpy_32_16_1( gain_code2, code2[i] );
+ Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow );
- Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow );
- exc2[i] = round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow );
+ Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow ); /* Q15 + Q_new */
+ Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow ); /* Q15 + Q_new */
+ exc2[i] = round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ); /* Q_new */
+ move16();
#else
Ltmp = L_shl( Ltmp, Q_new_p5 );
Ltmp = L_mac( Ltmp, gain_pit, exc_rf[i + i_subfr] );
@@ -477,12 +490,13 @@ void coder_acelp_rf_fx(
exc2[i] = round_fx( L_shl( Ltmp, 1 ) );
BASOP_SATURATE_WARNING_ON_EVS
#endif
- Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] );
+ Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */
#ifdef BASOP_NOGLOB
- Ltmp2 = L_shl_o( Ltmp2, Q_new_p5, &Overflow );
- Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_rf[i + i_subfr] = round_fx_o( Ltmp, &Overflow );
+ Ltmp2 = L_shl_o( Ltmp2, Q_new_p5, &Overflow ); /* Q15 + Q_new */
+ Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow ); /* Q15 + Q_new */
+ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new*/
+ exc_rf[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */
+ move16();
#else
Ltmp2 = L_shl( Ltmp2, Q_new_p5 );
Ltmp = L_add( Ltmp, Ltmp2 );
@@ -493,6 +507,7 @@ void coder_acelp_rf_fx(
#endif
}
tmp2 = L_SUBFR;
+ move16();
}
@@ -506,7 +521,8 @@ void coder_acelp_rf_fx(
}
}
- IF( i_subfr < sub( L_frame, L_SUBFR ) || NE_16( rf_frame_type, RF_NELP ) )
+ test();
+ IF( LT_16( i_subfr, sub( L_frame, L_SUBFR ) ) || NE_16( rf_frame_type, RF_NELP ) )
{
/*----------------------------------------------------------*
@@ -524,11 +540,12 @@ void coder_acelp_rf_fx(
p_Aq += ( M + 1 );
nSubfr++;
- st->gain_code[j_subfr] = gain_code;
+ st->gain_code[j_subfr] = gain_code; /* Q16 */
j_subfr = add( j_subfr, 1 );
/* copy current gain for next subframe use, in case there is no explicit encoding */
prev_gain_pit = gain_pit;
+ move16();
}
diff --git a/lib_enc/enc_higher_acelp.c b/lib_enc/enc_higher_acelp.c
deleted file mode 100644
index a01b229ff9cdd26addc170ce3100e40a897bbc12..0000000000000000000000000000000000000000
--- a/lib_enc/enc_higher_acelp.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-/*---------------------------------------------------------------------*
- * Local function prototypes
- *---------------------------------------------------------------------*/
diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c
index da58fe7212671e771cf5d8ff01b7761b2866028e..3630be38e58ed97d2c08a750cdab36562b500cf2 100644
--- a/lib_enc/enc_higher_acelp_fx.c
+++ b/lib_enc/enc_higher_acelp_fx.c
@@ -21,25 +21,25 @@ static void find_cn_fx( const Word16 xn[], const Word16 Ap[], const Word16 *p_Aq
#define Q_MINUS 4
void transf_cdbk_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const Word16 i_subfr, /* i : subframe index */
- Word16 cn[], /* i/o: target vector in residual domain */
- Word16 exc[], /* i/o: pointer to excitation signal frame */
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 h1[], /* i : weighted filter input response */
- Word16 xn[], /* i/o: target vector */
- Word16 xn2[], /* i/o: target vector for innovation search */
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
- const Word16 y2[], /* i : zero-memory filtered innovative excitation */
- const Word16 Es_pred, /* i : predicited scaled innovation energy */
- Word16 *gain_pit, /* i/o: adaptive excitation gain */
- const Word32 gain_code, /* i : innovative excitation gain */
- Word16 g_corr[], /* o : ACELP correlation values */
- const Word16 clip_gain, /* i : adaptive gain clipping flag */
- Word16 *gain_preQ, /* o : prequantizer excitation gain */
- Word16 code_preQ[], /* o : prequantizer excitation */
- Word16 *unbits, /* o : number of AVQ unused bits */
+ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ Word16 cn[], /* i/o: target vector in residual domain Q_new*/
+ Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 h1[], /* i : weighted filter input response Q15*/
+ Word16 xn[], /* i/o: target vector Q_new + shift -1*/
+ Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
+ Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
+ const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
+ const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
+ Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
+ const Word32 gain_code, /* i : innovative excitation gain Q16*/
+ Word16 g_corr[], /* o : ACELP correlation values Q15*/
+ const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
+ Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
+ Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
+ Word16 *unbits, /* o : number of AVQ unused bits Q0*/
const Word16 Q_new, /* i : Current frame scaling */
const Word16 shift /* i : shifting applied to y1, xn,... */
)
@@ -56,11 +56,12 @@ void transf_cdbk_enc_fx(
Word16 trgtSvPos;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
avq_bit_sFlag = 0;
move16();
- if ( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
avq_bit_sFlag = 1;
move16();
@@ -72,7 +73,7 @@ void transf_cdbk_enc_fx(
Nsv = 8;
move16();
- nBits = st_fx->acelp_cfg.AVQ_cdk_bits[shr( i_subfr, 6 )];
+ nBits = st_fx->acelp_cfg.AVQ_cdk_bits[shr( i_subfr, 6 )]; /* Q0 */
move16();
/* increase # of AVQ allocated bits by unused bits from the previous subframe */
@@ -97,10 +98,11 @@ void transf_cdbk_enc_fx(
Ltmp = L_shl( Ltmp, add( 5, shift ) );
Ltmp = L_negate( Ltmp );
Ltmp = L_mac( Ltmp, xn[i], 16384 );
- Ltmp = L_msu( Ltmp, y1[i], *gain_pit );
+ Ltmp = L_msu( Ltmp, y1[i], *gain_pit ); /* Q_new + 14 + shift */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- x_tran[i] = round_fx_sat( Ltmp ); /*Q_new-1 */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */
+ x_tran[i] = round_fx_sat( Ltmp ); /*Q_new-1 */
+ move16();
#else
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
x_tran[i] = round_fx( Ltmp ); /*Q_new-1 */
@@ -179,7 +181,7 @@ void transf_cdbk_enc_fx(
m_corr = shr( m_corr, 1 );
e_corr = add( e_corr, 1 );
}
- m_corr = div_s( m_corr, m_ener );
+ m_corr = div_s( m_corr, m_ener ); /* e_corr - e_ener */
e_corr = sub( e_corr, e_ener );
#ifdef BASOP_NOGLOB
Ltmp = L_shl_sat( m_corr, s_min( add( e_corr, 1 ), 31 ) ); /* Lgain in Q16 */
@@ -203,7 +205,7 @@ void transf_cdbk_enc_fx(
e_corr = sub( 14 + 4, e_den );
Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/
#ifdef BASOP_NOGLOB
- stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow );
+ stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */
#else
stmp = round_fx( L_shl( Ltmp, 16 ) );
#endif
@@ -215,15 +217,15 @@ void transf_cdbk_enc_fx(
}
IF( GT_32( st_fx->core_brate, 56000 ) )
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
ELSE IF( GT_32( st_fx->core_brate, 42000 ) )
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
ELSE
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
Ltmp = Mult_32_16( gain_code, stmp ); /* Q16 * Q12 - 15 -> Q13*/
#ifdef BASOP_NOGLOB
@@ -238,11 +240,11 @@ void transf_cdbk_enc_fx(
{
IF( Es_pred < 0 )
{
- Es_pred_loc = shr( negate( Es_pred ), 2 );
+ Es_pred_loc = shr( negate( Es_pred ), 2 ); /* Q8 */
}
ELSE
{
- Es_pred_loc = Es_pred;
+ Es_pred_loc = Es_pred; /* Q8 */
move16();
}
@@ -252,9 +254,9 @@ void transf_cdbk_enc_fx(
test();
IF( m_corr > 0 && m_den > 0 )
{
- m_corr = div_s( 16384, m_den );
+ m_corr = div_s( 16384, m_den ); /* 14 - 8 - e_den */
e_corr = sub( 14 - 8, e_den );
- Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr );
+ Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /* Q18 */
}
ELSE
{
@@ -263,11 +265,11 @@ void transf_cdbk_enc_fx(
test();
IF( LE_32( st_fx->core_brate, 42000 ) && GT_32( st_fx->core_brate, ACELP_24k40 ) )
{
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den );
+ index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
}
ELSE
{
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den );
+ index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
}
Ltmp = L_mult( stmp, Es_pred_loc ); /* Q0*Q8 -> Q9*/
Ltmp = L_shl( Ltmp, add( e_den, 9 ) ); /* Q18*/
@@ -296,7 +298,7 @@ void transf_cdbk_enc_fx(
AVQ_encmux_fx( st_fx->hBstr, -1, x_norm, &nBits, Nsv, nq, avq_bit_sFlag, trgtSvPos );
/* save # of AVQ unused bits for next subframe */
- *unbits = nBits;
+ *unbits = nBits; /* Q0 */
move16();
/* at the last subframe, write AVQ unused bits */
@@ -332,7 +334,7 @@ void transf_cdbk_enc_fx(
test();
IF( NE_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && !harm_flag_acelp )
{
- Copy( x_tran, code_preQ, L_SUBFR );
+ Copy( x_tran, code_preQ, L_SUBFR ); /* Q_AVQ_OUT_DEC */
}
ELSE
{
@@ -404,7 +406,7 @@ void transf_cdbk_enc_fx(
updt_tar_HR_fx( xn, xn, x_tran, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR );
#ifdef BASOP_NOGLOB
- *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow );
+ *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow ); /* Q14 */
#else
*gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0 );
#endif
@@ -412,7 +414,7 @@ void transf_cdbk_enc_fx(
test();
if ( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) )
{
- *gain_pit = 15565;
+ *gain_pit = 15565; /* 0.95 in Q15 */
move16();
}
updt_tar_fx( xn, xn2, y1, *gain_pit, L_SUBFR );
@@ -425,25 +427,25 @@ void transf_cdbk_enc_fx(
}
void transf_cdbk_enc_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const Word16 i_subfr, /* i : subframe index */
- Word16 cn[], /* i/o: target vector in residual domain */
- Word16 exc[], /* i/o: pointer to excitation signal frame */
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 h1[], /* i : weighted filter input response */
- Word16 xn[], /* i/o: target vector */
- Word16 xn2[], /* i/o: target vector for innovation search */
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
- const Word16 y2[], /* i : zero-memory filtered innovative excitation */
- const Word16 Es_pred, /* i : predicited scaled innovation energy */
- Word16 *gain_pit, /* i/o: adaptive excitation gain */
- const Word32 gain_code, /* i : innovative excitation gain */
- Word16 g_corr[], /* o : ACELP correlation values */
- const Word16 clip_gain, /* i : adaptive gain clipping flag */
- Word16 *gain_preQ, /* o : prequantizer excitation gain */
- Word16 code_preQ[], /* o : prequantizer excitation */
- Word16 *unbits, /* o : number of AVQ unused bits */
+ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ Word16 cn[], /* i/o: target vector in residual domain Q_new*/
+ Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 h1[], /* i : weighted filter input response Q15*/
+ Word16 xn[], /* i/o: target vector Q_new + shift -1*/
+ Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
+ Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
+ const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
+ const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
+ Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
+ const Word32 gain_code, /* i : innovative excitation gain Q16*/
+ Word16 g_corr[], /* o : ACELP correlation values Q15*/
+ const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
+ Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
+ Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
+ Word16 *unbits, /* o : number of AVQ unused bits Q0*/
const Word16 Q_new, /* i : Current frame scaling */
const Word16 shift /* i : shifting applied to y1, xn,... */
)
@@ -460,11 +462,12 @@ void transf_cdbk_enc_ivas_fx(
Word16 trgtSvPos;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
avq_bit_sFlag = 0;
move16();
- if ( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
avq_bit_sFlag = 1;
move16();
@@ -476,7 +479,7 @@ void transf_cdbk_enc_ivas_fx(
Nsv = 8;
move16();
- nBits = st_fx->acelp_cfg.AVQ_cdk_bits[shr( i_subfr, 6 )];
+ nBits = st_fx->acelp_cfg.AVQ_cdk_bits[i_subfr >> 6]; /* Q0 */
move16();
/* increase # of AVQ allocated bits by unused bits from the previous subframe */
@@ -501,10 +504,10 @@ void transf_cdbk_enc_ivas_fx(
Ltmp = L_shl( Ltmp, add( 5, shift ) );
Ltmp = L_negate( Ltmp );
Ltmp = L_mac( Ltmp, xn[i], 16384 );
- Ltmp = L_msu( Ltmp, y1[i], *gain_pit );
+ Ltmp = L_msu( Ltmp, y1[i], *gain_pit ); /* Q_new + 14 + shift */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- x_tran[i] = round_fx_sat( Ltmp ); /*Q_new-1 */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */
+ x_tran[i] = round_fx_sat( Ltmp ); /*Q_new-1 */
#else
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
x_tran[i] = round_fx( Ltmp ); /*Q_new-1 */
@@ -575,15 +578,15 @@ void transf_cdbk_enc_ivas_fx(
m_corr = extract_h( L_shl( L_corr, e_corr ) );
e_corr = sub( 30, add( e_corr, sub( Qdct, Q_AVQ_OUT ) ) );
e_ener = norm_l( L_ener );
- m_ener = extract_h( L_shl( L_ener, e_ener ) );
+ m_ener = extract_h( L_shl( L_ener, e_ener ) ); /* 30 - e-ener */
e_ener = sub( 30, e_ener );
IF( GT_16( m_corr, m_ener ) )
{
- m_corr = shr( m_corr, 1 );
+ m_corr = shr( m_corr, 1 ); /* e_corr + 1 */
e_corr = add( e_corr, 1 );
}
- m_corr = div_s( m_corr, m_ener );
+ m_corr = div_s( m_corr, m_ener ); /* e_corr - e_ener */
e_corr = sub( e_corr, e_ener );
#ifdef BASOP_NOGLOB
Ltmp = L_shl_sat( m_corr, s_min( add( e_corr, 1 ), 31 ) ); /* Lgain in Q16 */
@@ -607,7 +610,7 @@ void transf_cdbk_enc_ivas_fx(
e_corr = sub( 14 + 4, e_den );
Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/
#ifdef BASOP_NOGLOB
- stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow );
+ stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */
#else
stmp = round_fx( L_shl( Ltmp, 16 ) );
#endif
@@ -619,20 +622,21 @@ void transf_cdbk_enc_ivas_fx(
}
IF( GT_32( st_fx->core_brate, 56000 ) )
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
ELSE IF( GT_32( st_fx->core_brate, 42000 ) )
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
ELSE
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
Ltmp = Mult_32_16( gain_code, stmp ); /* Q16 * Q12 - 15 -> Q13*/
#ifdef BASOP_NOGLOB
Ltmp = L_shl_sat( Ltmp, 5 ); /* Q13 -> Q18*/
*gain_preQ = round_fx_sat( Ltmp ); /* Q2*/
+ move16();
#else
Ltmp = L_shl( Ltmp, 5 ); /* Q13 -> Q18*/
*gain_preQ = round_fx( Ltmp ); /* Q2*/
@@ -658,7 +662,7 @@ void transf_cdbk_enc_ivas_fx(
{
m_corr = div_s( 16384, m_den );
e_corr = sub( 14 - 8, e_den );
- Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr );
+ Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /* Q16 */
}
ELSE
{
@@ -667,22 +671,23 @@ void transf_cdbk_enc_ivas_fx(
test();
IF( LE_32( st_fx->core_brate, 42000 ) && GT_32( st_fx->core_brate, ACELP_24k40 ) )
{
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den );
+ index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
}
ELSE
{
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den );
+ index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
}
Ltmp = L_mult( stmp, Es_pred_loc ); /* Q0*Q8 -> Q9*/
Ltmp = L_shl( Ltmp, add( e_den, 9 ) ); /* Q18*/
*gain_preQ = round_fx( Ltmp ); /* Q2*/
+ move16();
}
push_indice( st_fx->hBstr, IND_AVQ_GAIN, index, G_AVQ_BITS );
/*--------------------------------------------------------------*
* Encode and multiplex subvectors into bit-stream
*--------------------------------------------------------------*/
- trgtSvPos = Nsv - 1;
+ trgtSvPos = sub( Nsv, 1 );
move16();
test();
test();
@@ -712,7 +717,8 @@ void transf_cdbk_enc_ivas_fx(
{
i = s_min( *unbits, 16 );
push_indice( st_fx->hBstr, IND_UNUSED, 0, i );
- *unbits -= i;
+ *unbits = sub( *unbits, i );
+ move16();
}
}
@@ -736,7 +742,7 @@ void transf_cdbk_enc_ivas_fx(
test();
IF( NE_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && !harm_flag_acelp )
{
- Copy( x_tran, code_preQ, L_SUBFR );
+ Copy( x_tran, code_preQ, L_SUBFR ); /* Q_AVQ_OUT_DEC */
}
ELSE
{
@@ -762,7 +768,7 @@ void transf_cdbk_enc_ivas_fx(
}
st_fx->last_nq_preQ = nq[7];
move16();
-#if 1 // def IVAS_CODE
+
/* TD pre-quantizer: in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */
test();
test();
@@ -771,23 +777,21 @@ void transf_cdbk_enc_ivas_fx(
test();
IF( GT_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->coder_type, INACTIVE ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && !harm_flag_acelp && code_preQ[0] != 0 )
{
- // if ( (float) abs( st->last_code_preq ) > 16.0f * (float) fabs( code_preQ[0] ) )
- if ( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 4 ) ) )
+ IF( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 4 ) ) )
{
st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 4 );
move16();
}
- // else if ( (float) abs( st->last_code_preq ) > 8.0f * (float) fabs( code_preQ[0] ) )
- if ( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 3 ) ) )
+ ELSE IF( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 3 ) ) )
{
st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 3 );
move16();
}
}
- // st->last_code_preq = (int16_t) code_preQ[L_SUBFR - 1];
st_fx->last_code_preq = shr( code_preQ[L_SUBFR - 1], 9 ); // Q0
-#endif
+ move16();
+
PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) );
/*--------------------------------------------------------------*
@@ -818,7 +822,8 @@ void transf_cdbk_enc_ivas_fx(
updt_tar_HR_fx( xn, xn, x_tran, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR );
#ifdef BASOP_NOGLOB
- *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow );
+ *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow ); /* Q14 */
+ move16();
#else
*gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0 );
#endif
@@ -826,7 +831,7 @@ void transf_cdbk_enc_ivas_fx(
test();
if ( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) )
{
- *gain_pit = 15565;
+ *gain_pit = 15565; /* 0.95 in Q14 */
move16();
}
updt_tar_fx( xn, xn2, y1, *gain_pit, L_SUBFR );
@@ -842,16 +847,16 @@ void transf_cdbk_enc_ivas_fx(
*-------------------------------------------------------------------*/
static void find_cn_fx(
- const Word16 xn[], /* i : target signal */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 *p_Aq, /* i : 12k8 LP coefficients */
- Word16 cn[] /* o : target signal in residual domain */
+ const Word16 xn[], /* i : target signal Qx*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 *p_Aq, /* i : 12k8 LP coefficients Q12*/
+ Word16 cn[] /* o : target signal in residual domain Qx*/
)
{
Word16 tmp, tmp_fl[L_SUBFR + M];
set16_fx( tmp_fl, 0, M );
- Copy( xn, tmp_fl + M, L_SUBFR );
+ Copy( xn, tmp_fl + M, L_SUBFR ); /* Qx */
tmp = 0;
move16();
PREEMPH_FX( tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp );
@@ -865,12 +870,12 @@ static void find_cn_fx(
/*-----------------------------------------------------------------*
* Transform domain contribution encoding
*-----------------------------------------------------------------*/
-Word16 gain_quant_fx( /* o: quantization index */
- Word32 *gain, /* i: quantized gain (Q16) */
- Word16 *gain16, /* o: quantized gain (expg) */
- const Word16 c_min, /* i: log10 of lower limit in Q14 */
- const Word16 c_max, /* i: log10 of upper limit in Q13 */
- const Word16 bits, /* i: number of bits to quantize */
+Word16 gain_quant_fx( /* o: quantization index Q0*/
+ Word32 *gain, /* i: quantized gain Q16*/
+ Word16 *gain16, /* o: quantized gain expg*/
+ const Word16 c_min, /* i: log10 of lower limit in Q14*/
+ const Word16 c_max, /* i: log10 of upper limit in Q13*/
+ const Word16 bits, /* i: number of bits to quantize Q0*/
Word16 *expg /* o: output exponent of gain16 */
)
{
@@ -913,15 +918,15 @@ Word16 gain_quant_fx( /* o: quantization index
IF( tmp1 != 0 )
{
exp = norm_s( tmp1 );
- frac = div_s( shl( 1, sub( 14, exp ) ), tmp1 ); /*Q(15-exp)*/
- L_tmp = L_mult( tmp2, frac ); /*Q(30-exp)*/
- L_tmp = Mult_32_16( L_tmp, sub( levels, 1 ) ); /*Q(15-exp)*/
- index = extract_l( L_shr( L_add( L_tmp, shr( 1 << 14, exp ) ), sub( 15, exp ) ) );
+ frac = div_s( shl( 1, sub( 14, exp ) ), tmp1 ); /*Q(15-exp)*/
+ L_tmp = L_mult( tmp2, frac ); /*Q(30-exp)*/
+ L_tmp = Mult_32_16( L_tmp, sub( levels, 1 ) ); /*Q(15-exp)*/
+ index = extract_l( L_shr( L_add( L_tmp, shr( 1 << 14, exp ) ), sub( 15, exp ) ) ); /* Q0 */
}
ELSE
{
- L_tmp = L_mult( tmp2, sub( levels, 1 ) ); /*Q15*/
- index = extract_l( L_shr( L_add( L_tmp, 1 << 14 ), 15 ) );
+ L_tmp = L_mult( tmp2, sub( levels, 1 ) ); /*Q15*/
+ index = extract_l( L_shr( L_add( L_tmp, 1 << 14 ), 15 ) ); /* Q0 */
}
index = s_max( index, 0 );
diff --git a/lib_enc/enc_nelp.c b/lib_enc/enc_nelp.c
deleted file mode 100644
index fd4f3cb7c53af6bc1a4a149c6db6799b8f39655e..0000000000000000000000000000000000000000
--- a/lib_enc/enc_nelp.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c
index 004b43fd364f96b4fc9196af485e3aa38531e207..aedb1d2c2efda7795e84356d24d205564498b5e4 100644
--- a/lib_enc/enc_nelp_fx.c
+++ b/lib_enc/enc_nelp_fx.c
@@ -43,17 +43,17 @@
/*==============================================================================*/
void encod_nelp_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* o : residual signal */
- Word16 *synth_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : input speech Q_new-1*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ Word16 *res_fx, /* o : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift
@@ -69,6 +69,7 @@ void encod_nelp_fx(
Word16 saved_Q_new = Q_new;
Word16 reduce_gains = 0;
+ move16();
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
@@ -95,13 +96,13 @@ void encod_nelp_fx(
* target in residual domain "cn"
* - Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
/* scale xn[] and h1[] to avoid overflow in dot_product12() */
- Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits */
+ Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits Q_new -1 + shift */
IF( i_subfr == 0 )
{
@@ -109,11 +110,12 @@ void encod_nelp_fx(
IF( EQ_16( hSC_VBR->Local_VAD, 1 ) && EQ_16( st_fx->bwidth, NB ) )
{
reduce_gains = 1;
+ move16();
}
nelp_encoder_fx( st_fx, res_fx, exc_nelp_fx, &Q_new, reduce_gains );
- Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) );
+ Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) ); /* saved_Q_new*/
}
@@ -137,7 +139,7 @@ void encod_nelp_fx(
move16();
}
- Copy( exc_nelp_fx, exc_fx, L_FRAME );
+ Copy( exc_nelp_fx, exc_fx, L_FRAME ); /* Q_new */
/*-----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
@@ -150,23 +152,23 @@ void encod_nelp_fx(
#endif
move16(); /*Q_new-1 */
hLPDmem->tilt_code = 0;
- move16(); /* purely unvoiced */
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ move16(); /* purely unvoiced */
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
- Copy( exc_fx, exc2_fx, L_FRAME );
+ Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
hSC_VBR->prev_ppp_gain_pit_fx = 0;
move16();
hLPDmem->dm_fx.prev_state = 0;
move16();
- hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx;
+ hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; /* Q14 */
move16();
FOR( j = 1; j < 5; j++ )
{
- hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1];
+ hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1]; /* Q14 */
move16();
}
interp_code_5over2_fx( exc2_fx, bwe_exc_fx, L_FRAME );
@@ -224,7 +226,7 @@ void encod_nelp_ivas_fx(
{
set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 );
}
- Scale_sig( hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER * 2, sub( Q_new, st_fx->prev_Q_new ) );
+ Scale_sig( hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER * 2, sub( Q_new, st_fx->prev_Q_new ) ); /* Q_new */
pz_filter_sp_fx( num_nelp_lp_fx, den_nelp_lp_fx, res_fx, res_fx, hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER, NELP_LP_ORDER, L_FRAME, 3 ); /*16-Q of filter coeff*/
}
@@ -241,13 +243,13 @@ void encod_nelp_ivas_fx(
* target in residual domain "cn"
* - Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
/* scale xn[] and h1[] to avoid overflow in dot_product12() */
- Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits */
+ Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits Q_new-1+shift */
IF( i_subfr == 0 )
{
@@ -260,7 +262,7 @@ void encod_nelp_ivas_fx(
nelp_encoder_ivas_fx( st_fx, res_fx, exc_nelp_fx, &Q_new, reduce_gains );
- Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) );
+ Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) ); /* saved_Q_new */
}
@@ -275,13 +277,13 @@ void encod_nelp_ivas_fx(
p_Aw_fx += ( M + 1 );
p_Aq_fx += ( M + 1 );
- *pitch_buf_fx = L_SUBFR_Q6;
+ *pitch_buf_fx = L_SUBFR_Q6; /* Q6 */
move16();
pitch_buf_fx++;
}
- Copy( exc_nelp_fx, exc_fx, L_FRAME );
+ Copy( exc_nelp_fx, exc_fx, L_FRAME ); /* Q_new */
/*-----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
@@ -298,19 +300,19 @@ void encod_nelp_ivas_fx(
hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
move16();
- Copy( exc_fx, exc2_fx, L_FRAME );
+ Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
hSC_VBR->prev_ppp_gain_pit_fx = 0;
move16();
hLPDmem->dm_fx.prev_state = 0;
move16();
- hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx;
+ hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; /* Q14 */
move16();
FOR( j = 1; j < 5; j++ )
{
- hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1];
+ hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1]; /* Q14 */
move16();
}
interp_code_5over2_fx( exc2_fx, bwe_exc_fx, L_FRAME );
diff --git a/lib_enc/enc_pit_exc.c b/lib_enc/enc_pit_exc.c
deleted file mode 100644
index fd4f3cb7c53af6bc1a4a149c6db6799b8f39655e..0000000000000000000000000000000000000000
--- a/lib_enc/enc_pit_exc.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c
index 08f6a7a3bdbd7df7d556bea5214432594b01b609..54674da1e884ace3f39577d89a47d6c2a62cb795 100644
--- a/lib_enc/enc_pit_exc_fx.c
+++ b/lib_enc/enc_pit_exc_fx.c
@@ -48,21 +48,21 @@
/*=======================================================================*/
void enc_pit_exc_fx(
Encoder_State *st_fx, /* i/o: State structure */
- const Word16 *speech, /* i : Input speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 *res, /* i : residual signal */
- Word16 *synth, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *T0, /* i/o: close loop integer pitch */
- Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part */
- Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *gpit, /* o : pitch mean gpit */
- Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 *speech, /* i : Input speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *synth, /* i/o: core synthesis Q_new*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *T0, /* i/o: close loop integer pitch Q0*/
+ Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/
+ Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *gpit, /* o : pitch mean gpit Q15*/
+ Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 Q_new,
Word16 shift )
{
@@ -87,6 +87,7 @@ void enc_pit_exc_fx(
Word16 cum_gpit, gpit_tmp;
Word32 Local_BR, Pitch_BR;
Word16 Pitch_CT, unbits_PI = 0; /* saved bits for PI */
+ move16();
Word32 norm_gain_code;
Word16 pitch_limit_flag;
Word16 h2[PIT_EXC_L_SUBFR + ( M + 1 )]; /* Impulse response vector */
@@ -104,6 +105,7 @@ void enc_pit_exc_fx(
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*------------------------------------------------------------------*
@@ -114,11 +116,13 @@ void enc_pit_exc_fx(
move16(); /* always extended pitch Q range */
use_fcb = 0;
unbits_PI = 0;
- test();
- test();
+ move16();
+ move16();
Pitch_CT = GENERIC;
move16();
+ test();
+ test();
IF( st_fx->GSC_IVAS_mode > 0 && ( st_fx->GSC_noisy_speech || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) )
{
Local_BR = ACELP_8k00;
@@ -134,7 +138,7 @@ void enc_pit_exc_fx(
Local_BR = ACELP_9k60;
move32();
}
- Pitch_BR = st_fx->core_brate;
+ Pitch_BR = st_fx->core_brate; /* Q0 */
move32();
}
}
@@ -148,7 +152,7 @@ void enc_pit_exc_fx(
move16();
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
- Pitch_BR = st_fx->core_brate;
+ Pitch_BR = st_fx->core_brate; /* Q0 */
move32();
}
}
@@ -157,12 +161,12 @@ void enc_pit_exc_fx(
Local_BR = ACELP_7k20;
move32();
- Pitch_BR = st_fx->core_brate;
+ Pitch_BR = st_fx->core_brate; /* Q0 */
move32();
Pitch_CT = AUDIO;
move16();
- if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
+ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
Local_BR = ACELP_13k20;
move32();
@@ -188,9 +192,9 @@ void enc_pit_exc_fx(
cum_gpit = 0;
move16();
- L_subfr = mult_r( st_fx->L_frame, div_s( 1, nb_subfr ) );
+ L_subfr = mult_r( st_fx->L_frame, div_s( 1, nb_subfr ) ); /* Q0 */
- lp_flag = st_fx->acelp_cfg.ltf_mode;
+ lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */
test();
test();
@@ -245,27 +249,27 @@ void enc_pit_exc_fx(
* target in residual domain "cn"
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res[i_subfr], &exc[i_subfr], L_subfr );
- /* condition on target (compared to float) has been put outside the loop */
-#if 1 // ndef BUG_FIX
+ Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */
+ /* condition on target (compared to float) has been put outside the loop */
+#if 1 // ndef BUG_FIX
find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
#else
find_targets_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hLPDmem->mem_w0, p_Aq, /*_DIFF_FLOAT_FIX_ --> Here I think mem_syn_tmp_fx should be used */
res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
#endif
- Copy_Scale_sig( h1, h2, L_subfr, -2 );
+ Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */
Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
/* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn, L_subfr, shift );
+ Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */
/*----------------------------------------------------------------*
* Close-loop pitch search and quantization
* Adaptive exc. construction
*----------------------------------------------------------------*/
*pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc,
- L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
/*-----------------------------------------------------------------*
* Find adaptive exitation
*-----------------------------------------------------------------*/
@@ -276,7 +280,7 @@ void enc_pit_exc_fx(
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, AUDIO, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
+ clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, AUDIO, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */
/*-----------------------------------------------------------------*
* Codebook target computation
@@ -284,7 +288,7 @@ void enc_pit_exc_fx(
*-----------------------------------------------------------------*/
lp_select = lp_filt_exc_enc_fx( MODE1, AUDIO, i_subfr, exc, h1,
- xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag );
+ xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
@@ -312,12 +316,12 @@ void enc_pit_exc_fx(
{
IF( GE_32( st_fx->core_brate, MIN_RATE_FCB ) )
{
- pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 32 );
+ pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 32 ); /* Q0 */
push_indice_fx( hBstr, IND_PIT_IDX, pit_idx, 5 );
}
ELSE
{
- pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 16 );
+ pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 16 ); /* Q0 */
push_indice_fx( hBstr, IND_PIT_IDX, pit_idx, 4 );
}
}
@@ -361,7 +365,7 @@ void enc_pit_exc_fx(
#endif
IF( use_fcb != 0 )
{
- hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift );
+ hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
move16();
}
ELSE
@@ -374,14 +378,15 @@ void enc_pit_exc_fx(
*-----------------------------------------------------------------*/
IF( use_fcb != 0 )
{
- Ltmp = L_mult( gcode16, y2[L_subfr - 1] );
+ Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow );
+ Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); /* Q15 + Q_new + shift */
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow );
- Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow );
- Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow );
- hLPDmem->mem_w0 = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */
+ Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); /* Q_new + Q15 + shift */
+ Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); /* Q_new + Q15 + shift */
+ Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); /* Q_new + 15 */
+ hLPDmem->mem_w0 = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */
+ move16();
#else
Ltmp = L_mult( gcode16, y2[L_subfr - 1] );
Ltmp = L_shl( Ltmp, add( 5, shift ) );
@@ -394,11 +399,12 @@ void enc_pit_exc_fx(
}
ELSE
{
- Ltmp = L_mult( xn[L_subfr - 1], 16384 );
+ Ltmp = L_mult( xn[L_subfr - 1], 16384 ); /* Q_new + 14 -shift */
#ifdef BASOP_NOGLOB
- Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit );
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + 14 -shift */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ move16();
#else
Ltmp = L_msu( Ltmp, y1[L_subfr - 1], gain_pit );
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
@@ -415,12 +421,13 @@ void enc_pit_exc_fx(
FOR( i = 0; i < L_subfr; i++ )
{
/* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code[i] );
+ Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 5, &Overflow );
- Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow );
+ Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */
+ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */
+ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q_new + Q16*/
+ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */
+ move16();
#else
Ltmp = L_mult( gcode16, code[i] );
Ltmp = L_shl( Ltmp, 5 );
@@ -435,10 +442,10 @@ void enc_pit_exc_fx(
FOR( i = 0; i < L_subfr; i++ )
{
- Ltmp = L_mult( exc[i + i_subfr], gain_pit );
+ Ltmp = L_mult( exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx_sat( Ltmp );
+ Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */
+ exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */
#else
Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */
exc[i + i_subfr] = round_fx( Ltmp );
@@ -455,7 +462,7 @@ void enc_pit_exc_fx(
IF( EQ_16( L_subfr, 5 * L_SUBFR ) )
{
- cum_gpit = gpit_tmp;
+ cum_gpit = gpit_tmp; /* Q14 */
move16();
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
@@ -478,7 +485,7 @@ void enc_pit_exc_fx(
{
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 13107 ); /* .4f*/
+ cum_gpit = mult_r( gpit_tmp, 13107 /* .4f in Q15 */ ); /* Q14 */
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
move16();
@@ -488,7 +495,7 @@ void enc_pit_exc_fx(
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 19660 ) ); /*0.6*/
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 19660 /* 0.6 in Q15 */ ) ); /* Q14 */
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
move16();
@@ -504,11 +511,11 @@ void enc_pit_exc_fx(
{
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 16384 );
+ cum_gpit = mult_r( gpit_tmp, 16384 /* 0.5 in Q15 */ ); /* Q14 */
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 16384 ) );
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 16384 /* 0.5 in Q15 */ ) ); /* Q14 */
}
p_Aw += 2 * ( M + 1 );
move16();
@@ -521,7 +528,7 @@ void enc_pit_exc_fx(
}
ELSE IF( EQ_16( L_subfr, 4 * L_SUBFR ) )
{
- cum_gpit = gpit_tmp;
+ cum_gpit = gpit_tmp; /* Q14 */
move16();
pt_pitch++;
@@ -541,11 +548,11 @@ void enc_pit_exc_fx(
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 8192 );
+ cum_gpit = mult_r( gpit_tmp, 8192 /* 0.25 in Q15 */ ); /* Q14 */
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 8192 ) );
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 8192 /* 0.25 in Q15 */ ) ); /* Q14 */
}
pt_pitch++;
@@ -564,21 +571,21 @@ void enc_pit_exc_fx(
void enc_pit_exc_ivas_fx(
Encoder_State *st_fx, /* i/o: State structure */
- const Word16 *speech, /* i : Input speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 *res, /* i : residual signal */
- Word16 *synth, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *T0, /* i/o: close loop integer pitch */
- Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part */
- Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *gpit, /* o : pitch mean gpit */
- Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 *speech, /* i : Input speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *synth, /* i/o: core synthesis Q_new*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *T0, /* i/o: close loop integer pitch Q0*/
+ Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/
+ Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *gpit, /* o : pitch mean gpit Q15*/
+ Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 Q_new,
Word16 shift )
{
@@ -620,6 +627,7 @@ void enc_pit_exc_ivas_fx(
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*------------------------------------------------------------------*
@@ -630,13 +638,15 @@ void enc_pit_exc_ivas_fx(
move16(); /* always extended pitch Q range */
use_fcb = 0;
unbits_PI = 0;
- test();
- test();
+ move16();
+ move16();
Pitch_CT = GENERIC;
move16();
#ifdef MSAN_FIX
set16_fx( cn1, 0, PIT_EXC_L_SUBFR );
#endif
+ test();
+ test();
IF( st_fx->GSC_IVAS_mode > 0 && ( st_fx->GSC_noisy_speech || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) )
{
Local_BR = ACELP_8k00;
@@ -706,9 +716,10 @@ void enc_pit_exc_ivas_fx(
cum_gpit = 0;
move16();
- L_subfr = mult_r( st_fx->L_frame, div_s( 1, nb_subfr ) );
+ L_subfr = mult_r( st_fx->L_frame, div_s( 1, nb_subfr ) ); /* Q0 */
lp_flag = st_fx->acelp_cfg.ltf_mode;
+ move16();
test();
test();
@@ -737,13 +748,14 @@ void enc_pit_exc_ivas_fx(
set16_fx( st_fx->acelp_cfg.fixed_cdk_index, 14, NB_SUBFR16k );
}
- *saved_bit_pos = st_fx->next_bit_pos_fx;
+ *saved_bit_pos = st_fx->next_bit_pos_fx; /* Q0 */
move16();
/*------------------------------------------------------------------*
* ACELP subframe loop
*------------------------------------------------------------------*/
cn = NULL;
+ test();
if ( EQ_16( L_subfr, L_SUBFR ) || EQ_16( L_subfr, L_SUBFR * 2 ) )
{
cn = cn1;
@@ -763,24 +775,25 @@ void enc_pit_exc_ivas_fx(
* target in residual domain "cn"
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res[i_subfr], &exc[i_subfr], L_subfr );
+ Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */
/* condition on target (compared to float) has been put outside the loop */
- find_targets_ivas_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
+ find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq,
res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
- Copy_Scale_sig( h1, h2, L_subfr, -2 );
+ Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */
Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
/* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn, L_subfr, shift );
+ Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */
/*----------------------------------------------------------------*
* Close-loop pitch search and quantization
* Adaptive exc. construction
*----------------------------------------------------------------*/
*pt_pitch = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc,
- L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
+ move16();
/*-----------------------------------------------------------------*
* Find adaptive exitation
*-----------------------------------------------------------------*/
@@ -791,15 +804,15 @@ void enc_pit_exc_ivas_fx(
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, AUDIO, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
+ clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, AUDIO, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */
/*-----------------------------------------------------------------*
* Codebook target computation
* (No LP filtering of the adaptive excitation)
*-----------------------------------------------------------------*/
- lp_select = lp_filt_exc_enc_fx( MODE1, AUDIO, i_subfr, exc, h1,
- xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag );
+ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, AUDIO, i_subfr, exc, h1,
+ xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
@@ -877,7 +890,7 @@ void enc_pit_exc_ivas_fx(
#endif
IF( use_fcb != 0 )
{
- hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift );
+ hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15
move16();
}
ELSE
@@ -897,7 +910,7 @@ void enc_pit_exc_ivas_fx(
Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); // Q_new-1+15+shift
Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); // Q_new-1+15+shift
Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); // Q_new+15
- hLPDmem->mem_w0 = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */
+ hGSCEnc->mem_w0_tmp_fx = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */
#else
Ltmp = L_mult( gcode16, y2[L_subfr - 1] );
Ltmp = L_shl( Ltmp, add( 5, shift ) );
@@ -905,7 +918,7 @@ void enc_pit_exc_ivas_fx(
Ltmp = L_mac( Ltmp, xn[L_subfr - 1], 16384 );
Ltmp = L_msu( Ltmp, y1[L_subfr - 1], gain_pit );
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
+ hGSCEnc->mem_w0_tmp_fx = round_fx( Ltmp ); /*Q_new-1 */
#endif
}
ELSE
@@ -914,11 +927,11 @@ void enc_pit_exc_ivas_fx(
#ifdef BASOP_NOGLOB
Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift
Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */
#else
Ltmp = L_msu( Ltmp, y1[L_subfr - 1], gain_pit );
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
+ hGSCEnc->mem_w0_tmp_fx = round_fx( Ltmp ); /*Q_new-1 */
#endif
}
@@ -931,12 +944,13 @@ void enc_pit_exc_ivas_fx(
FOR( i = 0; i < L_subfr; i++ )
{
/* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code[i] );
+ Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 5, &Overflow );
- Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow );
+ Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */
+ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */
+ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new */
+ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */
+ move16();
#else
Ltmp = L_mult( gcode16, code[i] );
Ltmp = L_shl( Ltmp, 5 );
@@ -951,10 +965,11 @@ void enc_pit_exc_ivas_fx(
FOR( i = 0; i < L_subfr; i++ )
{
- Ltmp = L_mult( exc[i + i_subfr], gain_pit );
+ Ltmp = L_mult( exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx_sat( Ltmp );
+ Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */
+ exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */
+ move16();
#else
Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */
exc[i + i_subfr] = round_fx( Ltmp );
@@ -994,7 +1009,7 @@ void enc_pit_exc_ivas_fx(
{
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 13107 ); /* .4f*/
+ cum_gpit = mult_r( gpit_tmp, 13107 /* .4f in Q15 */ ); /* Q14 */
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
move16();
@@ -1004,7 +1019,7 @@ void enc_pit_exc_ivas_fx(
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 19660 ) ); /*0.6*/
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 19660 /* 0.6 in Q15 */ ) ); /* Q14 */
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
move16();
@@ -1020,11 +1035,11 @@ void enc_pit_exc_ivas_fx(
{
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 16384 );
+ cum_gpit = mult_r( gpit_tmp, 16384 /* 0.5 in Q15 */ ); /* Q14 */
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 16384 ) );
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 16384 /* 0.5 in Q15 */ ) ); /* Q14 */
}
p_Aw += 2 * ( M + 1 );
move16();
@@ -1057,11 +1072,11 @@ void enc_pit_exc_ivas_fx(
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 8192 );
+ cum_gpit = mult_r( gpit_tmp, 8192 /* 0.25 in Q15 */ ); /* Q14 */
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 8192 ) );
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 8192 /* 0.25 in Q15 */ ) ); /* Q14 */
}
pt_pitch++;
diff --git a/lib_enc/enc_ppp.c b/lib_enc/enc_ppp.c
deleted file mode 100644
index e7a8ca967132cf8896fc4a231dbaf74eed596840..0000000000000000000000000000000000000000
--- a/lib_enc/enc_ppp.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c
index 775a863d3379a11e3bae50bc02bd3f27329329d0..f1a87d2d296ec128e7aa823519ec942206c2f42e 100644
--- a/lib_enc/enc_ppp_fx.c
+++ b/lib_enc/enc_ppp_fx.c
@@ -53,16 +53,16 @@ void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m );
/*=======================================================================================*/
ivas_error encod_ppp_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 speech_fx[], /* i : input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q14*/
+ Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q-1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift )
{
@@ -77,6 +77,7 @@ ivas_error encod_ppp_fx(
Word16 shift_wsp = add( Q_new, shift );
Word16 rate_ctrl_fx;
Word16 saved_Q_new = Q_new;
+ move16();
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
@@ -101,7 +102,7 @@ ivas_error encod_ppp_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
@@ -130,7 +131,7 @@ ivas_error encod_ppp_fx(
return error;
}
- Scale_sig( exc_fx, L_FRAME, ( saved_Q_new - Q_new ) );
+ Scale_sig( exc_fx, L_FRAME, ( saved_Q_new - Q_new ) ); /* saved_Q_new */
if ( EQ_16( hSC_VBR->bump_up, 1 ) )
{
i_subfr = L_FRAME;
@@ -199,37 +200,38 @@ ivas_error encod_ppp_fx(
}
ELSE
{
- Copy( excQ_ppp_fx, exc_fx, L_FRAME );
+ Copy( excQ_ppp_fx, exc_fx, L_FRAME ); /* Q_new */
/*-----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
*-----------------------------------------------------------------*/
hLPDmem->mem_w0 = sub( shr( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); /*Q_new-1 */
+ move16();
- Copy( exc_fx, exc2_fx, L_FRAME );
+ Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
hLPDmem->dm_fx.prev_state = 2;
- move16(); /*Q0 dispMem index 0 */
- hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx;
- move16(); /*Q14 dispMem index 2 */
+ move16(); /*Q0 dispMem index 0 */
+ hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; /* Q14 */
+ move16(); /*Q14 dispMem index 2 */
FOR( k = 1; k < 5; k++ )
{
- hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1];
+ hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1]; /* Q14 */
move16();
}
- hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx;
+ hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx; /* Q15 */
move16();
- Copy( pitch_fx, pitch_buf_fx, NB_SUBFR );
- pitch_buf_fx[NB_SUBFR16k - 1] = pitch_fx[NB_SUBFR - 1];
+ Copy( pitch_fx, pitch_buf_fx, NB_SUBFR ); /* Q6 */
+ pitch_buf_fx[NB_SUBFR16k - 1] = pitch_fx[NB_SUBFR - 1]; /* Q6 */
interp_code_5over2_fx( exc2_fx, bwe_exc, L_FRAME );
set16_fx( voice_factors, 0, NB_SUBFR16k );
}
- hSC_VBR->rate_control = rate_ctrl_fx;
+ hSC_VBR->rate_control = rate_ctrl_fx; /* Q0 */
move16();
set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 );
@@ -239,16 +241,16 @@ ivas_error encod_ppp_fx(
ivas_error encod_ppp_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 speech_fx[], /* i : input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q-1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift )
{
@@ -288,7 +290,7 @@ ivas_error encod_ppp_ivas_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
@@ -301,7 +303,7 @@ ivas_error encod_ppp_ivas_fx(
{
FOR( k = 0; k < M; k++ )
{
- p_Aq_curr_fx[k] = p_Aq_fx[k + ( 3 * ( M + 1 ) ) + 1];
+ p_Aq_curr_fx[k] = p_Aq_fx[k + ( 3 * ( M + 1 ) ) + 1]; /* Q12 */
move16();
}
@@ -317,7 +319,7 @@ ivas_error encod_ppp_ivas_fx(
return error;
}
- Scale_sig( exc_fx, L_FRAME, sub( saved_Q_new, Q_new ) );
+ Scale_sig( exc_fx, L_FRAME, sub( saved_Q_new, Q_new ) ); /* saved_Q_new */
if ( EQ_16( hSC_VBR->bump_up, 1 ) )
{
i_subfr = L_FRAME;
@@ -386,7 +388,7 @@ ivas_error encod_ppp_ivas_fx(
}
ELSE
{
- Copy( excQ_ppp_fx, exc_fx, L_FRAME );
+ Copy( excQ_ppp_fx, exc_fx, L_FRAME ); /* Q_new */
/*-----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
@@ -394,7 +396,7 @@ ivas_error encod_ppp_ivas_fx(
hLPDmem->mem_w0 = sub( shr( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); /*Q_new-1 */
- Copy( exc_fx, exc2_fx, L_FRAME );
+ Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
hLPDmem->dm_fx.prev_state = 2;
move16(); /*Q0 dispMem index 0 */
@@ -403,11 +405,11 @@ ivas_error encod_ppp_ivas_fx(
FOR( k = 1; k < 5; k++ )
{
- hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1];
+ hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1]; /* Q14 */
move16();
}
- hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx;
+ hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx; /* Q15 */
move16();
Copy( pitch_fx, pitch_buf_fx, NB_SUBFR );
pitch_buf_fx[NB_SUBFR16k - 1] = pitch_fx[NB_SUBFR - 1];
@@ -416,7 +418,7 @@ ivas_error encod_ppp_ivas_fx(
set16_fx( voice_factors, 0, NB_SUBFR16k );
}
- hSC_VBR->rate_control = rate_ctrl_fx;
+ hSC_VBR->rate_control = rate_ctrl_fx; /* Q0 */
move16();
set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 );
diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c
index 1239a104c6ca7ec870e4cfb55f2167f8f2f14a4d..6c6ade036529b72b8094b3e06bc1ccb654ef6094 100644
--- a/lib_enc/enc_prm.c
+++ b/lib_enc/enc_prm.c
@@ -44,16 +44,16 @@
/*-------------------------------------------------------------------*
- * writeTCXMode()
+ * writeTCXMode_fx()
*
* write TCX mode
*--------------------------------------------------------------------*/
-void writeTCXMode(
- Encoder_State *st, /* i/o: encoder state structure */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- Word16 *nbits_start /* o : nbits start */
+void writeTCXMode_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ Word16 *nbits_start /* o : nbits start Q0*/
)
{
UWord16 index;
@@ -110,8 +110,8 @@ void writeTCXMode(
}
/* retrieve the number of bits for signaling */
- idx = add( idx, 1 );
- nBits = extract_l( acelp_sig_tbl[idx] );
+ idx = add( idx, 1 ); /* Q0 */
+ nBits = extract_l( acelp_sig_tbl[idx] ); /* Q0 */
/* retrieve the signaling index */
idx = add( idx, 1 );
@@ -203,14 +203,14 @@ void writeTCXMode(
/*-------------------------------------------------------------------*
- * writeTCXWindowing()
+ * writeTCXWindowing_fx()
*
* write TCX transform type
*-------------------------------------------------------------------*/
-void writeTCXWindowing(
+void writeTCXWindowing_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 overlap_mode /* i : overlap mode */
+ const Word16 overlap_mode /* i : overlap mode Q0*/
)
{
diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c
index edfe5619fdb3bb00c5384f0db89a81bb3303c45b..d394fa2d3acbf5703f33934fcbf011e214f0b7a7 100644
--- a/lib_enc/enc_prm_fx.c
+++ b/lib_enc/enc_prm_fx.c
@@ -17,9 +17,10 @@
static void enc_prm_hm(
- Word16 *prm_hm,
+ Word16 *prm_hm, /* Q0 */
Encoder_State *st,
- Word16 L_frame )
+ Word16 L_frame /* Q0 */
+)
{
Word8 flag;
BSTR_ENC_HANDLE hBstr = st->hBstr;
@@ -55,9 +56,10 @@ static void enc_prm_hm(
}
}
static void enc_prm_hm_ivas_fx(
- Word16 *prm_hm,
+ Word16 *prm_hm, /* Q0 */
Encoder_State *st,
- Word16 L_frame )
+ Word16 L_frame /* Q0 */
+)
{
Word8 flag;
BSTR_ENC_HANDLE hBstr = st->hBstr;
@@ -100,9 +102,11 @@ static void enc_prm_hm_ivas_fx(
* encode RF parameters for ACELP and TCX partial copy *
*-----------------------------------------------------------------*/
-void enc_prm_rf_ivas_fx( Encoder_State *st,
- const Word16 rf_frame_type,
- const Word16 fec_offset )
+void enc_prm_rf_ivas_fx(
+ Encoder_State *st,
+ const Word16 rf_frame_type, /* Q0 */
+ const Word16 fec_offset /* Q0 */
+)
{
Word16 sfr, nb_subfr, n, index;
Word16 ltp_mode, ltf_mode, gains_mode;
@@ -111,7 +115,7 @@ void enc_prm_rf_ivas_fx( Encoder_State *st,
BSTR_ENC_HANDLE hBstr = st->hBstr;
- nb_subfr = st->nb_subfr;
+ nb_subfr = st->nb_subfr; /* Q0 */
move16();
/* partial copy bitstream writing */
test();
@@ -269,9 +273,11 @@ void enc_prm_rf_ivas_fx( Encoder_State *st,
/* write RF frame type last in the bitstream */
push_next_indice( hBstr, rf_frame_type, 3 );
}
-void enc_prm_rf_fx( Encoder_State *st,
- const Word16 rf_frame_type,
- const Word16 fec_offset )
+void enc_prm_rf_fx(
+ Encoder_State *st,
+ const Word16 rf_frame_type, /* Q0 */
+ const Word16 fec_offset /* Q0 */
+)
{
Word16 sfr, nb_subfr, n, index;
Word16 ltp_mode, ltf_mode, gains_mode;
@@ -280,7 +286,7 @@ void enc_prm_rf_fx( Encoder_State *st,
BSTR_ENC_HANDLE hBstr = st->hBstr;
- nb_subfr = st->nb_subfr;
+ nb_subfr = st->nb_subfr; /* Q0 */
/* partial copy bitstream writing */
test();
@@ -370,9 +376,9 @@ void enc_prm_rf_fx( Encoder_State *st,
/* ES pred */
push_next_indice_fx( hBstr, hRF->rf_indx_EsPred[fec_offset], 3 );
- ltp_mode = ACELP_LTP_MODE[1][1][rf_frame_type];
- ltf_mode = ACELP_LTF_MODE[1][1][rf_frame_type];
- gains_mode = ACELP_GAINS_MODE[1][1][rf_frame_type];
+ ltp_mode = ACELP_LTP_MODE[1][1][rf_frame_type]; /* Q0 */
+ ltf_mode = ACELP_LTF_MODE[1][1][rf_frame_type]; /* Q0 */
+ gains_mode = ACELP_GAINS_MODE[1][1][rf_frame_type]; /* Q0 */
/* Subframe parameters */
FOR( sfr = 0; sfr < nb_subfr; sfr++ )
@@ -446,13 +452,14 @@ void enc_prm_rf_fx( Encoder_State *st,
void enc_prm_fx(
const Word16 coder_type, /* (i) : coding type */
- Word16 param[], /* (i) : parameters */
- Word16 param_lpc[], /* (i) : LPC parameters */
+ Word16 param[], /* (i) : parameters Q0*/
+ Word16 param_lpc[], /* (i) : LPC parameters Q0*/
Encoder_State *st, /* i/o : quantization Analysis values */
- Word16 L_frame,
+ Word16 L_frame, /* Q0 */
CONTEXT_HM_CONFIG hm_cfg[],
- Word16 *bits_param_lpc,
- Word16 no_param_lpc )
+ Word16 *bits_param_lpc, /* Q0 */
+ Word16 no_param_lpc /* Q0 */
+)
{
Word16 j, k, n, sfr, core, last_core, *prm, tmp;
Word16 nbits_start, total_nbbits;
@@ -507,7 +514,7 @@ void enc_prm_fx(
move16();
move16();
j = 0;
- nbits_start = hBstr->nb_bits_tot;
+ nbits_start = hBstr->nb_bits_tot; /* Q0 */
/*--------------------------------------------------------------------------------*
@@ -517,10 +524,10 @@ void enc_prm_fx(
IF( EQ_16( st->mdct_sw, MODE1 ) )
{
/* Adjust st->bits_frame_core not to subtract MODE2 bandwidth signaling */
- st->bits_frame_core = add( st->bits_frame_core, FrameSizeConfig[st->frame_size_index].bandwidth_bits );
+ st->bits_frame_core = add( st->bits_frame_core, FrameSizeConfig[st->frame_size_index].bandwidth_bits ); /* Q0 */
/* Write MODE1 core mode signaling */
- signalling_mode1_tcx20_enc( st, 1 );
+ signalling_mode1_tcx20_enc_fx( st, 1 );
}
/* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */
@@ -565,19 +572,19 @@ void enc_prm_fx(
}
/* retrieve the number of bits for signalling */
- nBits = (Word16) acelp_sig_tbl[++idx];
+ nBits = (Word16) acelp_sig_tbl[++idx]; /* Q0 */
/* retrieve the signalling index */
- idx = add( idx, 1 );
- start_idx = idx;
+ idx = add( idx, 1 ); /* Q0 */
+ start_idx = idx; /* Q0 */
tmp32 = SIG2IND_fx( coder_type, st->bwidth, st->sharpFlag, st->rf_mode );
WHILE( NE_32( acelp_sig_tbl[idx], tmp32 ) )
{
- idx = add( idx, 1 );
+ idx = add( idx, 1 ); /* Q0 */
}
push_next_indice_fx( hBstr, idx - start_idx, nBits );
push_next_indice_fx( hBstr, 0, 1 ); /* Indicate to the decoder that the core is ACELP*/
- nbits_start = 3;
+ nbits_start = 3; /* Q0 */
}
ELSE
{
@@ -612,7 +619,7 @@ void enc_prm_fx(
}
/* retrieve the number of bits for signalling */
- nBits = (Word16) acelp_sig_tbl[++idx];
+ nBits = (Word16) acelp_sig_tbl[++idx]; /* Q0 */
test();
test();
@@ -628,8 +635,8 @@ void enc_prm_fx(
}
/* retrieve the signalling index */
- idx = add( idx, 1 );
- start_idx = idx;
+ idx = add( idx, 1 ); /* Q0 */
+ start_idx = idx; /* Q0 */
tmp32 = SIG2IND_fx( st->hTcxCfg->coder_type, st->bwidth, st->sharpFlag, st->rf_mode );
WHILE( NE_32( acelp_sig_tbl[idx], tmp32 ) )
{
@@ -720,7 +727,7 @@ void enc_prm_fx(
st->glr_reset = 0;
move16();
- nbits_header = sub( hBstr->nb_bits_tot, nbits_start );
+ nbits_header = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
/*--------------------------------------------------------------------------------*
@@ -730,7 +737,7 @@ void enc_prm_fx(
IF( s_and( st->enableTcxLpc != 0, core != ACELP_CORE ) )
{
/* Encode the indices */
- nbits_lpc = enc_lsf_tcxlpc_fx( ¶m_lpc, hBstr );
+ nbits_lpc = enc_lsf_tcxlpc_fx( ¶m_lpc, hBstr ); /* Q0 */
}
ELSE
{
@@ -745,7 +752,7 @@ void enc_prm_fx(
move16();
}
- nbits_lpc = encode_lpc_avq_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode );
+ nbits_lpc = encode_lpc_avq_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */
}
ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
{
@@ -753,11 +760,11 @@ void enc_prm_fx(
test();
IF( EQ_32( st->sr_core, 16000 ) && EQ_16( coder_type, VOICED ) && EQ_16( core, ACELP_CORE ) )
{
- nbits_lpc = lsf_bctcvq_encprm_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc );
+ nbits_lpc = lsf_bctcvq_encprm_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */
}
ELSE
{
- nbits_lpc = lsf_msvq_ma_encprm_fx( hBstr, param_lpc, core, coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc );
+ nbits_lpc = lsf_msvq_ma_encprm_fx( hBstr, param_lpc, core, coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */
}
}
ELSE
@@ -787,7 +794,7 @@ void enc_prm_fx(
}
/* Mean energy (2 or 3 bits) */
- n = ACELP_NRG_BITS[st->acelp_cfg.nrg_mode];
+ n = ACELP_NRG_BITS[st->acelp_cfg.nrg_mode]; /* Q0 */
IF( n != 0 )
{
@@ -800,7 +807,7 @@ void enc_prm_fx(
{
/* Pitch lag (4, 5, 6, 8 or 9 bits) */
move16();
- n = ACELP_LTP_BITS_SFR[st->acelp_cfg.ltp_mode][sfr];
+ n = ACELP_LTP_BITS_SFR[st->acelp_cfg.ltp_mode][sfr]; /* Q0 */
IF( n != 0 )
{
@@ -841,7 +848,7 @@ void enc_prm_fx(
push_next_indice_fx( hBstr, prm[j++], bitcnt );
}
- j = add( j_old, 8 );
+ j = add( j_old, 8 ); /* Q0 */
}
/* Gains (5b, 6b or 7b / subfr) */
@@ -887,9 +894,9 @@ void enc_prm_fx(
j = add( j, 3 );
/* TCX spectral data */
- lg = L_frame;
+ lg = L_frame; /* Q0 */
move16();
- lgFB = st->hTcxCfg->tcx_coded_lines;
+ lgFB = st->hTcxCfg->tcx_coded_lines; /* Q0 */
move16();
IF( last_core == ACELP_CORE )
@@ -899,7 +906,7 @@ void enc_prm_fx(
lgFB = add( lgFB, shr( lgFB, 2 ) );
if ( st->hTcxCfg->lfacNext < 0 )
{
- lg = sub( lg, st->hTcxCfg->lfacNext );
+ lg = sub( lg, st->hTcxCfg->lfacNext ); /* Q0 */
}
}
@@ -912,7 +919,7 @@ void enc_prm_fx(
IF( st->hTcxCfg->fIsTNSAllowed )
{
WriteTnsData_fx( st->hTcxCfg->pCurrentTnsConfig, prm + j, &nTnsParams, st, &nTnsBits );
- j = add( j, nTnsParams );
+ j = add( j, nTnsParams ); /* Q0 */
}
hm_size = shl( mult( st->hTcxCfg->bandwidth, lg ), 1 );
@@ -950,17 +957,17 @@ void enc_prm_fx(
IGFEncWriteBitstream_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, IGF_GRID_LB_NORM, 1 );
}
}
- total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
if ( EQ_16( st->rf_mode, 1 ) )
{
- total_nbbits = add( total_nbbits, st->rf_target_bits_write );
+ total_nbbits = add( total_nbbits, st->rf_target_bits_write ); /* Q0 */
}
- nbits_tcx = sub( st->bits_frame_core, total_nbbits );
+ nbits_tcx = sub( st->bits_frame_core, total_nbbits ); /* Q0 */
IF( hTcxEnc->tcx_lpc_shaped_ari != 0 )
{
push_next_bits_fx( hBstr, &prm[++j], nbits_tcx );
- j = add( j, nbits_tcx );
+ j = add( j, nbits_tcx ); /* Q0 */
}
ELSE
{
@@ -990,7 +997,7 @@ void enc_prm_fx(
move16();
IF( st->igf )
{
- nbits_igf = IGFEncWriteConcatenatedBitstream_fx( st->hIGFEnc, hBstr );
+ nbits_igf = IGFEncWriteConcatenatedBitstream_fx( st->hIGFEnc, hBstr ); /* Q0 */
}
FOR( k = 0; k < 2; k++ )
{
@@ -1004,7 +1011,7 @@ void enc_prm_fx(
j = 0;
move16();
- nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
test();
IF( st->enablePlcWaveadjust && k )
@@ -1043,11 +1050,11 @@ void enc_prm_fx(
IF( s_and( k == 0, last_core == ACELP_CORE ) )
{
/* ACE->TCX transition */
- lg = add( lg, st->hTcxCfg->tcx_offset );
+ lg = add( lg, st->hTcxCfg->tcx_offset ); /* Q0 */
lgFB = add( lgFB, shr( lgFB, 1 ) );
if ( st->hTcxCfg->lfacNext < 0 )
{
- lg = sub( lg, st->hTcxCfg->lfacNext );
+ lg = sub( lg, st->hTcxCfg->lfacNext ); /* Q0 */
}
}
@@ -1084,9 +1091,9 @@ void enc_prm_fx(
}
j = add( j, NPRM_CTX_HM );
- total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
- nbits_tcx = sub( shr( sub( add( sub( sub( sub( st->bits_frame_core, nbits_header ), nbits_lpc ), nbits_igf ), 1 ), k ), 1 ), sub( total_nbbits, nbits_tcx ) );
+ nbits_tcx = sub( shr( sub( add( sub( sub( sub( st->bits_frame_core, nbits_header ), nbits_lpc ), nbits_igf ), 1 ), k ), 1 ), sub( total_nbbits, nbits_tcx ) ); /* Q0 */
phm_cfg = NULL;
move16();
@@ -1109,7 +1116,7 @@ void enc_prm_fx(
*--------------------------------------------------------------------------------*/
- total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
/* Check if total encoded bits does not exceed CBR target bits (->this must never happen) */
@@ -1132,10 +1139,10 @@ void enc_prm_fx(
void writeLPCparam_fx(
Encoder_State *st, /* i/o: encoder state structure */
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 param_lpc[], /* i : LPC parameters to write */
- const Word16 bits_param_lpc[], /* i : bits per LPC parameter */
- const Word16 no_param_lpc, /* i : number of LPC parameters */
- Word16 *nbits_lpc /* o : LPC bits written */
+ const Word16 param_lpc[], /* i : LPC parameters to write Q0*/
+ const Word16 bits_param_lpc[], /* i : bits per LPC parameter Q0*/
+ const Word16 no_param_lpc, /* i : number of LPC parameters Q0*/
+ Word16 *nbits_lpc /* o : LPC bits written Q0*/
)
{
Word16 numlpc;
@@ -1144,7 +1151,7 @@ void writeLPCparam_fx(
IF( st->enableTcxLpc && st->core != ACELP_CORE )
{
/* Encode the indices */
- *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr );
+ *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr ); /* Q0 */
move16();
}
ELSE
@@ -1163,7 +1170,7 @@ void writeLPCparam_fx(
move16();
}
- *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode );
+ *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */
move16();
}
ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
@@ -1174,12 +1181,12 @@ void writeLPCparam_fx(
{
assert( st->element_mode == EVS_MONO );
- *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc );
+ *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */
move16();
}
ELSE
{
- *nbits_lpc = lsf_msvq_ma_encprm_ivas_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc );
+ *nbits_lpc = lsf_msvq_ma_encprm_ivas_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */
move16();
}
}
@@ -1199,17 +1206,18 @@ void writeLPCparam_fx(
*-------------------------------------------------------------------*/
void writeTCXparam_fx(
- Encoder_State *st, /* i/o: Encoder State handle */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */
- Word16 param[], /* i : parameters */
- const Word16 nbits_header,
- const Word16 nbits_start,
- const Word16 nbits_lpc,
- const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */
- Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */
- const Word16 target_bitsTCX10[2],
- const Word16 pre_past_flag )
+ Encoder_State *st, /* i/o: Encoder State handle */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */
+ Word16 param[], /* i : parameters Q0*/
+ const Word16 nbits_header, /* Q0 */
+ const Word16 nbits_start, /* Q0 */
+ const Word16 nbits_lpc, /* Q0 */
+ const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0*/
+ Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing Q0*/
+ const Word16 target_bitsTCX10[2], /* Q0 */
+ const Word16 pre_past_flag /* Q0 */
+)
{
Word16 *prm;
Word16 j, k, nSubframes, core, last_core;
@@ -1264,7 +1272,7 @@ void writeTCXparam_fx(
test();
IF( LT_16( st->element_mode, IVAS_CPE_MDCT ) && k == 0 && st->igf && EQ_16( core, TCX_10_CORE ) )
{
- nbits_igf = IGFEncWriteConcatenatedBitstream_ivas_fx( st->hIGFEnc, hBstr );
+ nbits_igf = IGFEncWriteConcatenatedBitstream_ivas_fx( st->hIGFEnc, hBstr ); /* Q0 */
}
flag_ctx_hm = 0;
@@ -1274,7 +1282,7 @@ void writeTCXparam_fx(
j = 0;
move16();
- nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
move16();
test();
@@ -1319,7 +1327,7 @@ void writeTCXparam_fx(
}
ELSE
{
- j = add( j, sub( p_param[k], 2 ) );
+ j = add( j, sub( p_param[k], 2 ) ); /* Q0 */
}
/* TCX spectral data */
@@ -1331,12 +1339,12 @@ void writeTCXparam_fx(
IF( post_part && k == 0 && last_core == ACELP_CORE )
{
/* ACE->TCX transition */
- lg = add( lg, st->hTcxCfg->tcx_offset );
- lgFB = add( lgFB, shr( lgFB, sub( 3, nSubframes ) ) );
+ lg = add( lg, st->hTcxCfg->tcx_offset ); /* Q0 */
+ lgFB = add( lgFB, shr( lgFB, sub( 3, nSubframes ) ) ); /* Q0 */
IF( st->hTcxCfg->lfacNext < 0 )
{
- lg = sub( lg, st->hTcxCfg->lfacNext );
+ lg = sub( lg, st->hTcxCfg->lfacNext ); /* Q0 */
}
}
@@ -1368,7 +1376,7 @@ void writeTCXparam_fx(
IF( no_param_tns && ( st->hTcxEnc->tnsData[k].nFilters < 0 ) )
{
/* a negative filter count means that the filters are identical to those in the first channel at the same sub-frame */
- nTnsParams = no_param_tns[k];
+ nTnsParams = no_param_tns[k]; /* Q0 */
move16();
}
ELSE
@@ -1377,14 +1385,14 @@ void writeTCXparam_fx(
}
IF( no_param_tns )
{
- nTnsBits = add( nTnsBits, 1 );
+ nTnsBits = add( nTnsBits, 1 ); /* Q0 */
}
- j = add( j, nTnsParams );
+ j = add( j, nTnsParams ); /* Q0 */
}
IF( post_part )
{
- hm_size = imult1616( mult( 2, st->hTcxCfg->bandwidth ), lg );
+ hm_size = imult1616( mult( 2, st->hTcxCfg->bandwidth ), lg ); /* Q0 */
test();
test();
@@ -1430,35 +1438,35 @@ void writeTCXparam_fx(
IGFEncWriteBitstream_ivas_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, gridIdx, 1 );
}
- total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
IF( EQ_16( core, TCX_20_CORE ) )
{
IF( st->rf_mode )
{
- total_nbbits = add( total_nbbits, st->rf_target_bits_write );
+ total_nbbits = add( total_nbbits, st->rf_target_bits_write ); /* Q0 */
}
- nbits_tcx = sub( st->bits_frame_core, total_nbbits );
+ nbits_tcx = sub( st->bits_frame_core, total_nbbits ); /* Q0 */
}
ELSE /* TCX_10_CORE */
{
- nbits_tcx = sub( shr( sub( add( sub( sub( sub( st->bits_frame_core, nbits_header ), nbits_lpc ), nbits_igf ), 1 ), k ), 1 ), sub( total_nbbits, nbits_tcx ) );
+ nbits_tcx = sub( shr( sub( add( sub( sub( sub( st->bits_frame_core, nbits_header ), nbits_lpc ), nbits_igf ), 1 ), k ), 1 ), sub( total_nbbits, nbits_tcx ) ); /* Q0 */
}
}
ELSE
{
/*Context HM flag*/
- p_param[k] = j;
+ p_param[k] = j; /* Q0 */
move16();
}
}
ELSE
{
- nbits_tcx = st->bits_frame_channel;
+ nbits_tcx = st->bits_frame_channel; /* Q0 */
move16();
IF( EQ_16( core, TCX_10_CORE ) )
{
- nbits_tcx = sub( target_bitsTCX10[k], NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL );
+ nbits_tcx = sub( target_bitsTCX10[k], NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ); /* Q0 */
}
}
@@ -1468,7 +1476,7 @@ void writeTCXparam_fx(
IF( st->hTcxEnc->tcx_lpc_shaped_ari && EQ_16( core, TCX_20_CORE ) )
{
push_next_bits( hBstr, (UWord16 *) &prm[++j], nbits_tcx );
- j = add( j, nbits_tcx );
+ j = add( j, nbits_tcx ); /* Q0 */
}
ELSE
{
diff --git a/lib_enc/enc_tran.c b/lib_enc/enc_tran.c
deleted file mode 100644
index fc894ba6cc3b0f6891e5522d7bdaa893786ada84..0000000000000000000000000000000000000000
--- a/lib_enc/enc_tran.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c
index c7f7bcd51cb5b449143630268e87af0a81a1ac2e..71e8b9e3b3253f984c4b6825d838e148c8c3624c 100644
--- a/lib_enc/enc_tran_fx.c
+++ b/lib_enc/enc_tran_fx.c
@@ -47,20 +47,20 @@
Word16 encod_tran_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
- Word16 tc_subfr, /* i/o: TC subframe classification */
- Word16 position, /* i : maximum of residual signal index */
- Word16 *unbits, /* i/o: number of unused bits */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
+ Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
+ Word16 position, /* i : maximum of residual signal index Q0*/
+ Word16 *unbits, /* i/o: number of unused bits Q0*/
const Word16 shift, /* i : Scaling to get 12 bits */
const Word16 Q_new /* i : Input scaling */
)
@@ -96,6 +96,7 @@ Word16 encod_tran_fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
@@ -131,14 +132,14 @@ Word16 encod_tran_fx(
/**unbits = 0;move16();*/
Jopt_flag = 0;
move16();
- unbits_ACELP = *unbits;
+ unbits_ACELP = *unbits; /* Q0 */
move16();
*unbits = 0;
move16();
- p_Aw = Aw_fx;
- p_Aq = Aq_fx;
- pt_pitch = pitch_buf_fx;
+ p_Aw = Aw_fx; /* Q12 */
+ p_Aq = Aq_fx; /* Q12 */
+ pt_pitch = pitch_buf_fx; /* Q6 */
gain_preQ = 0;
move16();
set16_fx( code_preQ, 0, L_SUBFR );
@@ -156,7 +157,7 @@ Word16 encod_tran_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
@@ -235,20 +236,20 @@ Word16 encod_tran_fx(
Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
gcode16 = round_fx( Lgcode );
#endif
- hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift );
+ hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
/*-----------------------------------------------------------------*
* Update memory of the weighting filter
*-----------------------------------------------------------------*/
/*st->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]);*/
- L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] );
- L_tmp = L_shl( L_tmp, add( 5, shift ) );
+ L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /* Q10 + Q_new */
+ L_tmp = L_shl( L_tmp, add( 5, shift ) ); /* Q15 + Q_new + shift */
L_tmp = L_negate( L_tmp );
L_tmp = L_mac( L_tmp, xn[L_SUBFR - 1], 16384 );
L_tmp = L_msu( L_tmp, y1[L_SUBFR - 1], gain_pit );
#ifdef BASOP_NOGLOB
- L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx_sat( L_tmp ); /*Q_new-1*/
+ L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) ); /* Q_new + 15 */
+ hLPDmem->mem_w0 = round_fx_sat( L_tmp ); /*Q_new-1*/
#else
L_tmp = L_shl( L_tmp, sub( 1, shift ) );
hLPDmem->mem_w0 = round_fx( L_tmp ); /*Q_new-1*/
@@ -269,7 +270,7 @@ Word16 encod_tran_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
#ifdef BASOP_NOGLOB
- exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) );
+ exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_new */
#else
exc2_fx[i + i_subfr] = round_fx( L_shl( L_mult( gain_pit, exc_fx[i + i_subfr] ), 1 ) );
#endif
@@ -277,10 +278,10 @@ Word16 encod_tran_fx(
}
ELSE
{
- Gain_pitX2 = shl( gain_pit, 1 );
+ Gain_pitX2 = shl( gain_pit, 1 ); /* Q15 */
FOR( i = 0; i < L_SUBFR; i++ )
{
- exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] );
+ exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_new */
}
}
@@ -291,12 +292,12 @@ Word16 encod_tran_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
/* code in Q9, gain_pit in Q14 */
- L_tmp = L_mult( gcode16, code[i] );
+ L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */
#ifdef BASOP_NOGLOB
- L_tmp = L_shl_o( L_tmp, 5, &Overflow );
- L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow );
- L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow );
+ L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */
+ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */
+ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new */
+ exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /* Q_new */
#else
L_tmp = L_shl( L_tmp, 5 );
L_tmp = L_mac( L_tmp, exc_fx[i + i_subfr], gain_pit );
@@ -319,9 +320,9 @@ Word16 encod_tran_fx(
L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */
tmp_fx = round_fx_o( L_tmp, &Overflow );
- exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow );
+ exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */
move16();
- exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow );
+ exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */
move16();
#else
L_tmp = L_shl( L_tmp, tmp1_fx ); /* Q16 + Q_exc */
@@ -439,9 +440,9 @@ Word16 encod_tran_fx(
IF( st_fx->Opt_SC_VBR )
{
/* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
@@ -450,20 +451,20 @@ Word16 encod_tran_fx(
Word16 encod_tran_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
- Word16 tc_subfr, /* i/o: TC subframe classification */
- Word16 position, /* i : maximum of residual signal index */
- Word16 *unbits, /* i/o: number of unused bits */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
+ Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
+ Word16 position, /* i : maximum of residual signal index Q0*/
+ Word16 *unbits, /* i/o: number of unused bits Q0*/
const Word16 shift, /* i : Scaling to get 12 bits */
const Word16 Q_new /* i : Input scaling */
)
@@ -499,6 +500,7 @@ Word16 encod_tran_ivas_fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
@@ -534,13 +536,13 @@ Word16 encod_tran_ivas_fx(
/**unbits = 0;move16();*/
Jopt_flag = 0;
move16();
- unbits_ACELP = *unbits;
+ unbits_ACELP = *unbits; /* Q0 */
move16();
*unbits = 0;
move16();
- p_Aw = Aw_fx;
- p_Aq = Aq_fx;
+ p_Aw = Aw_fx; /* Q12 */
+ p_Aq = Aq_fx; /* Q12 */
pt_pitch = pitch_buf_fx;
gain_preQ = 0;
move16();
@@ -559,7 +561,7 @@ Word16 encod_tran_ivas_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
@@ -638,7 +640,7 @@ Word16 encod_tran_ivas_fx(
Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
gcode16 = round_fx( Lgcode );
#endif
- hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift );
+ hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15
/*-----------------------------------------------------------------*
* Update memory of the weighting filter
*-----------------------------------------------------------------*/
@@ -672,7 +674,7 @@ Word16 encod_tran_ivas_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
#ifdef BASOP_NOGLOB
- exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) );
+ exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_exc */
#else
exc2_fx[i + i_subfr] = round_fx( L_shl( L_mult( gain_pit, exc_fx[i + i_subfr] ), 1 ) );
#endif
@@ -683,7 +685,7 @@ Word16 encod_tran_ivas_fx(
Gain_pitX2 = shl( gain_pit, 1 );
FOR( i = 0; i < L_SUBFR; i++ )
{
- exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] );
+ exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_exc */
}
}
@@ -694,12 +696,12 @@ Word16 encod_tran_ivas_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
/* code in Q9, gain_pit in Q14 */
- L_tmp = L_mult( gcode16, code[i] );
+ L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */
#ifdef BASOP_NOGLOB
- L_tmp = L_shl_o( L_tmp, 5, &Overflow );
- L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow );
- L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow );
+ L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */
+ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */
+ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new */
+ exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /* Q_new */
#else
L_tmp = L_shl( L_tmp, 5 );
L_tmp = L_mac( L_tmp, exc_fx[i + i_subfr], gain_pit );
@@ -722,9 +724,9 @@ Word16 encod_tran_ivas_fx(
L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */
tmp_fx = round_fx_o( L_tmp, &Overflow );
- exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow );
+ exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */
move16();
- exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow );
+ exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */
move16();
#else
L_tmp = L_shl( L_tmp, tmp1_fx ); /* Q16 + Q_exc */
@@ -843,9 +845,9 @@ Word16 encod_tran_ivas_fx(
IF( st_fx->Opt_SC_VBR )
{
/* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
diff --git a/lib_enc/enc_uv.c b/lib_enc/enc_uv.c
deleted file mode 100644
index ccdf49ed34f76e6fc8e0305d1de54cbdde0ce8fa..0000000000000000000000000000000000000000
--- a/lib_enc/enc_uv.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c
index ea88f28b5eff44a563723987895777f3666759dd..d2d8c95706f3d41e3a1c8f45f1326493003664d2 100644
--- a/lib_enc/enc_uv_fx.c
+++ b/lib_enc/enc_uv_fx.c
@@ -18,18 +18,18 @@
/*fixed point implementation of unvoiced_encoder*/
void encod_unvoiced_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : Input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
const Word16 Q_new,
const Word16 shift )
{
@@ -91,7 +91,7 @@ void encod_unvoiced_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
i_subfr_idx = shr( i_subfr, 6 );
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
@@ -108,7 +108,7 @@ void encod_unvoiced_fx(
{
*pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx,
&hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx,
- &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx );
+ &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */
}
ELSE
{
@@ -123,7 +123,7 @@ void encod_unvoiced_fx(
* Gain clipping test to avoid unstable synthesis on frame erasure
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- Mode2_gp_clip( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
+ Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
*pt_pitch_fx = L_SUBFR;
move16();
/*----------------------------------------------------------------------*
@@ -148,7 +148,7 @@ void encod_unvoiced_fx(
*----------------------------------------------------------*/
index = gain_enc_uv_fx( code_fx, code2, L_SUBFR, &gain_pit_fx, &L_gain_code_fx, &gain_code2,
- st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV );
+ st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV ); /* Q0 */
#ifdef DEBUGGING
assert( st_fx->acelp_cfg.gains_mode[i_subfr_idx] == 7 && "Error: UC two-stage, only 5+2 gain Q is supported" );
@@ -175,14 +175,14 @@ void encod_unvoiced_fx(
* Update memory of the weighting filter
*-----------------------------------------------------------------*/
/* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, Q_xn ) );
- Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx );
+ Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] ); /* Q10 */
+ Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */
+ Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx ); /* Q15 + Q_xn */
/* Add Gaussian contribution*/
- Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] );
- Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) );
- Ltmp = L_add( Ltmp, Ltmp2 );
- hLPDmem->mem_w0 = sub( xn_fx[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) );
+ Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */
+ Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */
+ Ltmp = L_add( Ltmp, Ltmp2 ); /* Q15 + Q_xn */
+ hLPDmem->mem_w0 = sub( xn_fx[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) ); /* Q_xn */
move16();
BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef BASOP_NOGLOB
@@ -202,15 +202,15 @@ void encod_unvoiced_fx(
FOR( i = sub( tmp2, shr( L_SUBFR, 1 ) ); i < tmp2; i++ )
{
/* code in Q9, gain_pit in Q14; exc Q_new */
- Ltmp = Mpy_32_16_1( gain_code2, code2[i] );
- Ltmp = L_shl( Ltmp, Q_new_p5 );
- Ltmp = L_mac( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] );
- Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] );
- Ltmp2 = L_shl( Ltmp2, Q_new_p5 );
- Ltmp = L_add( Ltmp, Ltmp2 );
+ Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */
+ Ltmp = L_shl( Ltmp, Q_new_p5 ); /* Q15 + Q_new */
+ Ltmp = L_mac( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] ); /* Q_new + Q15 */
+ Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] ); /* Q10 */
+ Ltmp2 = L_shl( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */
+ Ltmp = L_add( Ltmp, Ltmp2 ); /* Q15 + Q_new */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */
- exc_fx[i + i_subfr] = round_fx_sat( Ltmp );
+ Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */
+ exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */
#else
BASOP_SATURATE_WARNING_OFF_EVS
Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */
@@ -223,7 +223,7 @@ void encod_unvoiced_fx(
}
}
- *tmp_noise_fx = extract_h( norm_gain_code_fx );
+ *tmp_noise_fx = extract_h( norm_gain_code_fx ); /* Q0 */
voice_factors_fx[i_subfr / L_SUBFR] = 0;
move16();
@@ -241,9 +241,9 @@ void encod_unvoiced_fx(
}
/* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
return;
@@ -251,18 +251,18 @@ void encod_unvoiced_fx(
void encod_unvoiced_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : Input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
const Word16 Q_new,
const Word16 shift )
{
@@ -325,7 +325,7 @@ void encod_unvoiced_ivas_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
i_subfr_idx = shr( i_subfr, 6 );
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
@@ -342,7 +342,7 @@ void encod_unvoiced_ivas_fx(
{
*pt_pitch_fx = gaus_encode_ivas_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx,
&hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx,
- &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx );
+ &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */
move16();
}
ELSE
@@ -358,7 +358,7 @@ void encod_unvoiced_ivas_fx(
* Gain clipping test to avoid unstable synthesis on frame erasure
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- Mode2_gp_clip( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
+ Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
*pt_pitch_fx = L_SUBFR << 6;
move16();
/*----------------------------------------------------------------------*
@@ -390,7 +390,7 @@ void encod_unvoiced_ivas_fx(
*----------------------------------------------------------*/
index = gain_enc_uv_fx( code_fx, code2, L_SUBFR, &gain_pit_fx, &L_gain_code_fx, &gain_code2,
- st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV );
+ st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV ); /* Q0 */
#ifdef DEBUGGING
assert( st_fx->acelp_cfg.gains_mode[i_subfr_idx] == 7 && "Error: UC two-stage, only 5+2 gain Q is supported" );
@@ -418,13 +418,13 @@ void encod_unvoiced_ivas_fx(
* Update memory of the weighting filter
*-----------------------------------------------------------------*/
/* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); // Qxn+15
- Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx );
+ Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] ); /* Q10 */
+ Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); // Qxn+15
+ Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx ); /* Qxn + Q15 */
/* Add Gaussian contribution*/
- Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] );
- Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) ); // Q_xn+15
- Ltmp = L_add( Ltmp, Ltmp2 );
+ Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */
+ Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) ); // Q_xn+15
+ Ltmp = L_add( Ltmp, Ltmp2 ); /* Qxn + Q15 */
hLPDmem->mem_w0 = sub( xn_fx[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) ); // Q_xn
move16();
BASOP_SATURATE_WARNING_OFF_EVS;
@@ -446,20 +446,20 @@ void encod_unvoiced_ivas_fx(
FOR( i = sub( tmp2, shr( L_SUBFR, 1 ) ); i < tmp2; i++ )
{
/* code in Q9, gain_pit in Q14; exc Q_new */
- Ltmp = Mpy_32_16_1( gain_code2, code2[i] );
+ Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, Q_new_p5 );
- Ltmp = L_mac_sat( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] );
+ Ltmp = L_shl_sat( Ltmp, Q_new_p5 ); /* Q15 + Q_new */
+ Ltmp = L_mac_sat( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] ); /* Q15 + Q_new */
#else
Ltmp = L_shl( Ltmp, Q_new_p5 );
Ltmp = L_mac( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] );
#endif
- Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] );
+ Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] ); /* Q10 */
#ifdef BASOP_NOGLOB
- Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 );
- Ltmp = L_add_sat( Ltmp, Ltmp2 );
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */
- exc_fx[i + i_subfr] = round_fx_sat( Ltmp );
+ Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */
+ Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */
+ Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */
+ exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */
#else
BASOP_SATURATE_WARNING_OFF_EVS
Ltmp2 = L_shl( Ltmp2, Q_new_p5 );
@@ -496,9 +496,9 @@ void encod_unvoiced_ivas_fx(
/* SC-VBR */
IF( hSC_VBR )
{
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
diff --git a/lib_enc/energy.c b/lib_enc/energy.c
deleted file mode 100644
index 59a3eb11a82f687754109ba17252b6dfe625aca8..0000000000000000000000000000000000000000
--- a/lib_enc/energy.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot.h"
-#include "cnst.h"
-#include "rom_enc.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c
index 054245a6d288b432c1c5b5107d52f713ce9ed4d6..e645395f1aabcce56c261b367d4be78c82e7204a 100644
--- a/lib_enc/energy_fx.c
+++ b/lib_enc/energy_fx.c
@@ -17,18 +17,18 @@
*
*-------------------------------------------------------------------*/
void est_energy_fx(
- Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band */
- Word16 enerBuffer_exp, /* i : exponent of energy vector */
- Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly*/
- Word32 *frame_energy2_p, /* o : frame energy 2*/
- Word32 *HB_Power_p, /* o : high frequency energy*/
- Word32 *frame_energy_p, /* o : frame energy 1*/
- Word16 *sb_power_Q, /* o : the scaling of sb_power*/
- Word16 *frame_energy2_Q, /* o : the scaling of frame_energy*/
- Word16 *HB_Power_Q, /* o : the scaling of HB_Power*/
- Word16 *frame_energy_Q, /* o : the Scaling of frame_energy*/
- Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[]*/
- const Word32 bandwidth /* i : band width*/
+ Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band enerBuffer_exp*/
+ Word16 enerBuffer_exp, /* i : exponent of energy vector */
+ Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly frame_sb_energy_scale*/
+ Word32 *frame_energy2_p, /* o : frame energy 2 frame_energy2_Q*/
+ Word32 *HB_Power_p, /* o : high frequency energy HB_Power_Q*/
+ Word32 *frame_energy_p, /* o : frame energy 1 frame_energy_Q*/
+ Word16 *sb_power_Q, /* o : the scaling of sb_power */
+ Word16 *frame_energy2_Q, /* o : the scaling of frame_energy */
+ Word16 *HB_Power_Q, /* o : the scaling of HB_Power */
+ Word16 *frame_energy_Q, /* o : the Scaling of frame_energy */
+ Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[] */
+ const Word32 bandwidth /* i : band width Q0*/
)
{
Word32 i, j;
@@ -56,13 +56,13 @@ void est_energy_fx(
BandNum = BAND_NUM_TAB[bandwidth];
move16();
- frame_energy2 = L_shr( sb_power[1], shr_tmp );
- HB_Power = L_shr( sb_power[6], shr_tmp );
+ frame_energy2 = L_shr( sb_power[1], shr_tmp ); /* 31 - enerBuffer_exp - shr_tmp */
+ HB_Power = L_shr( sb_power[6], shr_tmp ); /* 31 - enerBuffer_exp - shr_tmp */
FOR( i = 2; i < BandNum; i++ )
{
- Ltmp32 = L_shr( sb_power[i], shr_tmp );
+ Ltmp32 = L_shr( sb_power[i], shr_tmp ); /* 31 - enerBuffer_exp - shr_tmp */
#ifdef BASOP_NOGLOB
- frame_energy2 = L_add_sat( frame_energy2, Ltmp32 );
+ frame_energy2 = L_add_sat( frame_energy2, Ltmp32 ); /* 31 - enerBuffer_exp - shr_tmp */
if ( i > 6 )
HB_Power = L_add_sat( HB_Power, Ltmp32 );
#else
@@ -71,29 +71,29 @@ void est_energy_fx(
HB_Power = L_add( HB_Power, Ltmp32 );
#endif
}
- frame_energy2 = L_sub( frame_energy2, Ltmp32 );
+ frame_energy2 = L_sub( frame_energy2, Ltmp32 ); /* 31 - enerBuffer_exp - shr_tmp */
- sb_power_tmp = L_shr( sb_power[0], shr_tmp );
+ sb_power_tmp = L_shr( sb_power[0], shr_tmp ); /* 31 - enerBuffer_exp - shr_tmp */
IF( EQ_32( bandwidth, 1 ) )
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x147a ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x147a /* 0.16 in Q15 */ ) );
}
ELSE IF( EQ_32( bandwidth, 2 ) )
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x1eb8 ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x1eb8 /* 0.24 in Q15 */ ) );
}
ELSE IF( EQ_32( bandwidth, 3 ) )
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 /* 0.28 in Q15 */ ) );
}
ELSE IF( EQ_32( bandwidth, 4 ) )
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 /* 0.28 in Q15 */ ) );
}
ELSE
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 /* 0.28 in Q15 */ ) );
}
*frame_energy2_p = frame_energy2;
@@ -115,7 +115,7 @@ void est_energy_fx(
FOR( i = 0; i < 6; i++ )
{
- frame_sb_energy[i] = sb_power[i];
+ frame_sb_energy[i] = sb_power[i]; /* sb_power_Q */
move32();
}
@@ -123,17 +123,17 @@ void est_energy_fx(
{
s32CopyPower = 0;
move32();
- widthsb = sub( Nregion_index[i + 1], Nregion_index[i] );
+ widthsb = sub( Nregion_index[i + 1], Nregion_index[i] ); /* Q0 */
s16MaxCoefNorm = sub( ffr_getSfWord32( ( sb_power + Nregion_index[i] ), widthsb ), NREGION_PREOFF[i] );
FOR( j = Nregion_index[i]; j < Nregion_index[i + 1]; j++ )
{
- tmpspec_amp = L_shl( sb_power[j], s16MaxCoefNorm );
+ tmpspec_amp = L_shl( sb_power[j], s16MaxCoefNorm ); /* sb_power_Q + s16MaxCoefNorm */
s32CopyPower = L_add( s32CopyPower, tmpspec_amp );
}
#ifdef BASOP_NOGLOB
- frame_sb_energy[i] = L_shr_o( s32CopyPower, s16MaxCoefNorm, &Overflow );
-#else /* BASOP_NOGLOB */
+ frame_sb_energy[i] = L_shr_o( s32CopyPower, s16MaxCoefNorm, &Overflow ); /* sb_power_Q */
+#else /* BASOP_NOGLOB */
frame_sb_energy[i] = L_shr( s32CopyPower, s16MaxCoefNorm );
#endif
move32();
@@ -180,28 +180,29 @@ static void NormEnergyWord32(
*
*-------------------------------------------------------------------*/
static void update_sb_bg_energy(
- Word32 *sb_bg_energy,
- Word16 *tbg_energy_count,
+ Word32 *sb_bg_energy, /* p_scale_sb_energy */
+ Word16 *tbg_energy_count, /* Q0 */
Word16 *p_scale_sb_energy,
- const Word32 SNR_sb_num,
- const Word32 *frame_sb_energy,
+ const Word32 SNR_sb_num, /* Q0 */
+ const Word32 *frame_sb_energy, /* frame_sb_energy_scale */
const Word16 frame_sb_energy_scale,
- const Word16 FAC_16Q15_a,
+ const Word16 FAC_16Q15_a, /* Q15 */
const Word16 tmp_Q_add,
- const Word16 FAC_16Q19_b )
+ const Word16 FAC_16Q19_b /* Q19 */
+)
{
Word32 sb_bg_energy_ti, tmp;
Word16 tmpQ, i;
- *tbg_energy_count = add( *tbg_energy_count, 1 );
+ *tbg_energy_count = add( *tbg_energy_count, 1 ); /* Q0 */
move16();
tmpQ = add( tmp_Q_add, frame_sb_energy_scale );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy_ti = MUL_F( sb_bg_energy[i], FAC_16Q15_a );
+ sb_bg_energy_ti = MUL_F( sb_bg_energy[i], FAC_16Q15_a ); /* p_scale_sb_energy */
tmp = MUL_F( frame_sb_energy[i], FAC_16Q19_b );
- sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] );
+ sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] ); /* p_scale_sb_energy */
move32();
}
}
@@ -212,12 +213,13 @@ static void update_sb_bg_energy(
*
*-------------------------------------------------------------------*/
void background_update_fx(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word16 scale, /* i : the scaling of frame energy*/
- Word32 frame_energy, /* i : current frame energy*/
- Word32 update_flag, /* i : update flag*/
- Word16 music_backgound_f, /* i : background music flag*/
- Word32 snr )
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ Word16 scale, /* i : the scaling of frame energy */
+ Word32 frame_energy, /* i : current frame energy scale*/
+ Word32 update_flag, /* i : update flag Q0*/
+ Word16 music_backgound_f, /* i : background music flag Q0*/
+ Word32 snr /* Q25 */
+)
{
Word32 tmp;
Word16 i, tmpQ, cmp_lt_frame, cmp_pre_frame;
@@ -279,12 +281,13 @@ void background_update_fx(
test();
test();
test();
- IF( ( LT_16( hVAD_CLDFB->frameloop, 60 ) ) && ( GT_16( hVAD_CLDFB->frameloop, 5 ) ) && ( LT_16( f_tonality_rate[0], 9174 /* 0.56 Q14 */ ) ) && ( LT_16( f_tonality_rate[1], 8192 /* 0.5 Q14 */ ) ) && ( LT_16( ltd_stable_rate[1], 1966 /* 0.06 Q15 */ ) ) && LT_32( snr, 83886080 ) )
+ IF( ( LT_16( hVAD_CLDFB->frameloop, 60 ) ) && ( GT_16( hVAD_CLDFB->frameloop, 5 ) ) && ( LT_16( f_tonality_rate[0], 9174 /* 0.56 Q14 */ ) ) && ( LT_16( f_tonality_rate[1], 8192 /* 0.5 Q14 */ ) ) && ( LT_16( ltd_stable_rate[1], 1966 /* 0.06 Q15 */ ) ) && LT_32( snr, 83886080 /* 2.5f in Q25 */ ) )
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
+ move16();
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
ELSE
@@ -303,8 +306,9 @@ void background_update_fx(
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(q_divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
+ move16();
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
ELSE
@@ -314,7 +318,8 @@ void background_update_fx(
update_sb_bg_energy( sb_bg_energy, &hVAD_CLDFB->tbg_energy_count, p_scale_sb_energy, SNR_sb_num, frame_sb_energy, hVAD_CLDFB->frame_sb_energy_scale,
31456 /* 0.96 Q15 */, 4, 20971 /* 0.04 Q19 */ );
- hVAD_CLDFB->bg_update_count = add( hVAD_CLDFB->bg_update_count, 1 );
+ hVAD_CLDFB->bg_update_count = add( hVAD_CLDFB->bg_update_count, 1 ); /* Q0 */
+ move16();
}
ELSE
{
@@ -329,9 +334,9 @@ void background_update_fx(
tmpQ = add( 9, hVAD_CLDFB->frame_sb_energy_scale );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 32734 /* 0.999 Q15 */ );
+ sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 32734 /* 0.999 Q15 */ ); /* p_scale_sb_energy */
tmp = MUL_F( frame_sb_energy[i], 16777 /* 0.001 Q24 */ );
- sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] );
+ sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] ); /* p_scale_sb_energy */
move32();
}
}
@@ -340,8 +345,9 @@ void background_update_fx(
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(q_divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
+ move16();
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
ELSE
@@ -358,8 +364,9 @@ void background_update_fx(
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(q_divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
+ move16();
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
ELSE
@@ -373,7 +380,7 @@ void background_update_fx(
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(q_divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
@@ -390,7 +397,7 @@ void background_update_fx(
ELSE
{
cmp_pre_frame = VAD_L_CMP( t_bg_energy, hVAD_CLDFB->scale_t_bg_energy, MUL_F( exp_frame_energy.s32Mantissa, 32000 ), sub( exp_frame_energy.s16Exp, 9 ) );
- cmp_lt_frame = VAD_L_CMP( sb_bg_energy[0], scale_sb_energy, MUL_F( frame_sb_energy[0], 20480 ), sub( hVAD_CLDFB->frame_sb_energy_scale, 4 ) );
+ cmp_lt_frame = VAD_L_CMP( sb_bg_energy[0], scale_sb_energy, MUL_F( frame_sb_energy[0], 20480 /* 10 in Q11 */ ), sub( hVAD_CLDFB->frame_sb_energy_scale, 4 ) );
test();
IF( ( cmp_pre_frame > 0 ) && ( cmp_lt_frame > 0 ) )
@@ -398,9 +405,9 @@ void background_update_fx(
tmpQ = add( 3, hVAD_CLDFB->frame_sb_energy_scale );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 29490 /* 0.90 Q15 */ );
+ sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 29490 /* 0.90 Q15 */ ); /* p_scale_sb_energy */
tmp = MUL_F( frame_sb_energy[i], 26214 /* 0.10 Q18 */ );
- sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] );
+ sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] ); /* p_scale_sb_energy */
move32();
}
}
@@ -412,16 +419,16 @@ void background_update_fx(
tmpQ = add( 9, hVAD_CLDFB->frame_sb_energy_scale );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 32734 /* 0.999 Q15 */ );
+ sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 32734 /* 0.999 Q15 */ ); /* exp(p_scale_sb_energy) */
tmp = MUL_F( frame_sb_energy[i], 16777 /* 0.001 Q24 */ );
- sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] );
+ sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] ); /* exp(p_scale_sb_energy) */
move32();
}
}
}
}
- tmp = L_mult0( 160, (Word16) hVAD_CLDFB->tbg_energy_count );
+ tmp = L_mult0( 160, (Word16) hVAD_CLDFB->tbg_energy_count ); /* Q31 */
cmp_pre_frame = VAD_L_CMP( t_bg_energy_sum.s32Mantissa, t_bg_energy_sum.s16Exp, tmp, 0 );
IF( cmp_pre_frame > 0 )
{
@@ -438,10 +445,10 @@ void background_update_fx(
test();
IF( ( EQ_16( music_backgound_f, 1 ) ) && ( LT_32( hVAD_CLDFB->lt_snr_org, 107374179 /* 3.2 Q25 */ ) ) && ( cmp_pre_frame > 0 ) && update_flag == 0 )
{
- tmp = L_shr( 2147 /* 0.000001 Q31 */, sub( 31, scale_sb_energy ) );
+ tmp = L_shr( 2147 /* 0.000001 Q31 */, sub( 31, scale_sb_energy ) ); /* scale_sb_energy */
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy[i] = L_add( MUL_F( sb_bg_energy[i], 32112 /* 0.98 Q15 */ ), tmp );
+ sb_bg_energy[i] = L_add( MUL_F( sb_bg_energy[i], 32112 /* 0.98 Q15 */ ), tmp ); /* scale_sb_energy */
move32();
}
}
@@ -451,10 +458,10 @@ void background_update_fx(
cmp_pre_frame = VAD_L_CMP( exp_frame_energy.s32Mantissa, exp_frame_energy.s16Exp, MUL_F( t_bg_energy, 5000 ), sub( hVAD_CLDFB->scale_t_bg_energy, 15 ) );
IF( cmp_pre_frame < 0 )
{
- tmp = L_shr( 2147 /* 0.000001 Q31 */, sub( 31, scale_sb_energy ) );
+ tmp = L_shr( 2147 /* 0.000001 Q31 */, sub( 31, scale_sb_energy ) ); /* scale_sb_energy */
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy[i] = L_add( MUL_F( sb_bg_energy[i], 32112 /* 0.98 Q15 */ ), tmp );
+ sb_bg_energy[i] = L_add( MUL_F( sb_bg_energy[i], 32112 /* 0.98 Q15 */ ), tmp ); /* scale_sb_energy */
move32();
}
}
@@ -467,7 +474,7 @@ void background_update_fx(
t_bg_energy_sum.s32Mantissa = MUL_F( t_bg_energy_sum.s32Mantissa, 24575 /* 0.75 Q15 */ );
}
- t_bg_energy = VAD_L_div( t_bg_energy_sum.s32Mantissa, hVAD_CLDFB->tbg_energy_count, t_bg_energy_sum.s16Exp, 0, &q_divout );
+ t_bg_energy = VAD_L_div( t_bg_energy_sum.s32Mantissa, hVAD_CLDFB->tbg_energy_count, t_bg_energy_sum.s16Exp, 0, &q_divout ); /* exp(q_divout) */
hVAD_CLDFB->scale_t_bg_energy = q_divout;
move16();
hVAD_CLDFB->t_bg_energy = t_bg_energy;
diff --git a/lib_enc/eval_pit_contr.c b/lib_enc/eval_pit_contr.c
deleted file mode 100644
index d441f6ead49ddcb3a6a1ffab0962633db8157cd0..0000000000000000000000000000000000000000
--- a/lib_enc/eval_pit_contr.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c
index a438b79a69d7c00f4014be221038ba6ef65b1921..e49463a5cf1a9eccf19b817a54d636bf68ca46c3 100644
--- a/lib_enc/eval_pit_contr_fx.c
+++ b/lib_enc/eval_pit_contr_fx.c
@@ -51,11 +51,11 @@
Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is significant */
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *dct_res, /* i : DCT of residual */
- Word16 *dct_pitex, /* i/o: DCT of pitch contribution */
- Word16 *pitch_buf, /* i/o: Pitch per subframe */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *hangover, /* i : hangover for the time contribution switching */
+ const Word16 *dct_res, /* i : DCT of residual Qnew*/
+ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/
+ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *hangover, /* i : hangover for the time contribution switching Q0*/
Word16 Qnew )
{
@@ -80,6 +80,8 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
+ move16();
+ move16();
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
@@ -115,8 +117,8 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
FOR( j = 0; j < mfreq_bindiv_loc[i]; j++ ) /* up to maximum allowed voiced critical band */
{
- tmp_ex = mult_r( dct_pitex[j + freq], 8192 );
- tmp_res = mult_r( dct_res[j + freq], 8192 );
+ tmp_ex = mult_r( dct_pitex[j + freq], 8192 /* 0.25 in Q15 */ );
+ tmp_res = mult_r( dct_res[j + freq], 8192 /* 0.25 in Q15 */ );
corr_tmp = L_mac0( corr_tmp, tmp_res, tmp_ex ); /*2*Qnew*/
ener_res = L_mac0( ener_res, tmp_res, tmp_res ); /*2*Qnew*/
ener_pit = L_mac0( ener_pit, tmp_ex, tmp_ex ); /*2*Qnew*/
@@ -145,10 +147,10 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
FOR( i = 1; i < Mbands_loc - 1; i++ ) /* up to maximum allowed voiced critical band */
{
- L_tmp = L_mult( BETA_FX, corr_dct_pit[i - 1] );
- L_tmp = L_mac( L_tmp, BETA_FX, corr_dct_pit[i + 1] );
+ L_tmp = L_mult( BETA_FX, corr_dct_pit[i - 1] ); /* Q30 */
+ L_tmp = L_mac( L_tmp, BETA_FX, corr_dct_pit[i + 1] ); /* Q30 */
- tmp = mac_r( L_tmp, ALPA_FX, corr_dct_pit[i] );
+ tmp = mac_r( L_tmp, ALPA_FX, corr_dct_pit[i] ); /* Q30 */
tmp = s_max( tmp, val_thrs );
corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 );
@@ -176,7 +178,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
/*av_corr *= 1.25f;*/
- av_corr = add( av_corr, shr( av_corr, 2 ) );
+ av_corr = add( av_corr, shr( av_corr, 2 ) ); /* Q2 */
}
test();
if ( GE_16( st_fx->GSC_IVAS_mode, 1 ) || LT_32( st_fx->core_brate, ACELP_9k60 ) )
@@ -193,7 +195,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
{
last_pit_band = i;
move16();
- min_corr = ftmp;
+ min_corr = ftmp; /* Q2 */
move16();
}
}
@@ -315,13 +317,13 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
{
last_pit_band = add( BAND1k2, 1 );
}
- last_pit_bin = mfreq_loc_div_25[last_pit_band];
+ last_pit_bin = mfreq_loc_div_25[last_pit_band]; /* Q0 */
move16();
st_fx->bpf_off = 0;
move16();
- max_len = sub( st_fx->L_frame, last_pit_bin );
+ max_len = sub( st_fx->L_frame, last_pit_bin ); /* Q0 */
if ( EQ_16( st_fx->bwidth, NB ) )
{
@@ -350,7 +352,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
FOR( i = 0; i < Len; i++ )
{
- dct_pitex[i + last_pit_bin] = mult_r( dct_pitex[i + last_pit_bin], sm_table_fx[i] );
+ dct_pitex[i + last_pit_bin] = mult_r( dct_pitex[i + last_pit_bin], sm_table_fx[i] ); /* Q_new */
}
FOR( ; i < max_len; i++ )
{
@@ -358,7 +360,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
move16();
}
}
- hGSCEnc->mem_last_pit_band = last_pit_band;
+ hGSCEnc->mem_last_pit_band = last_pit_band; /* Q0 */
move16();
pit_contr_idx = sub( last_pit_band, BAND1k2 );
}
@@ -383,7 +385,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
#ifndef IVAS_CODE_BITSTREAM
IF( hBstr->ind_list[i].nb_bits != -1 )
{
- hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[i].nb_bits );
+ hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[i].nb_bits ); /* Q0 */
hBstr->ind_list[i].nb_bits = -1;
move16();
}
@@ -395,7 +397,8 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
#ifndef IVAS_CODE_BITSTREAM
IF( hBstr->ind_list[IND_ES_PRED].nb_bits != -1 )
{
- hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_ES_PRED].nb_bits );
+ hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_ES_PRED].nb_bits ); /* Q0 */
+ move16();
hBstr->ind_list[IND_ES_PRED].nb_bits = -1;
move16();
}
@@ -434,11 +437,11 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin where pitch contribution is significant */
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *dct_res, /* i : DCT of residual */
- Word16 *dct_pitex, /* i/o: DCT of pitch contribution */
- Word16 *pitch_buf, /* i/o: Pitch per subframe */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *hangover, /* i : hangover for the time contribution switching */
+ const Word16 *dct_res, /* i : DCT of residual Q_new*/
+ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Q_new*/
+ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *hangover, /* i : hangover for the time contribution switching Q0*/
Word16 Qnew )
{
@@ -463,6 +466,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
+ move16();
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
@@ -521,33 +525,33 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
move16(); /* 0.5 in Q14*/
/* Smooth the inter-correlation value and skip the last band for the average (since last band is almost always 0)*/
tmp = mac_r( L_mult( ALPA_FX, corr_dct_pit[0] ), ALPAM1_FX, corr_dct_pit[1] ); /*Qnew*/
- tmp = s_max( tmp, val_thrs );
+ tmp = s_max( tmp, val_thrs ); /*Qnew */
- corr_dct_pit_tmp[0] = shl( sub( tmp, val_thrs ), 1 );
+ corr_dct_pit_tmp[0] = shl( sub( tmp, val_thrs ), 1 ); /* Q_new + 1 */
move16();
FOR( i = 1; i < Mbands_loc - 1; i++ ) /* up to maximum allowed voiced critical band */
{
- L_tmp = L_mult( BETA_FX, corr_dct_pit[i - 1] );
- L_tmp = L_mac( L_tmp, BETA_FX, corr_dct_pit[i + 1] );
+ L_tmp = L_mult( BETA_FX, corr_dct_pit[i - 1] ); /* Q_new + 16 */
+ L_tmp = L_mac( L_tmp, BETA_FX, corr_dct_pit[i + 1] ); /* Q_new + 16 */
- tmp = mac_r( L_tmp, ALPA_FX, corr_dct_pit[i] );
- tmp = s_max( tmp, val_thrs );
+ tmp = mac_r( L_tmp, ALPA_FX, corr_dct_pit[i] ); /* Q_new */
+ tmp = s_max( tmp, val_thrs ); /* Q_new */
- corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 );
+ corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 ); /* Q_new + 1 */
move16();
}
tmp = mac_r( L_mult( ALPA_FX, corr_dct_pit[i] ), ALPAM1_FX, corr_dct_pit[i - 1] ); /*Qnew*/
- tmp = s_max( tmp, val_thrs );
- corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 );
+ tmp = s_max( tmp, val_thrs ); /* Q_new */
+ corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 ); /* Q_new + 1 */
move16();
- Copy( corr_dct_pit_tmp, corr_dct_pit, Mbands_loc );
+ Copy( corr_dct_pit_tmp, corr_dct_pit, Mbands_loc ); /* Q_new + 1 */
L_tmp1 = L_mult( DIV_NB_VOIC_FX, corr_dct_pit[0] ); /*Qnew*/
FOR( i = 1; i < NB_VOIC_FX; i++ ) /* up to maximum allowed voiced critical band */
{
- L_tmp1 = L_mac( L_tmp1, DIV_NB_VOIC_FX, corr_dct_pit[i] );
+ L_tmp1 = L_mac( L_tmp1, DIV_NB_VOIC_FX, corr_dct_pit[i] ); /* Q_new + 16 */
}
av_corr = round_fx( L_tmp1 ); /*Qnew*/
@@ -652,7 +656,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
move16();
}
- ( *hangover ) = sub( ( *hangover ), 1 );
+ ( *hangover ) = sub( ( *hangover ), 1 ); /* Q0 */
if ( *hangover < 0 )
{
*hangover = 0;
@@ -678,7 +682,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
test();
test();
/*if(st_fx->core_brate core_brate, ACELP_9k60 ) && LT_16( low_pit, 4096 ) )
+ IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && LT_16( low_pit, 4096 /* 64 in Q6 */ ) )
{
last_pit_band = add( 9, BAND1k2 );
if ( EQ_16( st_fx->bwidth, NB ) )
@@ -686,7 +690,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
last_pit_band = add( 7, BAND1k2 );
}
}
- ELSE IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && LT_16( low_pit, 8192 ) )
+ ELSE IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && LT_16( low_pit, 8192 /* 128 in Q6 */ ) )
{
last_pit_band = add( 5, BAND1k2 );
}
@@ -698,7 +702,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
{
last_pit_band = add( BAND1k2, 1 );
}
- last_pit_bin = mfreq_loc_div_25[last_pit_band];
+ last_pit_bin = mfreq_loc_div_25[last_pit_band]; /* Q15 */
move16();
st_fx->bpf_off = 0;
@@ -733,7 +737,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
FOR( i = 0; i < Len; i++ )
{
- dct_pitex[i + last_pit_bin] = mult_r( dct_pitex[i + last_pit_bin], sm_table_fx[i] );
+ dct_pitex[i + last_pit_bin] = mult_r( dct_pitex[i + last_pit_bin], sm_table_fx[i] ); /* Q_new */
}
FOR( ; i < max_len; i++ )
{
diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c
deleted file mode 100644
index d4fe802221847d9ecedad7d46d88d7aeb2f2d099..0000000000000000000000000000000000000000
--- a/lib_enc/evs_enc.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include "ivas_prot_fx.h"
-#include "prot_fx.h"
-#include "prot_fx_enc.h"
diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c
index 4a706969ed2e7f5c484f96d645263ab35640f0fc..3005edd6e61cd9f11d47b5f0a858a4a02377daad 100644
--- a/lib_enc/evs_enc_fx.c
+++ b/lib_enc/evs_enc_fx.c
@@ -30,10 +30,10 @@ static void configure_core_coder_loc( Encoder_State *st );
*-------------------------------------------------------------------*/
ivas_error evs_enc_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 *data, /* i : input signal */
- Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory */
- const Word16 n_samples /* i : number of input samples */
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 *data, /* i : input signal Q0*/
+ Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/
+ const Word16 n_samples /* i : number of input samples Q0*/
)
{
Word16 i, input_frame, delay;
@@ -144,13 +144,13 @@ ivas_error evs_enc_fx(
/* get delay to synchronize ACELP and MDCT frame */
delay = NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS );
- Copy( st->input_fx - delay, st->old_input_signal_fx, input_frame + delay );
+ Copy( st->input_fx - delay, st->old_input_signal_fx, input_frame + delay ); /* st->q_inp */
/*----------------------------------------------------------------*
* convert 'short' input data to 'float'
*----------------------------------------------------------------*/
- Copy( data, st->input_fx, input_frame );
+ Copy( data, st->input_fx, input_frame ); /* st-> q_inp */
IF( LT_16( n_samples, input_frame ) )
{
set16_fx( st->input_fx + n_samples, 0, sub( input_frame, n_samples ) );
@@ -225,7 +225,7 @@ ivas_error evs_enc_fx(
IF( EQ_16( st->last_L_frame, L_FRAME ) && st->ini_frame != 0 )
{
/* this is just an approximation, but it is sufficient */
- Copy( st->lsp_old1_fx, st->lspold_enc_fx, M );
+ Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /* Q15 */
}
}
ELSE
@@ -238,7 +238,7 @@ ivas_error evs_enc_fx(
move16();
}
- st->sr_core = L_mult0( FRAMES_PER_SEC, st->L_frame );
+ st->sr_core = L_mult0( FRAMES_PER_SEC, st->L_frame ); /* Q0 */
st->core_brate = st->total_brate;
move32();
@@ -332,7 +332,7 @@ ivas_error evs_enc_fx(
bwe_exc_extended, voice_factors, pitch_buf,
vad_hover_flag, &Q_new, &shift );
#ifndef FIX_I4_OL_PITCH
- Copy( pitch_orig, st->pitch, 3 ); /* populate the original OL pitch values back */
+ Copy( pitch_orig, st->pitch, 3 ); /* populate the original OL pitch values back Q0*/
#endif
/*---------------------------------------------------------------------*
@@ -393,12 +393,12 @@ ivas_error evs_enc_fx(
move32();
}
- st->core_brate = L_sub( st->total_brate, st->extl_brate );
+ st->core_brate = L_sub( st->total_brate, st->extl_brate ); /* Q0 */
IF( EQ_16( st->tec_tfa, 1 ) )
{
- st->core_brate = L_sub( st->core_brate, BITS_TEC );
- st->core_brate = L_sub( st->core_brate, BITS_TFA );
+ st->core_brate = L_sub( st->core_brate, BITS_TEC ); /* Q0 */
+ st->core_brate = L_sub( st->core_brate, BITS_TFA ); /* Q0 */
}
}
@@ -413,14 +413,14 @@ ivas_error evs_enc_fx(
IF( st->igf != 0 && EQ_16( st->core, ACELP_CORE ) && GT_32( st->core_brate, SID_2k40 ) )
{
/* padBits = ((st->bits_frame+7)/8)*8 - (st->nb_bits_tot + (st->rf_target_bits_write - ((st->Opt_RF_ON==1)?1:0) ) + get_tbe_bits(st->total_brate, st->bwidth, st->rf_mode )); */
- tmp = add( get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_mode ), sub( st->rf_target_bits_write, st->rf_mode ) );
- padBits = sub( sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), hBstr->nb_bits_tot ), tmp );
+ tmp = add( get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_mode ), sub( st->rf_target_bits_write, st->rf_mode ) ); /* Q0 */
+ padBits = sub( sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), hBstr->nb_bits_tot ), tmp ); /* Q0 */
}
ELSE
{
/* padBits = ((st->bits_frame+7)/8)*8 - (st->nb_bits_tot + (st->rf_target_bits_write - ((st->Opt_RF_ON==1)?1:0) )); */
- tmp = sub( st->rf_target_bits_write, st->rf_mode );
- padBits = sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), add( hBstr->nb_bits_tot, tmp ) );
+ tmp = sub( st->rf_target_bits_write, st->rf_mode ); /* Q0 */
+ padBits = sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), add( hBstr->nb_bits_tot, tmp ) ); /* Q0 */
}
FOR( i = 0; i < padBits; i++ )
@@ -517,7 +517,7 @@ ivas_error evs_enc_fx(
st->hTECEnc->corrFlag = 0;
move16();
}
- st->tfa_flag = tfaEnc_TBE_fx( st->tfa_enr, st->last_core, st->voicing_fx, pitch_buf, shl( Q_shb_spch, 1 ) );
+ st->tfa_flag = tfaEnc_TBE_fx( st->tfa_enr, st->last_core, st->voicing_fx, pitch_buf, shl( Q_shb_spch, 1 ) ); /* Q0 */
set_TEC_TFA_code_fx( st->hTECEnc->corrFlag, &st->tec_flag, &st->tfa_flag );
}
ELSE
@@ -559,7 +559,7 @@ ivas_error evs_enc_fx(
* Channel-aware mode - write signaling information into the bitstream
*---------------------------------------------------------------------*/
- signalling_enc_rf( st );
+ signalling_enc_rf_fx( st );
updt_enc_common_fx( st, Etot, Q_new );
diff --git a/lib_enc/ext_sig_ana.c b/lib_enc/ext_sig_ana.c
deleted file mode 100644
index 9f9fa4c23133239f729cb22721f441ff8c4e71c0..0000000000000000000000000000000000000000
--- a/lib_enc/ext_sig_ana.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c
index 97d6f3b912b9ce9fe384cc6dc9bbef7fac58cae9..af9c2dbc4e01340ab6a85d450b1cbefed000fce3 100644
--- a/lib_enc/ext_sig_ana_fx.c
+++ b/lib_enc/ext_sig_ana_fx.c
@@ -23,19 +23,19 @@
void core_signal_analysis_high_bitrate_fx(
const Word16 *new_samples, /*i: 0Q15*/
- const Word16 T_op[3], /* i : open-loop pitch values for quantiz. */
- Word16 lsp_new[],
- Word16 lsp_mid[],
+ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/
+ Word16 lsp_new[], /* Q15 */
+ Word16 lsp_mid[], /* Q15 */
Encoder_State *st,
- Word16 pTnsSize[],
- Word16 pTnsBits[],
- Word16 param_core[],
- Word16 *ltpBits,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- const Word16 last_element_mode,
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- Word32 **spectrum,
+ Word16 pTnsSize[], /* Q0 */
+ Word16 pTnsBits[], /* Q0 */
+ Word16 param_core[], /* Q0 */
+ Word16 *ltpBits, /* Q0 */
+ const Word16 L_frame, /* Q0 */
+ const Word16 L_frameTCX, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ Word32 **spectrum, /* spectrum_e */
Word16 *spectrum_e,
Word16 *Q_new )
{
@@ -93,10 +93,10 @@ void core_signal_analysis_high_bitrate_fx(
right_overlap = -1;
move16();
- tcx10SizeFB = shl( st->hTcxCfg->tcx5SizeFB, 1 );
- tcx5SizeFB = st->hTcxCfg->tcx5SizeFB;
+ tcx10SizeFB = shl( st->hTcxCfg->tcx5SizeFB, 1 ); /* Q0 */
+ tcx5SizeFB = st->hTcxCfg->tcx5SizeFB; /* Q0 */
move16();
- tcx10Size = shl( st->hTcxCfg->tcx5Size, 1 );
+ tcx10Size = shl( st->hTcxCfg->tcx5Size, 1 ); /* Q0 */
/*--------------------------------------------------------------*
* Input Signal Processing: copy, HP filter, pre-emphasis
@@ -105,8 +105,8 @@ void core_signal_analysis_high_bitrate_fx(
/* Copy Samples */
IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- Copy( new_samples, st->new_speech_enc, L_frame );
- Scale_sig( st->new_speech_enc, L_frame, 1 );
+ Copy( new_samples, st->new_speech_enc, L_frame ); /* Q0 */
+ Scale_sig( st->new_speech_enc, L_frame, 1 ); /* Q1 */
}
/*--------------------------------------------------------------*
@@ -158,16 +158,16 @@ void core_signal_analysis_high_bitrate_fx(
move16();
/* Rescale Memory */
- Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( *Q_new, st->Q_old ) );
+ Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( *Q_new, st->Q_old ) ); /* Q_new */
IF( Q_exp != 0 )
{
- Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc + st->encoderLookahead_enc, Q_exp );
+ Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc + st->encoderLookahead_enc, Q_exp ); /* Q15 - exp_buf_speech_enc_pe + Q_exp */
Scale_sig( &( st->mem_wsp_enc ), 1, Q_exp );
}
IF( EQ_16( hTcxEnc->tcxMode, TCX_10 ) )
{
- Copy( ¶m_core[1 + NOISE_FILL_RANGES], ¶m_core[NPRM_DIV + 1 + NOISE_FILL_RANGES], LTPSIZE );
+ Copy( ¶m_core[1 + NOISE_FILL_RANGES], ¶m_core[NPRM_DIV + 1 + NOISE_FILL_RANGES], LTPSIZE ); /* Q0 */
}
@@ -178,19 +178,19 @@ void core_signal_analysis_high_bitrate_fx(
{
lsp[0] = lsp_new;
lsp[1] = lsp_mid;
- alw_pitch_lag_12k8[0] = st->pitch[0];
+ alw_pitch_lag_12k8[0] = st->pitch[0]; /* Q0 */
move16();
- alw_pitch_lag_12k8[1] = st->pitch[1];
+ alw_pitch_lag_12k8[1] = st->pitch[1]; /* Q0 */
move16();
- alw_voicing[0] = st->voicing_fx[0];
+ alw_voicing[0] = st->voicing_fx[0]; /* Q15 */
move16();
- alw_voicing[1] = st->voicing_fx[1];
+ alw_voicing[1] = st->voicing_fx[1]; /* Q15 */
move16();
- alw_pitch_lag_12k8_wc = s_min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] );
- alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] );
+ alw_pitch_lag_12k8_wc = s_min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] ); /* Q0 */
+ alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] ); /* Q15 */
}
- overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame */
+ overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame Q0*/
move16();
IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) )
@@ -200,14 +200,14 @@ void core_signal_analysis_high_bitrate_fx(
transform_type[0] = TCX_20;
transform_type[1] = TCX_20;
move16();
- overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame */
+ overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame Q0*/
move16();
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- alw_pitch_lag_12k8[0] = alw_pitch_lag_12k8_wc;
+ alw_pitch_lag_12k8[0] = alw_pitch_lag_12k8_wc; /* Q0 */
move16();
- alw_voicing[0] = alw_voicing_wc;
+ alw_voicing[0] = alw_voicing_wc; /* Q15 */
move16();
}
}
@@ -260,7 +260,7 @@ void core_signal_analysis_high_bitrate_fx(
move16();
}
}
- overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame */
+ overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame Q0*/
move16();
}
IF( NE_16( transform_type[0], TCX_20 ) )
@@ -273,14 +273,14 @@ void core_signal_analysis_high_bitrate_fx(
FOR( frameno = 0; frameno < nSubframes; frameno++ )
{
- L_subframe = L_frameTCX;
+ L_subframe = L_frameTCX; /* Q0 */
move16();
if ( NE_16( nSubframes, 1 ) )
L_subframe = shr( L_frameTCX, 1 );
- lpc_left_overlap_mode = overlap_mode[frameno];
+ lpc_left_overlap_mode = overlap_mode[frameno]; /* Q0 */
move16();
- lpc_right_overlap_mode = overlap_mode[frameno + 1];
+ lpc_right_overlap_mode = overlap_mode[frameno + 1]; /* Q0 */
move16();
if ( EQ_16( lpc_left_overlap_mode, ALDO_WINDOW ) )
{
@@ -319,7 +319,7 @@ void core_signal_analysis_high_bitrate_fx(
FOR( i = 0; i < folding_offset; i++ )
{
#ifdef BASOP_NOGLOB
- tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] );
+ tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); // Q0
#else
tcx20Win[folding_offset + i] = sub( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] );
#endif
@@ -339,18 +339,18 @@ void core_signal_analysis_high_bitrate_fx(
FOR( i = 0; i < tmp; i++ )
{
#ifdef BASOP_NOGLOB
- tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] );
+ tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); // Q0
#else
tcx20Win[L_subframe + folding_offset - 1 - i] = add( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] );
#endif
move16();
}
/* 2xTCX5 */
- L_subframe = tcx5SizeFB;
+ L_subframe = tcx5SizeFB; /* Q0 */
move16();
tmpP16 = tcx20Win;
- tmpP32 = spectrum[frameno];
+ tmpP32 = spectrum[frameno]; /* exp(spectrum) */
assert( st->mct_chan_mode != MCT_CHAN_MODE_LFE );
FOR( i = 0; i < 2; i++ )
{
@@ -411,7 +411,7 @@ void core_signal_analysis_high_bitrate_fx(
FOR( i = 0; i < L_subframe; i++ )
{
- tmp_buf[i] = Mpy_32_16_1( tmp_buf[i], tmp1 );
+ tmp_buf[i] = Mpy_32_16_1( tmp_buf[i], tmp1 ); /* Q - 4 */
move32();
}
Q = sub( Q, tmp2 );
@@ -579,9 +579,9 @@ void core_signal_analysis_high_bitrate_fx(
/* group sub-windows: interleave bins according to their frequencies */
FOR( i = 0; i < tcx5SizeFB; i++ )
{
- interleaveBuf[2 * i] = spectrum[frameno][i];
+ interleaveBuf[2 * i] = spectrum[frameno][i]; /* exp(spectrum_e) */
move32();
- interleaveBuf[2 * i + 1] = spectrum[frameno][tcx5SizeFB + i];
+ interleaveBuf[2 * i + 1] = spectrum[frameno][tcx5SizeFB + i]; /* exp(spectrum_e) */
move32();
}
MVR2R_WORD32( interleaveBuf, spectrum[frameno], tcx10SizeFB );
@@ -617,7 +617,7 @@ void core_signal_analysis_high_bitrate_fx(
}
/* Copy memory */
- MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M );
+ MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M ); /* Q15 */
}
}
@@ -632,20 +632,20 @@ void core_signal_analysis_high_bitrate_fx(
void core_signal_analysis_high_bitrate_ivas_fx(
const Word16 *new_samples, /*i: Q0 */
- const Word16 T_op[3], /* i : open-loop pitch values for quantiz. */
+ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/
Word16 lsp_new[], /* Q15 */
Word16 lsp_mid[], /* Q15 */
Encoder_State *st,
- Word16 pTnsSize[],
- Word16 pTnsBits[],
- Word16 param_core[],
- Word16 *ltpBits,
- Word32 *windowed_samples,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- const Word16 last_element_mode,
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- Word32 **spectrum,
+ Word16 pTnsSize[], /* Q0 */
+ Word16 pTnsBits[], /* Q0 */
+ Word16 param_core[], /* Q0 */
+ Word16 *ltpBits, /* Q0 */
+ Word32 *windowed_samples, /* q_win */
+ const Word16 L_frame, /* Q0 */
+ const Word16 L_frameTCX, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ Word32 **spectrum, /* exp(spectrum_e) */
Word16 *spectrum_e,
Word16 *Q_new,
Word16 *q_win )
@@ -657,13 +657,14 @@ void core_signal_analysis_high_bitrate_ivas_fx(
Word16 i, frameno;
Word16 L_subframe;
Word16 left_overlap = -1, right_overlap = -1, folding_offset;
- Word32 buf[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
- Word32 buf_powerSPec[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
- Word16 mdstWin[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for MDST windowing */
+ Word32 buf[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
+ Word32 buf_powerSPec[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
+ Word16 buf_powerSPec_exp[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
+ Word16 mdstWin[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for MDST windowing */
Word16 *pMdstWin;
Word16 lpc_left_overlap_mode, lpc_right_overlap_mode;
Word32 *powerSpec = buf_powerSPec;
- Word16 powerSpec_e;
+ Word16 *powerSpec_e = buf_powerSPec_exp;
Word16 *tcx20Win = (Word16 *) buf;
Word32 *tcx20Win_32 = buf;
Word32 interleaveBuf[N_TCX10_MAX];
@@ -692,8 +693,6 @@ void core_signal_analysis_high_bitrate_ivas_fx(
move16();
move16();
(void) vad_hover_flag;
- powerSpec_e = 0;
- move16();
Word16 *speech_ltp_fx = NULL;
Word16 *wspeech_fx = NULL;
@@ -702,6 +701,8 @@ void core_signal_analysis_high_bitrate_ivas_fx(
move16();
Word16 win_len = 0;
move16();
+ set32_fx( buf_powerSPec, 0, N_MAX + L_MDCT_OVLP_MAX );
+ set16_fx( buf_powerSPec_exp, 0, N_MAX + L_MDCT_OVLP_MAX );
if ( NE_16( last_element_mode, st->element_mode ) )
{
@@ -717,15 +718,15 @@ void core_signal_analysis_high_bitrate_ivas_fx(
test();
IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- Copy( new_samples, st->new_speech_enc, L_frame );
- Scale_sig( st->new_speech_enc, L_frame, 1 ); // Q1
+ Copy( new_samples, st->new_speech_enc, L_frame ); /* Q0 */
+ Scale_sig( st->new_speech_enc, L_frame, 1 ); // Q1
}
/*--------------------------------------------------------------*
* TCX-LTP
*---------------------------------------------------------------*/
- if ( st->element_mode == IVAS_CPE_DFT )
+ if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
{
if ( st->element_mode > EVS_MONO )
{
@@ -736,9 +737,9 @@ void core_signal_analysis_high_bitrate_ivas_fx(
wspeech_fx = st->buf_wspeech_enc + st->L_frame + idiv1616( st->L_frame, st->nb_subfr );
}
}
- else if ( st->element_mode != IVAS_CPE_MDCT )
+ else if ( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- speech_fx = st->buf_speech_enc + +st->encoderPastSamples_enc;
+ speech_fx = st->buf_speech_enc + st->encoderPastSamples_enc;
speech_ltp_fx = st->hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc;
}
@@ -746,7 +747,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
{
tcx_ltp_encode_ivas_fx( st, hTcxEnc->tcxMode, L_frame, wspeech_fx, NULL, wspeech_fx, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode );
}
- ELSE IF( st->element_mode != IVAS_CPE_MDCT )
+ ELSE IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
tcx_ltp_encode_ivas_fx( st, hTcxEnc->tcxMode, L_frame, speech_fx + st->encoderLookahead_enc, speech_ltp_fx + st->encoderLookahead_enc, speech_fx + st->encoderLookahead_enc, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode );
}
@@ -764,23 +765,27 @@ void core_signal_analysis_high_bitrate_ivas_fx(
Q_exp = sub( *Q_new, st->prev_Q_new );
move16();
- Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( *Q_new, st->Q_old ) ); // *Q_new
+ Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( *Q_new, sub( Q15, st->exp_old_inp_16k ) ) ); // *Q_new
+ st->exp_old_inp_16k = sub( Q15, *Q_new );
+ move16();
IF( Q_exp != 0 )
{
- Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc + st->encoderLookahead_enc, Q_exp ); // *Q_new
- Scale_sig( &( st->mem_wsp_enc ), 1, Q_exp ); // *Q_new
+ Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc + st->encoderLookahead_enc, sub( Q_exp, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); // *Q_new
+ st->exp_buf_speech_enc_pe = sub( Q15, Q_exp );
+ move16();
+ Scale_sig( &( st->mem_wsp_enc ), 1, Q_exp ); // *Q_new
}
IF( EQ_16( hTcxEnc->tcxMode, TCX_10 ) )
{
- Copy( ¶m_core[1 + NOISE_FILL_RANGES], ¶m_core[NPRM_DIV + 1 + NOISE_FILL_RANGES], LTPSIZE );
+ Copy( ¶m_core[1 + NOISE_FILL_RANGES], ¶m_core[NPRM_DIV + 1 + NOISE_FILL_RANGES], LTPSIZE ); // Q0
}
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- lsp[0] = lsp_new;
+ lsp[0] = lsp_new; // Q15
move16();
- lsp[1] = lsp_mid;
+ lsp[1] = lsp_mid; // Q15
move16();
}
@@ -790,19 +795,19 @@ void core_signal_analysis_high_bitrate_ivas_fx(
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- alw_pitch_lag_12k8[0] = st->pitch[0];
+ alw_pitch_lag_12k8[0] = st->pitch[0]; // Q0
move16();
- alw_pitch_lag_12k8[1] = st->pitch[1];
+ alw_pitch_lag_12k8[1] = st->pitch[1]; // Q0
move16();
- alw_voicing[0] = st->voicing_fx[0];
+ alw_voicing[0] = st->voicing_fx[0]; // Q15
move16();
- alw_voicing[1] = st->voicing_fx[1];
+ alw_voicing[1] = st->voicing_fx[1]; // Q15
move16();
- alw_pitch_lag_12k8_wc = s_min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] );
- alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] );
+ alw_pitch_lag_12k8_wc = s_min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] ); // Q0
+ alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] ); // Q15
}
- overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame */
+ overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame Q0*/
move16();
IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) )
@@ -813,14 +818,14 @@ void core_signal_analysis_high_bitrate_ivas_fx(
move16();
transform_type[1] = TCX_20;
move16();
- overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame */
+ overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame Q0*/
move16();
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- alw_pitch_lag_12k8[0] = alw_pitch_lag_12k8_wc;
+ alw_pitch_lag_12k8[0] = alw_pitch_lag_12k8_wc; // Q0
move16();
- alw_voicing[0] = alw_voicing_wc;
+ alw_voicing[0] = alw_voicing_wc; // Q15
move16();
}
}
@@ -873,7 +878,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
move16();
}
}
- overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame */
+ overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame Q0*/
move16();
}
@@ -889,16 +894,16 @@ void core_signal_analysis_high_bitrate_ivas_fx(
FOR( frameno = 0; frameno < nSubframes; frameno++ )
{
- L_subframe = L_frameTCX;
+ L_subframe = L_frameTCX; // Q0
move16();
IF( NE_16( nSubframes, 1 ) )
{
L_subframe = shr( L_frameTCX, 1 );
}
- lpc_left_overlap_mode = overlap_mode[frameno];
+ lpc_left_overlap_mode = overlap_mode[frameno]; // Q0
move16();
- lpc_right_overlap_mode = overlap_mode[frameno + 1];
+ lpc_right_overlap_mode = overlap_mode[frameno + 1]; // Q0
move16();
if ( EQ_16( lpc_left_overlap_mode, ALDO_WINDOW ) )
{
@@ -919,13 +924,31 @@ void core_signal_analysis_high_bitrate_ivas_fx(
IF( windowed_samples != NULL ) /* store overlap data for later */
{
assert( frameno == 0 );
- windowed_samples[0] = L_deposit_l( overlap_mode[frameno] );
- windowed_samples[1] = L_deposit_l( overlap_mode[frameno + 1] );
+ windowed_samples[0] = L_deposit_l( overlap_mode[frameno] ); // Q0
+ windowed_samples[1] = L_deposit_l( overlap_mode[frameno + 1] ); // Q0
}
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
+ Word16 left_overlap_mode, right_overlap_mode;
+ if ( EQ_16( overlap_mode[frameno], ALDO_WINDOW ) )
+ {
+ left_overlap_mode = FULL_OVERLAP;
+ }
+ else
+ {
+ left_overlap_mode = overlap_mode[frameno]; // Q0
+ }
+
+ if ( EQ_16( overlap_mode[frameno + 1], ALDO_WINDOW ) )
+ {
+ right_overlap_mode = FULL_OVERLAP;
+ }
+ else
+ {
+ right_overlap_mode = overlap_mode[frameno + 1]; // Q0
+ }
/* Windowing of the 2xTCX5 subframes or 1xTCX10 or 1xTCX20 */
- WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 1, 1 );
+ WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, left_overlap_mode, right_overlap_mode, &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 1, 1 );
}
}
ELSE
@@ -939,13 +962,13 @@ void core_signal_analysis_high_bitrate_ivas_fx(
{
assert( L_subframe + ( left_overlap + right_overlap ) / 2 < 2 * L_FRAME_MAX / nSubframes - L_FRAME_MAX / 8 );
win_len = add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) );
- windowed_samples[frameno * L_FRAME_MAX + 0] = L_deposit_l( overlap_mode[frameno] );
- windowed_samples[frameno * L_FRAME_MAX + 1] = L_deposit_l( overlap_mode[frameno + 1] );
- Copy_Scale_sig_16_32( tcx20Win, windowed_samples + frameno * L_FRAME_MAX + 2, L_subframe + ( left_overlap + right_overlap ) / 2, 0 );
- *q_win = s_min( *q_win, sub( L_norm_arr( windowed_samples + frameno * L_FRAME_MAX + 2, L_subframe + ( left_overlap + right_overlap ) / 2 ), 1 ) );
+ windowed_samples[frameno * L_FRAME_MAX + 0] = L_deposit_l( overlap_mode[frameno] ); // Q0
+ windowed_samples[frameno * L_FRAME_MAX + 1] = L_deposit_l( overlap_mode[frameno + 1] ); // Q0
+ Copy_Scale_sig_16_32( tcx20Win, windowed_samples + add( imult1616( frameno, L_FRAME_MAX ), 2 ), add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ), 0 );
+ *q_win = s_min( *q_win, sub( L_norm_arr( windowed_samples + add( imult1616( frameno, L_FRAME_MAX ), 2 ), add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ) ), 1 ) );
move16();
#ifdef MSAN_FIX
- Scale_sig32( windowed_samples + frameno * L_FRAME_MAX + 2, win_len, *q_win );
+ Scale_sig32( windowed_samples + frameno * L_FRAME_MAX + 2, win_len, *q_win ); // q_win
#endif
}
}
@@ -958,7 +981,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
FOR( i = 0; i < folding_offset; i++ )
{
#ifdef BASOP_NOGLOB
- tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] );
+ tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); // Q0
#else
tcx20Win[folding_offset + i] = sub( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] );
#endif
@@ -1003,7 +1026,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
FOR( i = 0; i < tmp; i++ )
{
#ifdef BASOP_NOGLOB
- tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] );
+ tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); // Q0
#else
tcx20Win[L_subframe + folding_offset - 1 - i] = add( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] );
#endif
@@ -1070,7 +1093,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
Word16 Q;
Q = q_out_wtda;
- edct_fx( tcx20Win_32, hTcxEnc->spectrum_fx[frameno], L_subframe, &Q );
+ edct_ivas_fx( tcx20Win_32, hTcxEnc->spectrum_fx[frameno], L_subframe, &Q );
hTcxEnc->spectrum_e[frameno] = sub( 31, Q );
move16();
@@ -1154,14 +1177,14 @@ void core_signal_analysis_high_bitrate_ivas_fx(
/* Compute noise-measure flags for spectrum filling and quantization */
AnalyzePowerSpectrum_ivas_fx( st, div_l( L_mult( L_subframe, st->L_frame ), hTcxEnc->L_frameTCX ),
L_subframe, left_overlap, right_overlap, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_e[frameno],
- pMdstWin, powerSpec, &powerSpec_e );
+ pMdstWin, powerSpec, powerSpec_e );
}
}
}
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- L_subframe = idiv1616( L_frameTCX, nSubframes );
+ L_subframe = idiv1616( L_frameTCX, nSubframes ); /* Q0 */
test();
IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) )
@@ -1181,7 +1204,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
FOR( i = 0; i < left_overlap / 2; i++ )
{
#ifdef BASOP_NOGLOB
- mdstWin[left_overlap / 2 + i] = add_sat( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] );
+ mdstWin[left_overlap / 2 + i] = add_sat( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] ); // Q0
#else
mdstWin[left_overlap / 2 + i] = add( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] );
#endif
@@ -1223,7 +1246,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
FOR( i = 0; i < right_overlap / 2; i++ )
{
#ifdef BASOP_NOGLOB
- mdstWin[L_subframe + left_overlap / 2 - 1 - i] = sub_sat( mdstWin[L_subframe + left_overlap / 2 - 1 - i], mdstWin[L_subframe + left_overlap / 2 + i] );
+ mdstWin[L_subframe + left_overlap / 2 - 1 - i] = sub_sat( mdstWin[L_subframe + left_overlap / 2 - 1 - i], mdstWin[L_subframe + left_overlap / 2 + i] ); // Q0
#else
mdstWin[L_subframe + left_overlap / 2 - 1 - i] = sub( mdstWin[L_subframe + left_overlap / 2 - 1 - i], mdstWin[L_subframe + left_overlap / 2 + i] );
#endif
@@ -1358,9 +1381,9 @@ void core_signal_analysis_high_bitrate_ivas_fx(
/* group sub-windows: interleave bins according to their frequencies */
FOR( i = 0; i < tcx5SizeFB; i++ )
{
- interleaveBuf[2 * i] = hTcxEnc->spectrum_fx[frameno][i];
+ interleaveBuf[2 * i] = hTcxEnc->spectrum_fx[frameno][i]; /* hTcxEnc->spectrum_e */
move32();
- interleaveBuf[2 * i + 1] = hTcxEnc->spectrum_fx[frameno][tcx5SizeFB + i];
+ interleaveBuf[2 * i + 1] = hTcxEnc->spectrum_fx[frameno][tcx5SizeFB + i]; /* hTcxEnc->spectrum_e */
move32();
}
MVR2R_WORD32( interleaveBuf, hTcxEnc->spectrum_fx[frameno], tcx10SizeFB );
@@ -1392,10 +1415,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
IF( st->igf )
{
Word16 q_spectrum = sub( Q31, hTcxEnc->spectrum_e[frameno] );
- Word16 q_powerSpec = sub( Q31, powerSpec_e );
- st->hIGFEnc->spec_be_igf_e = hTcxEnc->spectrum_e[frameno];
- move16();
- ProcessIGF_ivas_fx( st, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, &q_powerSpec, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag );
+ ProcessIGF_ivas_fx( st, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag );
}
}
}
diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c
index 47408845100650353abdfd4e1c633078c2dfd84a..5c493876bab2caeb84ae0a6f9db36e2bcd1c5371 100644
--- a/lib_enc/fd_cng_enc.c
+++ b/lib_enc/fd_cng_enc.c
@@ -73,39 +73,39 @@
* Perform noise estimation
*-------------------------------------------------------------------*/
void perform_noise_estimation_enc_ivas_fx(
- Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */
+ Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/
Word16 band_energies_exp,
- Word32 *enerBuffer,
+ Word32 *enerBuffer, /* enerBuffer_exp */
Word16 enerBuffer_exp,
HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */
- const Word32 input_Fs, /* i : input sampling rate */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */
)
{
Word16 i, j, s, s1, s2;
Word16 numBands;
- Word16 numCoreBands = hFdCngEnc->hFdCngCom->numCoreBands;
+ Word16 numCoreBands = hFdCngEnc->hFdCngCom->numCoreBands; /* Q0 */
move16();
- Word16 regularStopBand = hFdCngEnc->hFdCngCom->regularStopBand;
+ Word16 regularStopBand = hFdCngEnc->hFdCngCom->regularStopBand; /* Q0 */
move16();
- Word16 numSlots = hFdCngEnc->hFdCngCom->numSlots;
+ Word16 numSlots = hFdCngEnc->hFdCngCom->numSlots; /* Q0 */
move16();
assert( numSlots == 16 );
Word32 numSlots_inv_fx = 134217728;
move32();
- Word32 *periodog = hFdCngEnc->hFdCngCom->periodog;
+ Word32 *periodog = hFdCngEnc->hFdCngCom->periodog; /* exp(peridog_exp) */
Word32 *ptr_per_fx = periodog;
- Word16 npart = hFdCngEnc->hFdCngCom->npart;
+ Word16 npart = hFdCngEnc->hFdCngCom->npart; /* Q0 */
move16();
- Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart;
+ Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart; /* Q0 */
move16();
- Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart;
+ Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart; /* Q0 */
move16();
- Word16 *psize = hFdCngEnc->hFdCngCom->psize;
+ Word16 *psize = hFdCngEnc->hFdCngCom->psize; // 6Q9
Word32 *msPeriodog_fx = hFdCngEnc->msPeriodog_fx;
- Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx;
+ Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx; /* exp(msNoiseEst_fx_exp) */
Word16 *msLogPeriodog_fx = hFdCngEnc->msLogPeriodog_fx;
Word16 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_fx;
@@ -170,7 +170,7 @@ void perform_noise_estimation_enc_ivas_fx(
/* Adjust to the desired time resolution by averaging the periodograms over the time slots */
FOR( j = numCoreBands; j < regularStopBand; j++ )
{
- *ptr_per_fx = Mpy_32_32( enerBuffer[j], scaleEB_fx );
+ *ptr_per_fx = Mpy_32_32( enerBuffer[j], scaleEB_fx ); /* exp(enerBuffer_exp) */
move32();
ptr_per_fx++;
@@ -181,7 +181,7 @@ void perform_noise_estimation_enc_ivas_fx(
hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP );
move16();
- numBands = sub( regularStopBand, numCoreBands );
+ numBands = sub( regularStopBand, numCoreBands ); /* Q0 */
IF( numBands > 0 )
{
@@ -211,13 +211,13 @@ void perform_noise_estimation_enc_ivas_fx(
FOR( i = 0; i < nFFTpart; i++ )
{
- msPeriodog_fx[i] = L_shr( msPeriodog_fx[i], s1 );
+ msPeriodog_fx[i] = L_shr( msPeriodog_fx[i], s1 ); /* hFdCngEnc->msPeriodog_fx_exp_fft */
move32();
}
FOR( i = 0; i < nCLDFBpart; i++ )
{
- msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s_min( 31, s2 ) );
+ msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s_min( 31, s2 ) ); /* hFdCngEnc->msPeriodog_fx_exp_fft */
move32();
}
}
@@ -425,14 +425,14 @@ void FdCng_encodeSID_ivas_fx(
/* NB last band energy compensation */
IF( hFdCngCom->CngBandwidth == NB )
{
- hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE );
+ hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp)
move32();
}
test();
IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) )
{
- hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE );
+ hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp)
move32();
}
@@ -485,7 +485,7 @@ void FdCng_encodeSID_ivas_fx(
*-------------------------------------------------------------------*/
void stereoFdCngCoherence_fx(
Encoder_State **sts, /* i/o: core encoder structures */
- const Word16 last_element_mode, /* i : last element mode */
+ const Word16 last_element_mode, /* i : last element mode Q0*/
Word16 fft_buf_fx[CPE_CHANNELS][2 * L_FFT], /* i : fft buffers for L and R channels fft_exp*/
Word16 fft_exp )
{
@@ -508,9 +508,9 @@ void stereoFdCngCoherence_fx(
/* case: at least one channel has triggered VAD -> ACTIVE FRAME */
IF( EQ_32( sts[0]->core_brate, -1 ) )
{
- sts[1]->total_brate = sts[0]->total_brate;
+ sts[1]->total_brate = sts[0]->total_brate; /* Q0 */
move32();
- sts[1]->active_cnt = sts[0]->active_cnt;
+ sts[1]->active_cnt = sts[0]->active_cnt; /* Q0 */
move16();
if ( GE_32( sts[1]->active_cnt, CNG_TYPE_HO ) )
{
@@ -520,9 +520,9 @@ void stereoFdCngCoherence_fx(
}
IF( EQ_32( sts[1]->core_brate, -1 ) )
{
- sts[0]->total_brate = sts[1]->total_brate;
+ sts[0]->total_brate = sts[1]->total_brate; /* Q0 */
move32();
- sts[0]->active_cnt = sts[1]->active_cnt;
+ sts[0]->active_cnt = sts[1]->active_cnt; /* Q0 */
move16();
if ( GE_16( sts[0]->active_cnt, CNG_TYPE_HO ) )
{
@@ -556,15 +556,15 @@ void stereoFdCngCoherence_fx(
}
/* synchronize SID counters */
- sts[0]->hDtxEnc->cnt_SID = s_min( sts[0]->hDtxEnc->cnt_SID, sts[1]->hDtxEnc->cnt_SID );
- sts[1]->hDtxEnc->cnt_SID = sts[0]->hDtxEnc->cnt_SID;
+ sts[0]->hDtxEnc->cnt_SID = s_min( sts[0]->hDtxEnc->cnt_SID, sts[1]->hDtxEnc->cnt_SID ); /* Q0 */
+ sts[1]->hDtxEnc->cnt_SID = sts[0]->hDtxEnc->cnt_SID; /* Q0 */
move16();
move16();
}
pt_fftL = fft_buf_fx[0];
pt_fftR = fft_buf_fx[1];
- mem = sts[0]->hFdCngEnc->mem_coherence_fx;
+ mem = sts[0]->hFdCngEnc->mem_coherence_fx; /* exp(sts[0]->hFdCngEnc->mem_coherence_exp) */
mem_exp = sts[0]->hFdCngEnc->mem_coherence_exp;
FOR( i_subfr = 0; i_subfr < 2; i_subfr++ )
{
@@ -579,28 +579,28 @@ void stereoFdCngCoherence_fx(
move16();
move16();
- cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp );
- eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp );
- eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp );
+ cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */
+ eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */
+ eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */
FOR( i = 1; i < L_FFT / 2; i++ )
{
- cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp );
- ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp );
- eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp );
- eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp );
+ cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */
+ ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */
+ eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */
+ eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */
}
test();
test();
IF( LE_32( sts[0]->ini_frame, 50 ) || ( sts[0]->vad_flag == 0 && sts[1]->vad_flag == 0 ) )
{
- mem[0] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[0], 31129 /*0.95f*/ ), mem_exp[0], Mpy_32_16_1( cr, 1638 /*0.05f*/ ), cr_exp, &mem_exp[0] );
+ mem[0] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[0], 31129 /*0.95f*/ ), mem_exp[0], Mpy_32_16_1( cr, 1638 /*0.05f*/ ), cr_exp, &mem_exp[0] ); /* exp(mem_exp[0]) */
move32();
- mem[1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[1], 31129 /*0.95f*/ ), mem_exp[1], Mpy_32_16_1( ci, 1638 /*0.05f*/ ), ci_exp, &mem_exp[1] );
+ mem[1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[1], 31129 /*0.95f*/ ), mem_exp[1], Mpy_32_16_1( ci, 1638 /*0.05f*/ ), ci_exp, &mem_exp[1] ); /* exp(mem_exp[1]) */
move32();
- mem[2] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[2], 31129 /*0.95f*/ ), mem_exp[2], Mpy_32_16_1( eL, 1638 /*0.05f*/ ), eL_exp, &mem_exp[2] );
+ mem[2] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[2], 31129 /*0.95f*/ ), mem_exp[2], Mpy_32_16_1( eL, 1638 /*0.05f*/ ), eL_exp, &mem_exp[2] ); /* exp(mem_exp[2]) */
move32();
- mem[3] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[3], 31129 /*0.95f*/ ), mem_exp[3], Mpy_32_16_1( eR, 1638 /*0.05f*/ ), eR_exp, &mem_exp[3] );
+ mem[3] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[3], 31129 /*0.95f*/ ), mem_exp[3], Mpy_32_16_1( eR, 1638 /*0.05f*/ ), eR_exp, &mem_exp[3] ); /* exp(mem_exp[3]) */
move32();
}
@@ -609,7 +609,7 @@ void stereoFdCngCoherence_fx(
}
Word16 sqr_inp, temp, sqr_out, sqr_inp_exp;
- Word32 sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp );
+ Word32 sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp ); /* exp(sqr_inp_exp) */
sqr_inp = BASOP_Util_Divide3232_Scale( sqr_inp32, Mpy_32_32( mem[2], mem[3] ), &temp );
sqr_inp_exp = add( temp, sub( sqr_inp_exp, add( mem_exp[2], mem_exp[3] ) ) );
sqr_out = Sqrt16( sqr_inp, &sqr_inp_exp );
@@ -666,13 +666,13 @@ void FdCngEncodeMDCTStereoSID_fx(
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts[ch] = hCPE->hCoreCoder[ch];
- lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0];
+ lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; /* exp(sts[ch]->hFdCngEnc->msNoiseEst_fx_exp) */
lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp;
ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0];
- lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0];
+ lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; /* exp(sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp) */
lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp;
}
- N = sts[0]->hFdCngEnc->npartDec;
+ N = sts[0]->hFdCngEnc->npartDec; /* Q0 */
move16();
set16_fx( weights_fx, ONE_IN_Q8, NPART );
@@ -733,14 +733,14 @@ void FdCngEncodeMDCTStereoSID_fx(
move32();
FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ )
{
- tmp32 = Mpy_32_32( ms_ptr_fx[ch][p], 165191050 ); // Q23
- gain_fx[ch] = L_add( gain_fx[ch], tmp32 ); // Q23
+ tmp32 = Mpy_32_32( ms_ptr_fx[ch][p], 165191050 /* 0.07 in Q31*/ ); // Q23
+ gain_fx[ch] = L_add( gain_fx[ch], tmp32 ); // Q23
move32();
}
FOR( p = 0; p < N; p++ )
{
- ms_ptr_fx[ch][p] = L_sub( ms_ptr_fx[ch][p], gain_fx[ch] );
+ ms_ptr_fx[ch][p] = L_sub( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q23
move32();
}
}
@@ -823,7 +823,7 @@ void FdCngEncodeMDCTStereoSID_fx(
tmp = Inv16( N, &tmp_e );
FOR( p = 0; p < N; p++ )
{
- gain_fx[ch] = L_add( gain_fx[ch], Mpy_32_16_1( ms_ptr_fx[ch][p], shl( tmp, tmp_e ) ) );
+ gain_fx[ch] = L_add( gain_fx[ch], Mpy_32_16_1( ms_ptr_fx[ch][p], shl( tmp, tmp_e ) ) ); // Q23
move32();
}
gain_fx[ch] = L_sub( L_shl( Mpy_32_16_1( E_fx[ch], shl( tmp, tmp_e ) ), Q23 - Q19 ), L_shl( gain_fx[ch], sub( ms_ptr_e, 8 ) ) ); // Q23
@@ -832,7 +832,7 @@ void FdCngEncodeMDCTStereoSID_fx(
apply_scale( &gain_fx[ch], sts[ch]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[ch]->element_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO );
/* quantize gain */
- gain_idx[ch] = (Word16) Mpy_32_32_r( L_add( gain_fx[ch], 251658240 ), 384 );
+ gain_idx[ch] = (Word16) Mpy_32_32_r( L_add( gain_fx[ch], 251658240 ), 384 ); // Q23
move16();
gain_idx[ch] = s_max( 0, s_min( 127, gain_idx[ch] ) );
move16();
@@ -1008,14 +1008,14 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
move16();
FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ )
{
- tmp32 = Mpy_32_32( ms_ptr_fx[0][p], 165191050 ); // Q23
- gain_fx[0] = L_add( gain_fx[0], tmp32 ); // Q23
+ tmp32 = Mpy_32_32( ms_ptr_fx[0][p], 165191050 /* 0.07 in Q31 */ ); // Q23
+ gain_fx[0] = L_add( gain_fx[0], tmp32 ); // Q23
move32();
}
FOR( p = 0; p < N[0]; p++ )
{
- ms_ptr_fx[0][p] = L_sub( ms_ptr_fx[0][p], gain_fx[0] );
+ ms_ptr_fx[0][p] = L_sub( ms_ptr_fx[0][p], gain_fx[0] ); // Q23
move32();
}
@@ -1035,7 +1035,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
extend_dctN_input_fx( ms_ptr_fx[0], dct_target_fx, N[0], tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/
- Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */
+ Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 Q23*/
}
create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) );
@@ -1043,7 +1043,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N[0], FD_CNG_maxN_37bits, indices[0], 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 );
shift = find_guarded_bits_fx( N[0] );
ms_ptr_e = sub( 31, sub( 20, shift ) );
- scale_sig32( ms_ptr_fx[1], N[1], sub( 8, ms_ptr_e ) );
+ scale_sig32( ms_ptr_fx[1], N[1], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */
/* set S to zero */
set32_fx( ms_ptr_fx[1], 0, NPART );
@@ -1056,7 +1056,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
tmp = Inv16( N[0], &tmp_e );
FOR( p = 0; p < N[0]; p++ )
{
- gain_fx[0] = L_add( gain_fx[0], Mpy_32_16_1( ms_ptr_fx[0][p], shl( tmp, tmp_e ) ) );
+ gain_fx[0] = L_add( gain_fx[0], Mpy_32_16_1( ms_ptr_fx[0][p], shl( tmp, tmp_e ) ) ); // Q23
move32();
}
gain_fx[0] = L_sub( L_shl( Mpy_32_16_1( E_fx[0], shl( tmp, tmp_e ) ), Q23 - Q18 ), L_shl( gain_fx[0], ms_ptr_e - 8 ) ); // Q23
@@ -1070,7 +1070,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
gain_idx[0] = s_max( 0, s_min( 127, gain_idx[0] ) );
move16();
- gain_fx[0] = Mpy_32_16_1( L_shl( sub( gain_idx[0], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 ); // Q23
+ gain_fx[0] = Mpy_32_16_1( L_shl( sub( gain_idx[0], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 /* 0.66 in Q15 */ ); // Q23
move32();
gain_fx[1] = gain_fx[0]; // Q23
move32();
@@ -1089,9 +1089,9 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
tmp_e = -MAX_16;
FOR( p = 0; p < N[ch]; p++ )
{
- pow = L_shl( gain_fx[ch], sub( 8, ms_ptr_e ) );
- pow = L_add( ms_ptr_fx[ch][p], pow );
- pow = Mpy_32_32( pow, 214748365 ); /*pow = 0.1*/
+ pow = L_shl( gain_fx[ch], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */
+ pow = L_add( ms_ptr_fx[ch][p], pow ); /* Q31 - ms_ptr_e */
+ pow = Mpy_32_32( pow, 214748365 /* 0.1 in Q31 */ ); /*pow = 0.1 Q31 - ms_ptr_e*/
lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] );
tmp_e = s_max( tmp_e, e_lr_out[p] );
}
@@ -1109,12 +1109,12 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
/* NB last band energy compensation */
IF( hFdCngCom->CngBandwidth == NB )
{
- lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], NB_LAST_BAND_SCALE );
+ lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], NB_LAST_BAND_SCALE ); // Q(31 - tmp_e)
move32();
}
ELSE IF( hFdCngCom->CngBandwidth == SWB && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) )
{
- lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], SWB_13k2_LAST_BAND_SCALE );
+ lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], SWB_13k2_LAST_BAND_SCALE ); // Q(31 - tmp_e)
move32();
}
/* scale bands and get scalefactors */
diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c
index 34b67b2ff575ffc52bfd6e7505d1a74921c26d89..8591f2627520c77121199284c3c78f349c58c059 100644
--- a/lib_enc/fd_cng_enc_fx.c
+++ b/lib_enc/fd_cng_enc_fx.c
@@ -51,7 +51,10 @@ void createFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc )
return;
}
-void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
+void initFdCngEnc_fx(
+ HANDLE_FD_CNG_ENC hsEnc,
+ Word32 input_Fs, /* Q0 */
+ Word16 scale )
{
Word16 j;
HANDLE_FD_CNG_COM hsCom = hsEnc->hFdCngCom;
@@ -65,7 +68,7 @@ void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
move16();
hsCom->numCoreBands = 16;
move16();
- hsCom->regularStopBand = idiv1616U( extract_l( L_shr( input_Fs, 5 ) ), 25 );
+ hsCom->regularStopBand = idiv1616U( extract_l( L_shr( input_Fs, 5 ) ), 25 ); /* Q0 */
move16();
if ( GT_16( hsCom->regularStopBand, 40 ) )
{
@@ -88,7 +91,7 @@ void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
{
hsCom->stopFFTbin = 256;
move16();
- hsCom->stopBand = add( sub( hsCom->regularStopBand, hsCom->numCoreBands ), hsCom->stopFFTbin );
+ hsCom->stopBand = add( sub( hsCom->regularStopBand, hsCom->numCoreBands ), hsCom->stopFFTbin ); /* Q0 */
move16();
hsCom->nFFTpart = 20;
move16();
@@ -96,12 +99,12 @@ void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
initPartitions( sidparts_encoder_noise_est, SIZE_SIDPARTS_ENC_NOISE_EST, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 );
- hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart );
+ hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); /* Q0 */
move16();
FOR( j = 0; j < hsCom->nCLDFBpart; j++ )
{
- hsCom->CLDFBpart[j] = sub( hsCom->part[j + hsCom->nFFTpart], sub( 256, hsCom->startBand ) );
- hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart];
+ hsCom->CLDFBpart[j] = sub( hsCom->part[j + hsCom->nFFTpart], sub( 256, hsCom->startBand ) ); /* Q0 */
+ hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart]; /* Q15 */
move16();
move16();
}
@@ -151,8 +154,9 @@ void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
* Configure FD_CNG *
************************************/
void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables related to the FD-based CNG process */
- Word16 bandwidth, /* i: bandwidth */
- Word32 bitrate )
+ Word16 bandwidth, /* i: bandwidth Q0*/
+ Word32 bitrate /* Q0 */
+)
{
HANDLE_FD_CNG_COM hsCom = hsEnc->hFdCngCom;
Word16 psizeDec[NPART];
@@ -169,7 +173,7 @@ void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variabl
hsCom->CngBandwidth = SWB;
move16();
}
- hsCom->CngBitrate = bitrate;
+ hsCom->CngBitrate = bitrate; /* Q0 */
move32();
/* NB configuration */
@@ -212,16 +216,16 @@ void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variabl
hsCom->FdCngSetup = FdCngSetup_swb2;
}
}
- hsCom->fftlen = hsCom->FdCngSetup.fftlen;
+ hsCom->fftlen = hsCom->FdCngSetup.fftlen; /* Q0 */
move16();
- hsEnc->stopFFTbinDec = hsCom->FdCngSetup.stopFFTbin;
+ hsEnc->stopFFTbinDec = hsCom->FdCngSetup.stopFFTbin; /* Q0 */
move16();
/* Configure the SID quantizer and the Confort Noise Generator */
- hsEnc->startBandDec = hsCom->startBand;
+ hsEnc->startBandDec = hsCom->startBand; /* Q0 */
move16();
- hsEnc->stopBandDec = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 );
+ hsEnc->stopBandDec = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 ); /* Q0 */
move16();
initPartitions( hsCom->FdCngSetup.sidPartitions,
hsCom->FdCngSetup.numPartitions,
@@ -277,8 +281,9 @@ void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variabl
void configureFdCngEnc_ivas_fx(
HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
- const Word16 bwidth,
- const Word32 total_brate )
+ const Word16 bwidth, /* Q0 */
+ const Word32 total_brate /* Q0 */
+)
{
HANDLE_FD_CNG_COM hsCom = hFdCngEnc->hFdCngCom;
Word16 psizeDec[NPART];
@@ -288,14 +293,14 @@ void configureFdCngEnc_ivas_fx(
set16_fx( psizeDec, 0, NPART );
- hsCom->CngBandwidth = bwidth;
+ hsCom->CngBandwidth = bwidth; /* Q0 */
move16();
IF( EQ_16( hsCom->CngBandwidth, FB ) )
{
hsCom->CngBandwidth = SWB;
move16();
}
- hsCom->CngBitrate = total_brate;
+ hsCom->CngBitrate = total_brate; /* Q0 */
move32();
/* NB configuration */
@@ -338,16 +343,16 @@ void configureFdCngEnc_ivas_fx(
hsCom->FdCngSetup = FdCngSetup_swb2;
}
}
- hsCom->fftlen = hsCom->FdCngSetup.fftlen;
+ hsCom->fftlen = hsCom->FdCngSetup.fftlen; /* Q0 */
move16();
- hFdCngEnc->stopFFTbinDec = hsCom->FdCngSetup.stopFFTbin;
+ hFdCngEnc->stopFFTbinDec = hsCom->FdCngSetup.stopFFTbin; /* Q0 */
move16();
/* Configure the SID quantizer and the Confort Noise Generator */
- hFdCngEnc->startBandDec = hsCom->startBand;
+ hFdCngEnc->startBandDec = hsCom->startBand; /* Q0 */
move16();
- hFdCngEnc->stopBandDec = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 );
+ hFdCngEnc->stopBandDec = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 ); /* Q0 */
move16();
initPartitions( hsCom->FdCngSetup.sidPartitions,
hsCom->FdCngSetup.numPartitions,
@@ -381,17 +386,17 @@ void configureFdCngEnc_ivas_fx(
{
case 512:
hsCom->fftSineTab_fx = NULL;
- hsCom->olapWinAna_fx = olapWinAna512_fx;
- hsCom->olapWinSyn_fx = olapWinSyn256_fx;
+ hsCom->olapWinAna_fx = olapWinAna512_fx; /* Q30 */
+ hsCom->olapWinSyn_fx = olapWinSyn256_fx; /* Q15 */
hsCom->fftlenShift = 8;
move16();
hsCom->fftlenFac = 32767 /*1.0 Q15*/;
move16();
BREAK;
case 640:
- hsCom->fftSineTab_fx = fftSineTab640_fx;
- hsCom->olapWinAna_fx = olapWinAna640_fx;
- hsCom->olapWinSyn_fx = olapWinSyn320_fx;
+ hsCom->fftSineTab_fx = fftSineTab640_fx; /* Q15 */
+ hsCom->olapWinAna_fx = olapWinAna640_fx; /* Q30 */
+ hsCom->olapWinSyn_fx = olapWinSyn320_fx; /* Q15 */
hsCom->fftlenShift = 9;
move16();
hsCom->fftlenFac = 20480 /*0.625 Q15*/;
@@ -440,8 +445,8 @@ void resetFdCngEnc_fx(
/* st->totalNoise_fx; Q8 Noise estimator - total noise energy */
/* Detect fast increase of totalNoise */
- totalNoiseIncrease = sub( hNoiseEst->totalNoise_fx, st->last_totalNoise_fx );
- st->last_totalNoise_fx = hNoiseEst->totalNoise_fx;
+ totalNoiseIncrease = sub( hNoiseEst->totalNoise_fx, st->last_totalNoise_fx ); // Q8
+ st->last_totalNoise_fx = hNoiseEst->totalNoise_fx; // Q8
move16();
IF( totalNoiseIncrease > 0 )
{
@@ -449,17 +454,17 @@ void resetFdCngEnc_fx(
{
FOR( n = 0; n < TOTALNOISE_HIST_SIZE - 1; n++ )
{
- st->totalNoise_increase_hist_fx[n] = st->totalNoise_increase_hist_fx[n + 1];
+ st->totalNoise_increase_hist_fx[n] = st->totalNoise_increase_hist_fx[n + 1]; // Q8
move16();
}
- st->totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE - 1] = totalNoiseIncrease;
+ st->totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE - 1] = totalNoiseIncrease; // Q8
move16();
}
ELSE
{
- st->totalNoise_increase_hist_fx[st->totalNoise_increase_len] = totalNoiseIncrease;
+ st->totalNoise_increase_hist_fx[st->totalNoise_increase_len] = totalNoiseIncrease; // Q8
move16();
- st->totalNoise_increase_len = add( st->totalNoise_increase_len, 1 );
+ st->totalNoise_increase_len = add( st->totalNoise_increase_len, 1 ); // Q0
}
}
ELSE
@@ -471,7 +476,7 @@ void resetFdCngEnc_fx(
move16();
FOR( n = 0; n < st->totalNoise_increase_len; n++ )
{
- totalNoiseIncrease = add( totalNoiseIncrease, st->totalNoise_increase_hist_fx[n] );
+ totalNoiseIncrease = add( totalNoiseIncrease, st->totalNoise_increase_hist_fx[n] ); // Q8
}
test();
@@ -518,9 +523,9 @@ void resetFdCngEnc_fx(
Returns:
void
*/
-void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */
+void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/
Word16 band_energies_exp, /* i: exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */
- Word32 *enerBuffer,
+ Word32 *enerBuffer, /* enerBuffer_exp */
Word16 enerBuffer_exp,
HANDLE_FD_CNG_ENC st /* i/o: FD_CNG structure containing all buffers and variables */
)
@@ -560,8 +565,8 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
/* preemphasis compensation and grouping of per bin energies into msPeriodog */
FOR( i = 0; i < nFFTpart; i++ )
{
- tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) );
- msPeriodog[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] );
+ tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) ); /* exp(band_energies_exp) */
+ msPeriodog[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] ); /* exp(band_energies_exp + 4) */
move32();
}
@@ -569,7 +574,7 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
st->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP );
move16();
- numBands = sub( regularStopBand, numCoreBands );
+ numBands = sub( regularStopBand, numCoreBands ); /* Q0 */
IF( numBands > 0 )
{
@@ -577,7 +582,7 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
FOR( j = numCoreBands; j < regularStopBand; j++ )
{
- *ptr_per = Mpy_32_16_1( enerBuffer[j], st->hFdCngCom->scalingFactor );
+ *ptr_per = Mpy_32_16_1( enerBuffer[j], st->hFdCngCom->scalingFactor ); /* exp(enerBuffer_exp) */
move32();
ptr_per++;
@@ -612,13 +617,13 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
FOR( i = 0; i < nFFTpart; i++ )
{
- msPeriodog[i] = L_shr( msPeriodog[i], s1 );
+ msPeriodog[i] = L_shr( msPeriodog[i], s1 ); // st->msPeriodog_fx_exp_fft
move32();
}
FOR( i = 0; i < nCLDFBpart; i++ )
{
- msPeriodog[nFFTpart + i] = L_shr( msPeriodog[nFFTpart + i], s_min( 31, s2 ) );
+ msPeriodog[nFFTpart + i] = L_shr( msPeriodog[nFFTpart + i], s_min( 31, s2 ) ); // st->msPeriodog_fx_exp_fft
move32();
}
}
@@ -681,19 +686,18 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
Returns:
void
*/
-Word16
-AdjustFirstSID_fx(
- Word16 npart, /* i : number of parts */
- Word32 *msPeriodog, /* i : pointer to periodog vector */
- Word16 msPeriodog_exp, /* i : exponent of periodog vector */
- Word32 *energy_ho, /* i/o : pointer to energy */
- Word16 *energy_ho_exp, /* i/o : pointer to exponent of energy */
- Word32 *msNoiseEst, /* i/o : pointer to estimated noise */
- Word16 *msNoiseEst_exp, /* i/o : pointer to exponent of estimated noise */
- Word32 *msNoiseEst_old, /* i/o : pointer to old estimated noise */
- Word16 *msNoiseEst_old_exp, /* i/o : pointer to exponent of old estimated noise */
- Word16 *active_frame_counter, /* i/o : pointer to active frame counter */
- Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */
+Word16 AdjustFirstSID_fx(
+ Word16 npart, /* i : number of parts Q0*/
+ Word32 *msPeriodog, /* i : pointer to periodog vector msPeriodog_exp */
+ Word16 msPeriodog_exp, /* i : exponent of periodog vector */
+ Word32 *energy_ho, /* i/o : pointer to energy energy_ho_exp*/
+ Word16 *energy_ho_exp, /* i/o : pointer to exponent of energy */
+ Word32 *msNoiseEst, /* i/o : pointer to estimated noise msNoiseEst_exp*/
+ Word16 *msNoiseEst_exp, /* i/o : pointer to exponent of estimated noise */
+ Word32 *msNoiseEst_old, /* i/o : pointer to old estimated noise msNoiseEst_old_exp*/
+ Word16 *msNoiseEst_old_exp, /* i/o : pointer to exponent of old estimated noise */
+ Word16 *active_frame_counter, /* i/o : pointer to active frame counter Q0*/
+ Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */
)
{
Word16 i, sc, s1, s2, lambda, lambdaM1, invFac;
@@ -706,7 +710,7 @@ AdjustFirstSID_fx(
/* Detect the hangover period and the first SID frame at the beginning of each CNG phase */
/* First hangover frame */
- Copy32( msPeriodog, energy_ho, npart );
+ Copy32( msPeriodog, energy_ho, npart ); /* exp(msPeriodog_exp) */
*energy_ho_exp = msPeriodog_exp;
move16();
@@ -724,8 +728,8 @@ AdjustFirstSID_fx(
/* active_frame_counter scaled by (1/1024.0) for compensation */
tmp32 = L_shl( L_deposit_l( add( *active_frame_counter, 1 ) ), WORD32_BITS - 1 - 10 );
tmp32 = BASOP_Util_InvLog2( Mpy_32_16_1( tmp32, -30877 /*-0.94229902485 Q15*/ ) );
- lambda = extract_h( tmp32 );
- lambdaM1 = extract_h( L_sub( 0x7FFFFFFF, tmp32 ) );
+ lambda = extract_h( tmp32 ); /* Q15 */
+ lambdaM1 = extract_h( L_sub( 0x7FFFFFFF /* 1.0f in Q31*/, tmp32 ) );
}
invFac = getNormReciprocalWord16( 1 );
@@ -739,7 +743,7 @@ AdjustFirstSID_fx(
FOR( i = 0; i < npart; i++ )
{
- msNoiseEst_old[i] = Mpy_32_16_1( msNoiseEst_old[i], lambda );
+ msNoiseEst_old[i] = Mpy_32_16_1( msNoiseEst_old[i], lambda ); /* exp(msNoiseEst_old) */
move32();
tmp32 = Mpy_32_16_1( Mpy_32_16_1( energy_ho[i], invFac ), lambdaM1 );
energy_ho[i] = L_add( L_shr( msNoiseEst_old[i], s1 ), L_shr( tmp32, s2 ) );
@@ -756,16 +760,16 @@ AdjustFirstSID_fx(
move32();
FOR( i = 0; i < npart; i++ )
{
- msNoiseEst_local = L_shr( msNoiseEst[i], s1 );
- energy_ho_local = L_shr( energy_ho[i], s2 );
+ msNoiseEst_local = L_shr( msNoiseEst[i], s1 ); /* exp(msNoiseEst + s1) */
+ energy_ho_local = L_shr( energy_ho[i], s2 ); /* exp(energy_ho_exp + s2) */
IF( GT_32( msNoiseEst_local, energy_ho_local ) )
{
- msNoiseEst[i] = energy_ho_local;
+ msNoiseEst[i] = energy_ho_local; /* exp(energy_ho_exp + s2) */
move32();
}
ELSE
{
- msNoiseEst[i] = msNoiseEst_local;
+ msNoiseEst[i] = msNoiseEst_local; /* exp(energy_ho_exp + s2) */
move32();
}
if ( msNoiseEst[i] > 0 )
@@ -788,13 +792,13 @@ AdjustFirstSID_fx(
IF( NE_32( stcod->core_brate, SID_2k40 ) && NE_32( stcod->core_brate, FRAME_NO_DATA ) )
{
/* Count the number of active frames in a row */
- *active_frame_counter = add( *active_frame_counter, 1 );
+ *active_frame_counter = add( *active_frame_counter, 1 ); /* Q0 */
move16();
}
ELSE
{
/* Store the noise estimate obtained in the CNG phases */
- Copy32( msNoiseEst, msNoiseEst_old, npart );
+ Copy32( msNoiseEst, msNoiseEst_old, npart ); /* exp(msNoiseEst_exp) */
*msNoiseEst_old_exp = *msNoiseEst_exp;
move16();
}
@@ -825,14 +829,14 @@ AdjustFirstSID_fx(
Returns:
void
*/
-static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) scaled with 8 bits */
- Word16 u[], /* i : Vector to be encoded (prediction and mean removed) */
- const Word16 levels[], /* i : Number of levels in each stage */
- Word16 maxC, /* i : Tree search size */
- Word16 stages, /* i : Number of stages */
- Word16 N, /* i : Vector dimension */
- Word16 maxN, /* i : Codebook vector dimension */
- Word16 Idx[] /* o : Indices */
+static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) scaled with 8 bits Q9.7*/
+ Word16 u[], /* i : Vector to be encoded (prediction and mean removed) Q9.7*/
+ const Word16 levels[], /* i : Number of levels in each stage Q0*/
+ Word16 maxC, /* i : Tree search size Q0*/
+ Word16 stages, /* i : Number of stages Q0*/
+ Word16 N, /* i : Vector dimension Q0*/
+ Word16 maxN, /* i : Codebook vector dimension Q0*/
+ Word16 Idx[] /* o : Indices Q0*/
)
{
Word32 *dist[2];
@@ -998,7 +1002,7 @@ static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb
pTmp += N;
/* Get indices that were used for parent node */
- Copy( indices[0] + parents[c] * stages, indices[1] + c * stages, s );
+ Copy( indices[0] + parents[c] * stages, indices[1] + c * stages, s ); // Q0
}
m = maxC;
move16();
@@ -1728,10 +1732,10 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
cngNoiseLevel = st->cngNoiseLevel;
cngNoiseLevelExp = st->cngNoiseLevelExp;
move16();
- ptr_level = cngNoiseLevel;
+ ptr_level = cngNoiseLevel; // cngNoiseLevelExp
seed = &( st->seed );
- fftBuffer = st->fftBuffer;
- timeDomainOutput = st->timeDomainBuffer;
+ fftBuffer = st->fftBuffer; // st->fftBuffer_exp
+ timeDomainOutput = st->timeDomainBuffer; // Q15
/*
Generate Gaussian random noise in real and imaginary parts of the FFT bins
@@ -1748,7 +1752,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
randGaussExp = CNG_RAND_GAUSS_SHIFT;
move16();
- cnt = sub( stenc->stopFFTbinDec, stenc->startBandDec );
+ cnt = sub( stenc->stopFFTbinDec, stenc->startBandDec ); // Q)=0
IF( stenc->startBandDec == 0 )
{
/* DC component in FFT */
@@ -1886,7 +1890,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
seed_loc = st->seed;
move16();
- N = st->frameSize;
+ N = st->frameSize; // Q0
move16();
N2 = shr( st->frameSize, 1 );
@@ -1942,7 +1946,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
FOR( i = 0; i < N2; i++ )
{
- timeDomainOutput[i] = add( timeDomainOutput[i], shl( hTcxEnc->Txnq[i], TCX_IMDCT_HEADROOM ) );
+ timeDomainOutput[i] = add( timeDomainOutput[i], shl( hTcxEnc->Txnq[i], TCX_IMDCT_HEADROOM ) ); // Q15
move16();
}
}
@@ -1972,6 +1976,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
preemph_fac = stcod->preemph_fac;
move16();
Q_exc = Q_new;
+ move16();
Q_syn = sub( Q_new, 1 );
/* shift to be in the range of values supported by getNormReciprocalWord16() */
@@ -2093,12 +2098,12 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
/*! r: CNG energy */
Word16 cng_energy_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 bwidth, /* i : audio bandwidh */
- const Word16 CNG_mode, /* i : mode for DTX configuration */
- const Word16 CNG_att, /* i : attenuation factor for CNG */
- const Word16 *exc, /* i : input signal */
- const Word16 len, /* i : vector length */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 bwidth, /* i : audio bandwidh Q0*/
+ const Word16 CNG_mode, /* i : mode for DTX configuration Q0*/
+ const Word16 CNG_att, /* i : attenuation factor for CNG Q7*/
+ const Word16 *exc, /* i : input signal Q_new*/
+ const Word16 len, /* i : vector length Q0*/
const Word16 Q_new /* i : Input scaling */
)
{
@@ -2193,11 +2198,11 @@ Word16 cng_energy_fx(
/*! r: CNG energy */
Word16 cng_energy_ivas_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 bwidth, /* i : audio bandwidh */
- const Word16 CNG_mode, /* i : mode for DTX configuration */
- const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */
- const Word16 *exc, /* i : input signal */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 bwidth, /* i : audio bandwidh Q0*/
+ const Word16 CNG_mode, /* i : mode for DTX configuration Q0*/
+ const Word16 CNG_att, /* i : attenuation factor for CNG Q7*/
+ const Word16 *exc, /* i : input signal Q_new*/
const Word16 len, /* i : vector length */
const Word16 Q_new /* i : Input scaling */
)
@@ -2264,11 +2269,13 @@ Word16 cng_energy_ivas_fx(
{
/* Bitrate adapted attenuation */
att = ENR_ATT_fx[CNG_mode];
+ move16();
}
ELSE
{
/* Use least attenuation for higher bitrates */
att = ENR_ATT_fx[4];
+ move16();
}
}
ELSE
diff --git a/lib_enc/find_tar.c b/lib_enc/find_tar.c
deleted file mode 100644
index e7a8ca967132cf8896fc4a231dbaf74eed596840..0000000000000000000000000000000000000000
--- a/lib_enc/find_tar.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c
index dc8477fc42db2aab8e4093e9f80a49bddde323a6..0c138308b5e25c0edc71f12620c0a543ac76d921 100644
--- a/lib_enc/find_tar_fx.c
+++ b/lib_enc/find_tar_fx.c
@@ -14,16 +14,16 @@
void find_targets_fx(
const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 i_subfr, /* i : subframe index Q0*/
Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization */
+ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15 */
+ Word16 tilt_fac, /* i : tilt factor Q15*/
Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
Word16 *cn, /* o : target vector in residual domain Q_new*/
- Word16 *h1 /* o : impulse response of weighted synthesis filter */
+ Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/
)
{
Word16 i;
@@ -33,6 +33,7 @@ void find_targets_fx(
Word32 Ltmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*------------------------------------------------------------------------*
* Find the target vector for excitation search:
@@ -50,7 +51,7 @@ void find_targets_fx(
FOR( i = 0; i < M; i++ )
{
#ifdef BASOP_NOGLOB
- temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] );
+ temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */
#else
temp[i] = sub( speech[i + i_subfr - M], mem_syn[i] );
#endif
@@ -77,7 +78,7 @@ void find_targets_fx(
Scale_sig( cn, L_SUBFR / 2, 1 );
/* second half: res[] --> cn[] (approximated and faster) */
- Copy( &res[i_subfr + ( L_SUBFR / 2 )], cn + ( L_SUBFR / 2 ), L_SUBFR / 2 );
+ Copy( &res[i_subfr + ( L_SUBFR / 2 )], cn + ( L_SUBFR / 2 ), L_SUBFR / 2 ); /* Q_new */
}
/*---------------------------------------------------------------*
@@ -89,13 +90,13 @@ void find_targets_fx(
d = sub( scaleq, scale );
IF( d >= 0 )
{
- Copy( p_Aq, Aqs, M + 1 );
+ Copy( p_Aq, Aqs, M + 1 ); /* Q12 */
s = add( scaleq, 1 );
s2 = shr( 16384, d );
}
ELSE
{
- Copy_Scale_sig( p_Aq, Aqs, M + 1, d );
+ Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */
s = add( scale, 1 );
s2 = 16384;
}
@@ -103,32 +104,32 @@ void find_targets_fx(
move16();
FOR( i = 0; i < M; i++ )
{
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= i; j++ )
{
-#ifdef BASOP_NOGLOB /* Critical Overflow , as well as those below*/
- Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow , as well as those below*/
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
#else
Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
#endif
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
#else
h1[i] = round_fx( L_shl( Ltmp, s ) );
#endif
}
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= M; j++ )
{
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
#else
Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
#endif
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
#else
h1[M] = round_fx( L_shl( Ltmp, s ) );
#endif
@@ -136,17 +137,17 @@ void find_targets_fx(
// PMT("should we used extended basop here for when the L_subfr > L_SUBFR, to prevent saturation/overflow and the subsequent loop\n")
FOR( i = M + 1; i < L_subfr; i++ )
{
- Ltmp = L_msu( 0, Aqs[1], h1[i - 1] );
+ Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */
FOR( j = 2; j <= M; j++ )
{
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
#else
Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
#endif
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
#else
h1[i] = round_fx( L_shl( Ltmp, s ) );
#endif
@@ -156,31 +157,31 @@ void find_targets_fx(
s2 = shr( s2, 1 );
FOR( i = 0; i < M; i++ )
{
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= i; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
#ifdef BASOP_NOGLOB
- h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) );
+ h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */
#else
h1[i] = round_fx( L_shl( Ltmp, s ) );
#endif
}
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= M; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
- h1[M] = round_fx( L_shl( Ltmp, s ) );
+ h1[M] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */
FOR( i = M + 1; i < L_subfr; i++ )
{
- Ltmp = L_msu( 0, Aqs[1], h1[i - 1] );
+ Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */
FOR( j = 2; j <= M; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
- h1[i] = round_fx( L_shl( Ltmp, s ) );
+ h1[i] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */
}
}
@@ -193,16 +194,16 @@ void find_targets_fx(
void find_targets_ivas_fx(
const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 i_subfr, /* i : subframe index Q0*/
Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization */
+ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15 */
+ Word16 tilt_fac, /* i : tilt factor Q15*/
Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
Word16 *cn, /* o : target vector in residual domain Q_new*/
- Word16 *h1 /* o : impulse response of weighted synthesis filter */
+ Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/
)
{
Word16 i;
@@ -229,7 +230,7 @@ void find_targets_ivas_fx(
FOR( i = 0; i < M; i++ )
{
#ifdef BASOP_NOGLOB
- temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] );
+ temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */
#else
temp[i] = sub( speech[i + i_subfr - M], mem_syn[i] );
#endif
@@ -253,10 +254,10 @@ void find_targets_ivas_fx(
preemph_copy_fx( xn, cn, tilt_fac, shr( L_subfr, 1 ), temp );
syn_filt_s_lc_fx( 1, Ap, cn, temp, shr( L_subfr, 1 ) ); /* Q-1 -> Q-2 */
Residu3_lc_fx( p_Aq, M, temp, cn, shr( L_subfr, 1 ), 1 ); /* Q-2 -> Q-1 */
- Scale_sig( cn, shr( L_subfr, 1 ), 1 );
+ Scale_sig( cn, shr( L_subfr, 1 ), 1 ); /* Q_new */
/* second half: res[] --> cn[] (approximated and faster) */
- Copy( &res[i_subfr + shr( L_subfr, 1 )], cn + shr( L_subfr, 1 ), shr( L_subfr, 1 ) );
+ Copy( &res[i_subfr + shr( L_subfr, 1 )], cn + shr( L_subfr, 1 ), shr( L_subfr, 1 ) ); /* Q_new */
}
/*---------------------------------------------------------------*
@@ -268,13 +269,13 @@ void find_targets_ivas_fx(
d = sub( scaleq, scale );
IF( d >= 0 )
{
- Copy( p_Aq, Aqs, M + 1 );
+ Copy( p_Aq, Aqs, M + 1 ); /* Q12 */
s = add( scaleq, 1 );
s2 = shr( 16384, d );
}
ELSE
{
- Copy_Scale_sig( p_Aq, Aqs, M + 1, d );
+ Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */
s = add( scale, 1 );
s2 = 16384;
}
@@ -283,32 +284,32 @@ void find_targets_ivas_fx(
move16();
FOR( i = 0; i < M; i++ )
{
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= i; j++ )
{
-#ifdef BASOP_NOGLOB /* Critical Overflow , as well as those below*/
- Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow , as well as those below*/
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
#else
Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
#endif
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
#else
h1[i] = round_fx( L_shl( Ltmp, s ) );
#endif
}
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= M; j++ )
{
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
#else
Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
#endif
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
#else
h1[M] = round_fx( L_shl( Ltmp, s ) );
#endif
@@ -316,17 +317,17 @@ void find_targets_ivas_fx(
// PMT("should we used extended basop here for when the L_subfr > L_SUBFR, to prevent saturation/overflow and the subsequent loop\n")
FOR( i = M + 1; i < L_subfr; i++ )
{
- Ltmp = L_msu( 0, Aqs[1], h1[i - 1] );
+ Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */
FOR( j = 2; j <= M; j++ )
{
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
#else
Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
#endif
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
+#ifdef BASOP_NOGLOB /* Critical Overflow */
+ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
#else
h1[i] = round_fx( L_shl( Ltmp, s ) );
#endif
@@ -336,31 +337,31 @@ void find_targets_ivas_fx(
s2 = shr( s2, 1 );
FOR( i = 0; i < M; i++ )
{
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= i; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
#ifdef BASOP_NOGLOB
- h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) );
+ h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */
#else
h1[i] = round_fx( L_shl( Ltmp, s ) );
#endif
}
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= M; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
- h1[M] = round_fx( L_shl( Ltmp, s ) );
+ h1[M] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */
FOR( i = M + 1; i < L_subfr; i++ )
{
- Ltmp = L_msu( 0, Aqs[1], h1[i - 1] );
+ Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */
FOR( j = 2; j <= M; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
- h1[i] = round_fx( L_shl( Ltmp, s ) );
+ h1[i] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */
}
}
diff --git a/lib_enc/find_tilt.c b/lib_enc/find_tilt.c
index c5e16ed22962d9f18f21f00a79ac9c7b52fa7278..59a7412fd5b4392ad354db5e6b1581ecd0579597 100644
--- a/lib_enc/find_tilt.c
+++ b/lib_enc/find_tilt.c
@@ -56,21 +56,22 @@
* Find LF/HF energy ratio
*-------------------------------------------------------------------*/
void find_tilt_ivas_fx(
- const Word32 fr_bands[], /* i : energy in frequency bands Q_new*/
- const Word32 bckr[], /* i : per band background noise energy estimate Q_new*/
- Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
- const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
- const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
- const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new - 2*/
- const Word16 corr_shift, /* i : normalized correlation correction Q15*/
- const Word16 bwidth, /* i : input signal bandwidth */
- const Word16 max_band, /* i : maximum critical band */
- Word32 hp_E[], /* o : energy in HF Q_new*/
- const Word16 codec_mode, /* i : MODE1 or MODE2 */
- const Word16 Q_new, /* i : scaling factor */
- Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16 */
+ const Word32 fr_bands[], /* i : energy in frequency bands Q_new*/
+ const Word32 bckr[], /* i : per band background noise energy estimate Q_new*/
+ Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
+ const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
+ const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
+ const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new - 2*/
+ const Word16 corr_shift, /* i : normalized correlation correction Q15*/
+ const Word16 bwidth, /* i : input signal bandwidth Q0*/
+ const Word16 max_band, /* i : maximum critical band Q0*/
+ Word32 hp_E[], /* o : energy in HF Q_new*/
+ const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/
+ const Word16 Q_new, /* i : scaling factor */
+ Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16*/
,
- Word16 Opt_vbr_mode )
+ Word16 Opt_vbr_mode /* Q0 */
+)
{
Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp;
const Word32 *pt_E, *pt_bands, *pt_bckr, *hf_bands, *tmp_E;
@@ -94,10 +95,10 @@ void find_tilt_ivas_fx(
{
/* WB processing */
bin = BIN4_FX;
- move16(); /* First useful frequency bin ~ 50 Hz */
- pt_bands = fr_bands;
- tmp_E = lf_E;
- pt_bckr = bckr;
+ move16(); /* First useful frequency bin ~ 50 Hz */
+ pt_bands = fr_bands; /* Q_new */
+ tmp_E = lf_E; /* Q_new - 2 */
+ pt_bckr = bckr; /* Q_new */
nb_bands = 10;
move16();
}
@@ -124,7 +125,7 @@ void find_tilt_ivas_fx(
lp_bckr = Mean32( pt_bckr, nb_bands );
/*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */
#ifdef BASOP_NOGLOB
- hp_bckr = L_shr( L_add_sat( bckr[max_band - 1], bckr[max_band] ), 1 );
+ hp_bckr = L_shr( L_add_sat( bckr[max_band - 1], bckr[max_band] ), 1 ); /* Q_new - 1 */
#else
hp_bckr = L_shr( L_add( bckr[max_band - 1], bckr[max_band] ), 1 );
#endif
@@ -132,31 +133,31 @@ void find_tilt_ivas_fx(
{
hp_bckr = L_deposit_l( 1 );
}
- Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp );
- Ltmp = Mpy_32_16_r( Ltmp, 3277 );
+ Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp ); /* exp(e_tmp) */
+ Ltmp = Mpy_32_16_r( Ltmp, 3277 /* 0.1 in Q15 */ );
Ltmp = L_shr_sat( Ltmp, sub( 15, e_tmp ) );
- *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Ltmp );
+ *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Ltmp ); /* Q16 */
move32();
test();
- IF( EQ_16( codec_mode, MODE2 ) || Opt_vbr_mode == 1 )
+ IF( EQ_16( codec_mode, MODE2 ) || EQ_16( Opt_vbr_mode, 1 ) )
{
/*lp_bckr *= FACT;*/
/*hp_bckr *= FACT;*/
#ifdef BASOP_NOGLOB
- lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr );
- hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr );
+ lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr ); /* Q_new */
+ hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr ); /* Q_new */
#else
lp_bckr = L_add( L_shl( lp_bckr, 1 ), lp_bckr );
hp_bckr = L_add( L_shl( hp_bckr, 1 ), hp_bckr );
#endif
}
/*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/
- Ltmp = L_mult( voicing[1], 16384 );
- Ltmp = L_mac( Ltmp, voicing[2], 16384 );
+ Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31
+ Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31
#ifdef BASOP_NOGLOB
- Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow );
- mean_voi = round_fx_o( Ltmp, &Overflow );
+ Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31
+ mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15
#else
Ltmp = L_mac( Ltmp, corr_shift, 32767 );
mean_voi = round_fx( Ltmp );
@@ -166,15 +167,15 @@ void find_tilt_ivas_fx(
e_tmp = norm_s( pitch[2] );
m_tmp = shl( pitch[2], e_tmp );
- m_Fs = div_s( INT_FS_FX, m_tmp );
+ m_Fs = div_s( INT_FS_FX, m_tmp ); /* exp(e_tmp) */
e_Fs = sub( 15, e_tmp );
f0 = shr( m_Fs, sub( e_Fs, 4 ) ); /* Q4 */
FOR( i = 0; i < 2; i++ )
{
- /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */
- Ltmp = L_add( L_shr( hf_bands[max_band - 1], 1 ), L_shr( hf_bands[max_band], 1 ) );
- hp_E[i] = L_sub( Ltmp, hp_bckr );
+ /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */
+ Ltmp = L_add( L_shr( hf_bands[max_band - 1], 1 ), L_shr( hf_bands[max_band], 1 ) ); /* Q_new */
+ hp_E[i] = L_sub( Ltmp, hp_bckr ); /* Q_new */
move32();
IF( Opt_vbr_mode == 0 )
{
@@ -202,16 +203,16 @@ void find_tilt_ivas_fx(
f1 = add( shr( f0, 1 ), f0 ); /* Middle between 2 harmonics */
f2 = f0;
move16();
- WHILE( LE_16( freq, 20320 ) ) /* End frequency of 10th critical band */
+ WHILE( LE_16( freq, 20320 /* 1270.0f in Q4 */ ) ) /* End frequency of 10th critical band */
{
FOR( ; freq <= f1; freq += BIN4_FX )
{
/* include only bins sufficiently close to harmonics */
- tmp = sub( freq, f2 );
+ tmp = sub( freq, f2 ); /* Q4 */
IF( L_mac0( -(Word32) TH_D_FX * TH_D_FX, tmp, tmp ) < 0 )
{
#ifdef BASOP_NOGLOB
- lp_E = L_add_o( *pt_E, lp_E, &Overflow );
+ lp_E = L_add_o( *pt_E, lp_E, &Overflow ); /* Q_new - 1 */
#else
lp_E = L_add( *pt_E, lp_E );
#endif
@@ -245,7 +246,7 @@ void find_tilt_ivas_fx(
lp_E = L_sub( L_shr( m_tmp, sub( e_tmp, 1 ) ), lp_bckr );
#endif
- pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */
+ pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame Q_new - 1 */
}
ELSE /* Other than high-pitched voiced frames */
{
@@ -271,7 +272,7 @@ void find_tilt_ivas_fx(
m_tmp = extract_h( L_shl( lp_E, e_tmp ) );
e_hpE = norm_l( hp_E[i] );
m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) );
- m_tmp = div_s( m_tmp, m_hpE );
+ m_tmp = div_s( m_tmp, m_hpE ); /* e_tmp + e_hpE */
e_tmp = sub( e_tmp, e_hpE );
#ifdef BASOP_NOGLOB
@@ -295,15 +296,15 @@ void find_tilt_ivas_fx(
IF( EQ_16( bwidth, NB ) ) /* For NB input, compensate for the missing bands */
{
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( ee[i], 3, &Overflow );
+ Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */
#else
Ltmp = L_shl( ee[i], 3 );
#endif
IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */
{
- Ltmp = Mult_32_16( ee[i], 24576 ); /* 6/8 */
+ Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/
#ifdef BASOP_NOGLOB
- ee[i] = L_shl_sat( Ltmp, 3 );
+ ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */
#else
ee[i] = L_shl( Ltmp, 3 );
#endif
@@ -311,7 +312,7 @@ void find_tilt_ivas_fx(
}
ELSE
{
- ee[i] = Mult_32_16( Ltmp, 24576 );
+ ee[i] = Mult_32_16( Ltmp, 24576 /* 0.75 in Q15 */ );
move32(); /* 6/8 */
}
}
diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c
index f0c39eee21dafe9fe30de6bee54dbdd2d4a6854c..f29a9709cf2916b81760cdcb34bb47745ae9d20b 100644
--- a/lib_enc/find_tilt_fx.c
+++ b/lib_enc/find_tilt_fx.c
@@ -23,14 +23,15 @@ void find_tilt_fx(
const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new + Q_SCALE - 2*/
const Word16 corr_shift, /* i : normalized correlation correction Q15*/
- const Word16 bwidth, /* i : input signal bandwidth */
- const Word16 max_band, /* i : maximum critical band */
+ const Word16 bwidth, /* i : input signal bandwidth Q0*/
+ const Word16 max_band, /* i : maximum critical band Q0*/
Word32 hp_E[], /* o : energy in HF Q_new + Q_SCALE*/
- const Word16 codec_mode, /* i : MODE1 or MODE2 */
+ const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/
const Word16 Q_new, /* i : scaling factor */
- Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16 */
+ Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16*/
,
- Word16 Opt_vbr_mode )
+ Word16 Opt_vbr_mode /* Q0 */
+)
{
Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp;
const Word32 *pt_E, *pt_bands, *pt_bckr, *hf_bands, *tmp_E;
@@ -41,8 +42,11 @@ void find_tilt_fx(
Word16 m_cnt, e_cnt;
Word16 m_hpE, e_hpE;
Word16 scaling;
+ move32();
+ move32();
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
* Initializations
@@ -53,10 +57,10 @@ void find_tilt_fx(
{
/* WB processing */
bin = BIN4_FX;
- move16(); /* First useful frequency bin ~ 50 Hz */
- pt_bands = fr_bands;
- tmp_E = lf_E;
- pt_bckr = bckr;
+ move16(); /* First useful frequency bin ~ 50 Hz */
+ pt_bands = fr_bands; /* Q_new + QSCALE */
+ tmp_E = lf_E; /* Q_new + QSCALE - 2 */
+ pt_bckr = bckr; /* Q_new + QSCALE */
nb_bands = 10;
move16();
}
@@ -64,9 +68,9 @@ void find_tilt_fx(
{
/* NB processing */
bin = add( shl( BIN4_FX, 1 ), BIN4_FX ); /* First useful frequency bin ~ 150 Hz */
- pt_bands = fr_bands + 1; /* Exlcude 1st critical band */
- tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) */
- pt_bckr = bckr + 1; /* Exlcude 1st critical band */
+ pt_bands = fr_bands + 1; /* Exlcude 1st critical band Q_new + QSCALE*/
+ tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) Q_new + QSCALE - 2*/
+ pt_bckr = bckr + 1; /* Exlcude 1st critical band Q_new + QSCALE*/
nb_bands = 9;
move16(); /* Nb. of "low" frequency bands taken into account in NB processing */
}
@@ -75,15 +79,15 @@ void find_tilt_fx(
* Find spectrum tilt
*-----------------------------------------------------------------*/
- pt_E = tmp_E; /* Point at the 1st useful element of the per-bin energy vector */
- hf_bands = fr_bands;
+ pt_E = tmp_E; /* Point at the 1st useful element of the per-bin energy vector */
+ hf_bands = fr_bands; /* Q_new + QSCALE */
/* bckr + voicing */
/*lp_bckr = mean( pt_bckr, nb_bands );*/ /* estimated noise E in first critical bands, up to 1270 Hz */
lp_bckr = Mean32( pt_bckr, nb_bands );
/*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */
#ifdef BASOP_NOGLOB
- hp_bckr = L_shr( L_add_sat( bckr[max_band - 1], bckr[max_band] ), 1 );
+ hp_bckr = L_shr( L_add_sat( bckr[max_band - 1], bckr[max_band] ), 1 ); /* Q_new + QSCALE - 1 */
#else
hp_bckr = L_shr( L_add( bckr[max_band - 1], bckr[max_band] ), 1 );
#endif
@@ -93,7 +97,7 @@ void find_tilt_fx(
}
tmp = BASOP_Util_Divide3232_Scale( lp_bckr, hp_bckr, &e_tmp );
Ltmp = L_shr_r( L_deposit_h( tmp ), sub( 15, e_tmp ) );
- *bckr_tilt_lt = L_add( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) );
+ *bckr_tilt_lt = L_add( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) ); /* Q16 */
test();
IF( EQ_16( codec_mode, MODE2 ) || Opt_vbr_mode == 1 )
@@ -101,7 +105,7 @@ void find_tilt_fx(
/*lp_bckr *= FACT;*/
/*hp_bckr *= FACT;*/
#ifdef BASOP_NOGLOB
- lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr );
+ lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr ); /* Q_new + QSCALE */
hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr );
#else
lp_bckr = L_add( L_shl( lp_bckr, 1 ), lp_bckr );
@@ -109,11 +113,11 @@ void find_tilt_fx(
#endif
}
/*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/
- Ltmp = L_mult( voicing[1], 16384 );
- Ltmp = L_mac( Ltmp, voicing[2], 16384 );
+ Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); /* Q31 */
+ Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); /* Q31 */
#ifdef BASOP_NOGLOB
- Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow );
- mean_voi = round_fx_o( Ltmp, &Overflow );
+ Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow ); /* Q31 */
+ mean_voi = round_fx_o( Ltmp, &Overflow ); /* Q15 */
#else
Ltmp = L_mac( Ltmp, corr_shift, 32767 );
mean_voi = round_fx( Ltmp );
@@ -123,23 +127,23 @@ void find_tilt_fx(
e_tmp = norm_s( pitch[2] );
m_tmp = shl( pitch[2], e_tmp );
- m_Fs = div_s( INT_FS_FX, m_tmp );
+ m_Fs = div_s( INT_FS_FX, m_tmp ); /* exp(e_tmp) */
e_Fs = sub( 15, e_tmp );
f0 = shr( m_Fs, sub( e_Fs, 4 ) ); /* Q4 */
FOR( i = 0; i < 2; i++ )
{
- /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */
- Ltmp = L_add( L_shr( hf_bands[max_band - 1], 1 ), L_shr( hf_bands[max_band], 1 ) );
- hp_E[i] = L_sub( Ltmp, hp_bckr );
+ /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */
+ Ltmp = L_add( L_shr( hf_bands[max_band - 1], 1 ), L_shr( hf_bands[max_band], 1 ) ); /* Q_new + QSCALE */
+ hp_E[i] = L_sub( Ltmp, hp_bckr ); /* Q_new + QSCALE */
IF( Opt_vbr_mode == 0 )
{
- hp_E[i] = L_max( hp_E[i], L_shl( E_MIN_FX, Q_new ) );
+ hp_E[i] = L_max( hp_E[i], L_shl( E_MIN_FX, Q_new ) ); /* Q_new + QSCALE */
move32();
}
ELSE
{
- hp_E[i] = L_max( hp_E[i], L_shl( 1, scaling ) );
+ hp_E[i] = L_max( hp_E[i], L_shl( 1, scaling ) ); /* Q_new + QSCALE */
move32();
}
@@ -164,11 +168,11 @@ void find_tilt_fx(
IF( L_mac0( -(Word32) TH_D_FX * TH_D_FX, tmp, tmp ) < 0 )
{
#ifdef BASOP_NOGLOB
- lp_E = L_add_o( *pt_E, lp_E, &Overflow );
+ lp_E = L_add_o( *pt_E, lp_E, &Overflow ); /* Q_new + QSCALE - 2 */
#else
lp_E = L_add( *pt_E, lp_E );
#endif
- m_cnt = add( m_cnt, 1 );
+ m_cnt = add( m_cnt, 1 ); /* Q0 */
}
pt_E++;
}
@@ -189,11 +193,11 @@ void find_tilt_fx(
e_cnt = norm_s( m_cnt );
m_cnt = shl( m_cnt, e_cnt );
- m_tmp = div_s( m_tmp, m_cnt );
+ m_tmp = div_s( m_tmp, m_cnt ); /* exp(e_tmp + e_cnt) */
e_tmp = sub( e_tmp, e_cnt );
#ifdef BASOP_NOGLOB
- lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow );
+ lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */
#else
lp_E = L_sub( L_shr( m_tmp, sub( e_tmp, 1 ) ), lp_bckr );
#endif
@@ -202,8 +206,8 @@ void find_tilt_fx(
}
ELSE /* Other than high-pitched voiced frames */
{
- /*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */
- lp_E = L_sub( Mean32( pt_bands, nb_bands ), lp_bckr );
+ /*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */
+ lp_E = L_sub( Mean32( pt_bands, nb_bands ), lp_bckr ); /* Q_new + QSCALE */
}
IF( Opt_vbr_mode == 0 )
{
@@ -221,7 +225,7 @@ void find_tilt_fx(
m_tmp = extract_h( L_shl( lp_E, e_tmp ) );
e_hpE = norm_l( hp_E[i] );
m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) );
- m_tmp = div_s( m_tmp, m_hpE );
+ m_tmp = div_s( m_tmp, m_hpE ); /* exp(e_tmp + e_hpE) */
e_tmp = sub( e_tmp, e_hpE );
#ifdef BASOP_NOGLOB
@@ -248,7 +252,7 @@ void find_tilt_fx(
#endif
IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */
{
- Ltmp = Mult_32_16( ee[i], 24576 ); /* 6/8 */
+ Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/
#ifdef BASOP_NOGLOB
ee[i] = L_shl_sat( Ltmp, 3 );
#else
@@ -258,8 +262,8 @@ void find_tilt_fx(
}
ELSE
{
- ee[i] = Mult_32_16( Ltmp, 24576 );
- move32(); /* 6/8 */
+ ee[i] = Mult_32_16( Ltmp, 24576 /* 0.75 in Q15 */ ); /* Q6 */
+ move32(); /* 6/8 */
}
}
diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c
index 972c402426034edf8f20cc593fc90e353a64f29a..4196b9cb63f8ff3e0acf25bac42e2d71c9646549 100644
--- a/lib_enc/find_uv.c
+++ b/lib_enc/find_uv.c
@@ -58,9 +58,9 @@
*-------------------------------------------------------------------*/
/*! r: maximum energy ratio */
-static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10 */
- const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search */
- const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer */
+static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/
+ const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/
+ const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/
)
{
Word16 i, j, end, flag;
@@ -74,9 +74,9 @@ static Word16 find_ener_decrease_fx( /* o : maximum
dE2 = 0;
move16();
- j = ind_deltaMax + 2;
+ j = add( ind_deltaMax, 2 ); /* Q0 */
move16();
- end = j + L_ENR;
+ end = add( j, L_ENR );
move16();
maxEnr = L_add( pt_enr_ssf[j], 0 );
j = add( j, 1 );
@@ -87,7 +87,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum
test();
IF( ( GT_32( pt_enr_ssf[i], maxEnr ) ) && ( flag == 0 ) )
{
- maxEnr = L_add( pt_enr_ssf[i], 0 ); /*Q0*/
+ maxEnr = pt_enr_ssf[i]; /* Qx */
j = add( j, 1 );
}
ELSE
@@ -100,7 +100,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum
minEnr = L_add( maxEnr, 0 );
FOR( i = j; i < end; i++ )
{
- minEnr = L_min( minEnr, pt_enr_ssf[i] );
+ minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */
}
@@ -130,17 +130,17 @@ static Word16 find_ener_decrease_fx( /* o : maximum
*-------------------------------------------------------------------*/
Word16 find_uv_ivas_fx( /* o : coding type */
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6 */
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15 */
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new */
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6 */
- Word32 *dE1X, /* o : sudden energy increase for S/M classifier */
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15 */
- const Word16 relE, /* i : relative frame energy Q8 */
- const Word16 Etot, /* i : total energy Q8 */
- const Word32 hp_E[], /* i : energy in HF q_hp_E */
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
- const Word16 last_core_orig, /* i : original last core */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
+ Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
+ const Word16 relE, /* i : relative frame energy Q8*/
+ const Word16 Etot, /* i : total energy Q8*/
+ const Word32 hp_E[], /* i : energy in HF q_hp_E*/
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
+ const Word16 last_core_orig, /* i : original last core Q0*/
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
const Word16 Q_new,
const Word16 q_hp_E )
@@ -170,9 +170,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ
IF( hSC_VBR != NULL )
{
- Last_Resort = hSC_VBR->Last_Resort;
+ Last_Resort = hSC_VBR->Last_Resort; /* Q0 */
move16();
- vadnoise = hSC_VBR->vadnoise_fx;
+ vadnoise = hSC_VBR->vadnoise_fx; /* Q8 */
move16();
}
ELSE
@@ -233,7 +233,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
move16();
}
- dE1 = L_max( dE1, fac_32 );
+ dE1 = L_max( dE1, fac_32 ); /* Q13 */
pt_enr_ssf++;
pt_enr_ssf1++;
@@ -243,14 +243,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
IF( st_fx->idchan == 0 )
{
- hStereoClassif->dE1_ch1_fx = dE1;
+ hStereoClassif->dE1_ch1_fx = dE1; /* Q13 */
move32();
hStereoClassif->dE1_ch1_e = 31 - Q13;
move16();
}
ELSE
{
- hStereoClassif->dE1_ch2_fx = dE1;
+ hStereoClassif->dE1_ch2_fx = dE1; /* Q13 */
move32();
hStereoClassif->dE1_ch2_e = 31 - Q13;
move16();
@@ -259,7 +259,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
if ( dE1X != NULL )
{
- *dE1X = dE1;
+ *dE1X = dE1; /* Q13 */
move32();
}
@@ -270,17 +270,17 @@ Word16 find_uv_ivas_fx( /* o : coding typ
/*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */
#ifdef BASOP_NOGLOB
- mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow );
-#else /* BASOP_NOGLOB */
+ mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */
+#else /* BASOP_NOGLOB */
mean_ee = L_add( L_add( st_fx->ee_old_fx, ee[0] ), ee[1] );
-#endif /* BASOP_NOGLOB */
- mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/
+#endif /* BASOP_NOGLOB */
+ mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/
/* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/
- Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 );
- Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 );
-#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP
- mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/
+ Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */
+ Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */
+#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP
+ mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/
#else
mean_voi3 = mac_r( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/
#endif
@@ -299,7 +299,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
move32();
nb_cond = 1;
move16(); /* no additional condition for WB input */
- IF( EQ_16( st_fx->input_bwidth, NB ) )
+ IF( st_fx->input_bwidth == NB )
{
dE2_th = 21 << 10;
move32();
@@ -324,9 +324,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) )
{
- st_fx->old_ind_deltaMax = ind_deltaMax;
+ st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */
move16();
- Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF );
+ Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */
}
ELSE
{
@@ -345,8 +345,8 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
IF( st_fx->old_ind_deltaMax >= 0 )
{
- Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF );
- dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf );
+ Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); /* Qx */
+ dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); /* Q10 */
if ( GT_32( dE2, dE2_th ) )
{
@@ -366,7 +366,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
tmp_offset_flag = 1;
move16();
- IF( NE_16( st_fx->input_bwidth, NB ) )
+ IF( st_fx->input_bwidth != NB )
{
ee0_th = 154; /*2.4 in Q6 */
move16();
@@ -387,14 +387,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
#ifdef BASOP_NOGLOB
- if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */
- ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */
- ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */
-#else /* BASOP_NOGLOB */
+ IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */
+ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */
+ ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */
+#else /* BASOP_NOGLOB */
if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */
( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */
( LT_16( add( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */
-#endif /* BASOP_NOGLOB */
+#endif /* BASOP_NOGLOB */
{
tmp_offset_flag = 0;
move16();
@@ -419,14 +419,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ
move16();
/* SC-VBR - determine the threshold on relative energy as a function of lp_noise */
- IF( NE_16( st_fx->input_bwidth, NB ) )
+ IF( st_fx->input_bwidth != NB )
{
/*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */
- L_tmp = L_mac( -562036736, 22938, st_fx->lp_noise_fx );
- if ( Last_Resort == 0 )
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24
+ IF( Last_Resort == 0 )
{
/*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -562036736, 21299, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24
}
relE_thres = round_fx( L_tmp );
}
@@ -434,10 +434,10 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
/*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -473117491, 19661, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24
relE_thres = round_fx( L_tmp );
}
- relE_thres = s_max( relE_thres, -6400 ); /* Q8 */
+ relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */
/* SC-VBR = set flag on low relative energy */
if ( LT_16( relE, relE_thres ) )
@@ -448,7 +448,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
/* SC-VBR - correction of voicing threshold for NB inputs (important only in noisy conditions) */
test();
- if ( EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */
+ if ( st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */
{
mean_voi3_offset = 1638; /*0.05f Q15*/
move16();
@@ -458,7 +458,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
/* make decision whether frame is unvoiced */
coder_type = GENERIC;
move16();
- IF( EQ_16( st_fx->input_bwidth, NB ) )
+ IF( st_fx->input_bwidth == NB )
{
test();
test();
@@ -470,18 +470,17 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- test();
#ifdef BASOP_NOGLOB
- if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282, mean_voi3_offset ) ) ) && /* normalized correlation low */
- ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */
- ( LT_32( ee[0], 640 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
- ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
- ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
- /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */
- ( LE_32( dE1, 237568 ) ) && /* Avoid on sharp energy spikes */
- ( LE_32( st_fx->old_dE1_fx, 237568 ) ) && /* + one frame hysteresis */
- ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
- flag_low_relE ) /* low relative frame energy (only for SC-VBR) */
+ IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
+ ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */
+ ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
+ ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
+ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
+ /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */
+ ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */
+ ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
+ flag_low_relE ) /* low relative frame energy (only for SC-VBR) */
#else
if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22282, mean_voi3_offset ) ) ) && /* normalized correlation low */
( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */
@@ -510,23 +509,20 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- test();
- test();
- test();
#ifdef BASOP_NOGLOB
- if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774, mean_voi3_offset ) ) ) && /* normalized correlation low */
- ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */
- ( LT_32( ee[0], 397 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
- ( LT_32( ee[1], 397 ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
- ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
- /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */
- ( LE_32( dE1, 245760 ) ) && /* Avoid on sharp energy spikes */
- ( LE_32( st_fx->old_dE1_fx, 245760 ) ) && /* + one frame hysteresis */
- ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
- || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 ) ) ) ) /* low relative frame energy (only for SC-VBR) */
+ if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
+ /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */
+ ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
+ ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
+ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
+ /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */
+ ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */
+ ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
+ || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */
#else
if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22774, mean_voi3_offset ) ) ) && /* normalized correlation low */
- ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */
+ /* ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */
( LT_32( ee[0], 397 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
( LT_32( ee[1], 397 ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
@@ -555,9 +551,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
IF( EQ_16( st_fx->localVAD, 1 ) && EQ_16( coder_type, GENERIC ) && NE_16( last_core_orig, AMR_WB_CORE ) )
{
- dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) );
- dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) );
- dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) );
+ dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) ); /* Q6 */
+ dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); /* Q6 */
+ dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); /* Q6 */
test();
test();
@@ -568,11 +564,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- IF( ( GT_16( voicing_fr[0], 19825 ) ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 19825 ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 19825 ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 19825 ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 256 ) ) && /* energy concentrated in low frequencies */
+ IF( ( GT_16( voicing_fr[0], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 1st sf. */
+ ( GT_16( voicing_fr[1], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( GT_16( voicing_fr[2], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
+ ( GT_16( voicing_fr[3], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
+ ( GT_32( mean_ee, 256 /* 4.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */
( LT_16( dpit1, 3 << 6 ) ) &&
( LT_16( dpit2, 3 << 6 ) ) &&
( LT_16( dpit3, 3 << 6 ) ) )
@@ -580,7 +576,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
coder_type = VOICED;
move16();
}
- ELSE IF( st_fx->Opt_SC_VBR && EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) )
+ ELSE IF( st_fx->Opt_SC_VBR && st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) )
{
test();
test();
@@ -589,11 +585,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- IF( GT_16( voicing_fr[0], 8192 ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 8192 ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 8192 ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 8192 ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */
+ IF( GT_16( voicing_fr[0], 8192 /* 0.25 in Q15 */ ) && /* normalized correlation high in 1st sf. */
+ ( GT_16( voicing_fr[1], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( GT_16( voicing_fr[2], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
+ ( GT_16( voicing_fr[3], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
+ ( GT_32( mean_ee, 64 /* 1.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */
( LT_16( dpit1, 5 << 6 ) ) &&
( LT_16( dpit2, 5 << 6 ) ) &&
( LT_16( dpit3, 5 << 6 ) ) )
@@ -607,14 +603,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ
/* set VOICED mode for frames with very stable pitch and high correlation
and avoid to switch to AUDIO/MUSIC later */
- voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 ), voicing_fr[2], 8192 ), voicing_fr[1], 8192 ), voicing_fr[0], 8192 );
+ voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 /* 0.25 in Q15 */ ), voicing_fr[2], 8192 /* 0.25 in Q15 */ ), voicing_fr[1], 8192 /* 0.25 in Q15 */ ), voicing_fr[0], 8192 /* 0.25 in Q15 */ ); /* Q15 */
test();
test();
test();
test();
test();
IF( *flag_spitch || ( LE_16( dpit1, 3 << 6 ) && LE_16( dpit2, 3 << 6 ) && LE_16( dpit3, 3 << 6 ) &&
- GT_16( voicing_m, 31130 ) && GT_16( st_fx->voicing_sm_fx, 31785 ) ) )
+ GT_16( voicing_m, 31130 /* 0.95f in Q15 */ ) && GT_16( st_fx->voicing_sm_fx, 31785 /* 0.97f in Q15 */ ) ) )
{
coder_type = VOICED;
move16();
@@ -627,7 +623,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
* Channel-aware mode - set RF mode and total bitrate
*-----------------------------------------------------------------*/
- st_fx->rf_mode = st_fx->Opt_RF_ON;
+ st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */
move16();
IF( EQ_16( coder_type, GENERIC ) )
@@ -636,11 +632,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- IF( ( LT_16( voicing_fr[0], 6554 ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[1], 6554 ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[2], 6554 ) ) && /* normalized correlation high in 3rd sf. */
- ( LT_16( voicing_fr[3], 6554 ) ) && /* normalized correlation high in 4th sf. */
- ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */
+ IF( ( LT_16( voicing_fr[0], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( LT_16( voicing_fr[1], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( LT_16( voicing_fr[2], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 3rd sf. */
+ ( LT_16( voicing_fr[3], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 4th sf. */
+ ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */
{
st_fx->rf_mode = 0;
@@ -685,7 +681,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) )
{
- st_fx->spike_hyst = add( st_fx->spike_hyst, 1 );
+ st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */
move16();
}
@@ -696,7 +692,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
if ( ( GT_16( st_fx->spike_hyst, 1 ) ) &&
( GT_16( dE3, 5 << 8 ) || /* energy increases */
#ifdef BASOP_NOGLOB
- ( GT_16( relE, -3328 ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */
+ ( GT_16( relE, -3328 /* 13 in Q8 */ ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 /* 0.695 in Q15 */ ) ) ) ) ) /* normalized correlation is high */
#else
( GT_16( relE, -3328 ) && ( GT_16( add( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */
#endif
@@ -712,7 +708,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
move32(); /*Q13*/
/* save the raw coder_type for various modules later in the codec (the reason is that e.g. UNVOICED is lost at higher rates) */
- st_fx->coder_type_raw = coder_type;
+ st_fx->coder_type_raw = coder_type; /* Q0 */
move16();
return coder_type;
diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c
index 778e7b51a80dbabf5cc77cdc978df6cfbed03b26..5cd9db2797f8e7b8da3f9a2f3326c8056ac8967e 100644
--- a/lib_enc/find_uv_fx.c
+++ b/lib_enc/find_uv_fx.c
@@ -23,9 +23,9 @@
* energy is trailing off after a spike
*-------------------------------------------------------------------*/
-static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10 */
- const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search */
- const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer */
+static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/
+ const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/
+ const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/
)
{
Word16 i, j, end, flag;
@@ -34,6 +34,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum
Word16 dE2, exp0, exp1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
dE2 = 0;
@@ -52,7 +53,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum
test();
IF( ( GT_32( pt_enr_ssf[i], maxEnr ) ) && ( flag == 0 ) )
{
- maxEnr = L_add( pt_enr_ssf[i], 0 ); /*Q0*/
+ maxEnr = L_add( pt_enr_ssf[i], 0 ); /*Qx*/
j = add( j, 1 );
}
ELSE
@@ -65,7 +66,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum
minEnr = L_add( maxEnr, 0 );
FOR( i = j; i < end; i++ )
{
- minEnr = L_min( minEnr, pt_enr_ssf[i] );
+ minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */
}
@@ -94,23 +95,23 @@ static Word16 find_ener_decrease_fx( /* o : maximum
* Decision about coder type
*-------------------------------------------------------------------*/
-Word16 find_uv_fx( /* o : coding type */
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
+Word16 find_uv_fx( /* o : coding type */
+ Encoder_State *st_fx, /* i/o: encoder state structure */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
#ifdef IVAS_CODE
Word32 *dE1X, /* o : sudden energy increase for S/M classifier */
#endif
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
- const Word16 relE, /* i : relative frame energy Q8*/
- const Word16 Etot, /* i : total energy Q8*/
- const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
+ const Word16 relE, /* i : relative frame energy Q8*/
+ const Word16 Etot, /* i : total energy Q8*/
+ const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
const Word16 Q_new,
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
const Word16 shift,
- const Word16 last_core_orig /* i : original last core */
+ const Word16 last_core_orig /* i : original last core Q0*/
#ifdef IVAS_CODE
,
STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */
@@ -135,6 +136,7 @@ Word16 find_uv_fx( /* o : coding type
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Word16 Last_Resort;
@@ -142,13 +144,17 @@ Word16 find_uv_fx( /* o : coding type
IF( hSC_VBR != NULL )
{
- Last_Resort = hSC_VBR->Last_Resort;
+ Last_Resort = hSC_VBR->Last_Resort; /* Q0 */
vadnoise = hSC_VBR->vadnoise_fx;
+ move16();
+ move16();
}
ELSE
{
Last_Resort = 0;
vadnoise = 0;
+ move16();
+ move16();
}
Q_in = sub( Q_new, 1 );
@@ -163,7 +169,7 @@ Word16 find_uv_fx( /* o : coding type
*-----------------------------------------------------------------*/
/* Find maximum energy per short subblocks */
- pt_speech = speech - SSF;
+ pt_speech = speech - SSF; /* Q_new */
pt_enr_ssf = enr_ssf + 2 * NB_SSF;
FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ )
{
@@ -203,7 +209,7 @@ Word16 find_uv_fx( /* o : coding type
move16();
}
- dE1 = L_max( dE1, fac_32 );
+ dE1 = L_max( dE1, fac_32 ); /* Q13 */
pt_enr_ssf++;
pt_enr_ssf1++;
@@ -234,17 +240,17 @@ Word16 find_uv_fx( /* o : coding type
/*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */
#ifdef BASOP_NOGLOB
- mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow );
-#else /* BASOP_NOGLOB */
+ mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */
+#else /* BASOP_NOGLOB */
mean_ee = L_add( L_add( st_fx->ee_old_fx, ee[0] ), ee[1] );
-#endif /* BASOP_NOGLOB */
- mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/
+#endif /* BASOP_NOGLOB */
+ mean_ee = Mult_32_16( mean_ee, 10923 /* 1/3 in Q15 */ ); /*Q6*/
/* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/
- Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 );
- Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 );
-#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP
- mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/
+ Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */
+ Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */
+#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP
+ mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/
#else
mean_voi3 = mac_r( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/
#endif
@@ -268,7 +274,7 @@ Word16 find_uv_fx( /* o : coding type
dE2_th = 21 << 10;
move32();
#ifdef BASOP_NOGLOB
- if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/
+ if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/
#else
if ( GE_16( add( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/
#endif
@@ -288,9 +294,9 @@ Word16 find_uv_fx( /* o : coding type
{
IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) )
{
- st_fx->old_ind_deltaMax = ind_deltaMax;
+ st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */
move16();
- Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF );
+ Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */
}
ELSE
{
@@ -309,8 +315,8 @@ Word16 find_uv_fx( /* o : coding type
{
IF( st_fx->old_ind_deltaMax >= 0 )
{
- Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF );
- dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf );
+ Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); /* Qx */
+ dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); /* Q10 */
if ( GT_32( dE2, dE2_th ) )
{
@@ -382,11 +388,11 @@ Word16 find_uv_fx( /* o : coding type
IF( NE_16( st_fx->input_bwidth, NB ) )
{
/*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */
- L_tmp = L_mac( -562036736, 22938, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24
if ( Last_Resort == 0 )
{
/*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -562036736, 21299, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24
}
relE_thres = round_fx( L_tmp );
}
@@ -394,10 +400,10 @@ Word16 find_uv_fx( /* o : coding type
{
/*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -473117491, 19661, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24
relE_thres = round_fx( L_tmp );
}
- relE_thres = s_max( relE_thres, -6400 ); /* Q8 */
+ relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */
/* SC-VBR = set flag on low relative energy */
if ( LT_16( relE, relE_thres ) )
@@ -433,16 +439,16 @@ Word16 find_uv_fx( /* o : coding type
test();
test();
#ifdef BASOP_NOGLOB
- if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282, mean_voi3_offset ) ) ) && /* normalized correlation low */
- ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */
- ( LT_32( ee[0], 640 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
- ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
- ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
- /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */
- ( LE_32( dE1, 237568 ) ) && /* Avoid on sharp energy spikes */
- ( LE_32( st_fx->old_dE1_fx, 237568 ) ) && /* + one frame hysteresis */
- ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
- flag_low_relE ) /* low relative frame energy (only for SC-VBR) */
+ if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
+ ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */
+ ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
+ ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
+ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
+ /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */
+ ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */
+ ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
+ flag_low_relE ) /* low relative frame energy (only for SC-VBR) */
#else
if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22282, mean_voi3_offset ) ) ) && /* normalized correlation low */
( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */
@@ -475,16 +481,16 @@ Word16 find_uv_fx( /* o : coding type
test();
test();
#ifdef BASOP_NOGLOB
- if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774, mean_voi3_offset ) ) ) && /* normalized correlation low */
- ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */
- ( LT_32( ee[0], 397 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
- ( LT_32( ee[1], 397 ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
- ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
- /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */
- ( LE_32( dE1, 245760 ) ) && /* Avoid on sharp energy spikes */
- ( LE_32( st_fx->old_dE1_fx, 245760 ) ) && /* + one frame hysteresis */
- ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
- || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 ) ) ) ) /* low relative frame energy (only for SC-VBR) */
+ if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
+ ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */
+ ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
+ ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
+ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
+ /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */
+ ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */
+ ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
+ || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */
#else
if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22774, mean_voi3_offset ) ) ) && /* normalized correlation low */
( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */
@@ -516,9 +522,9 @@ Word16 find_uv_fx( /* o : coding type
test();
IF( EQ_16( st_fx->localVAD, 1 ) && EQ_16( coder_type, GENERIC ) && NE_16( last_core_orig, AMR_WB_CORE ) )
{
- dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) );
- dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) );
- dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) );
+ dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) ); // Q6
+ dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); // Q6
+ dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); // Q6
test();
test();
@@ -529,11 +535,11 @@ Word16 find_uv_fx( /* o : coding type
test();
test();
test();
- IF( ( GT_16( voicing_fr[0], 19825 ) ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 19825 ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 19825 ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 19825 ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 256 ) ) && /* energy concentrated in low frequencies */
+ IF( ( GT_16( voicing_fr[0], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 1st sf. */
+ ( GT_16( voicing_fr[1], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( GT_16( voicing_fr[2], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
+ ( GT_16( voicing_fr[3], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
+ ( GT_32( mean_ee, 256 /* 4.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */
( LT_16( dpit1, 3 << 6 ) ) &&
( LT_16( dpit2, 3 << 6 ) ) &&
( LT_16( dpit3, 3 << 6 ) ) )
@@ -550,11 +556,11 @@ Word16 find_uv_fx( /* o : coding type
test();
test();
test();
- IF( GT_16( voicing_fr[0], 8192 ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 8192 ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 8192 ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 8192 ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */
+ IF( GT_16( voicing_fr[0], 8192 /* 0.25 in Q15 */ ) && /* normalized correlation high in 1st sf. */
+ ( GT_16( voicing_fr[1], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( GT_16( voicing_fr[2], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
+ ( GT_16( voicing_fr[3], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
+ ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */
( LT_16( dpit1, 5 << 6 ) ) &&
( LT_16( dpit2, 5 << 6 ) ) &&
( LT_16( dpit3, 5 << 6 ) ) )
@@ -568,14 +574,14 @@ Word16 find_uv_fx( /* o : coding type
/* set VOICED mode for frames with very stable pitch and high correlation
and avoid to switch to AUDIO/MUSIC later */
- voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 ), voicing_fr[2], 8192 ), voicing_fr[1], 8192 ), voicing_fr[0], 8192 );
+ voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 /* 0.25 in Q15 */ ), voicing_fr[2], 8192 /* 0.25 in Q15 */ ), voicing_fr[1], 8192 /* 0.25 in Q15 */ ), voicing_fr[0], 8192 /* 0.25 in Q15 */ );
test();
test();
test();
test();
test();
IF( *flag_spitch || ( LE_16( dpit1, 3 << 6 ) && LE_16( dpit2, 3 << 6 ) && LE_16( dpit3, 3 << 6 ) &&
- GT_16( voicing_m, 31130 ) && GT_16( st_fx->voicing_sm_fx, 31785 ) ) )
+ GT_16( voicing_m, 31130 /* 0.95f in Q15 */ ) && GT_16( st_fx->voicing_sm_fx, 31785 /* 0.97f in Q15 */ ) ) )
{
coder_type = VOICED;
move16();
@@ -588,7 +594,7 @@ Word16 find_uv_fx( /* o : coding type
* Channel-aware mode - set RF mode and total bitrate
*-----------------------------------------------------------------*/
- st_fx->rf_mode = st_fx->Opt_RF_ON;
+ st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */
move16();
IF( EQ_16( coder_type, GENERIC ) )
@@ -597,11 +603,11 @@ Word16 find_uv_fx( /* o : coding type
test();
test();
test();
- IF( ( LT_16( voicing_fr[0], 6554 ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[1], 6554 ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[2], 6554 ) ) && /* normalized correlation high in 3rd sf. */
- ( LT_16( voicing_fr[3], 6554 ) ) && /* normalized correlation high in 4th sf. */
- ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */
+ IF( ( LT_16( voicing_fr[0], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( LT_16( voicing_fr[1], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( LT_16( voicing_fr[2], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 3rd sf. */
+ ( LT_16( voicing_fr[3], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 4th sf. */
+ ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */
{
st_fx->rf_mode = 0;
@@ -641,7 +647,7 @@ Word16 find_uv_fx( /* o : coding type
test();
if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) )
{
- st_fx->spike_hyst = add( st_fx->spike_hyst, 1 );
+ st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */
}
/* reset spike hysteresis */
diff --git a/lib_enc/find_wsp.c b/lib_enc/find_wsp.c
index 9ba0a3c0764e86263dd28cebfe9af965e82e59a4..00729bde0ca3e5ac6d67d4ebf4fe522f504bb94e 100644
--- a/lib_enc/find_wsp.c
+++ b/lib_enc/find_wsp.c
@@ -41,14 +41,14 @@
#include "wmc_auto.h"
#include "prot_fx.h"
/*-------------------------------------------------------------------*
- * find_wsp()
+ * ivas_find_wsp_fx()
*
* Compute weighted speech used in open-loop pitch search
*-------------------------------------------------------------------*/
-void ivas_find_wsp(
- const Word16 L_frame, /* i : length of the frame */
- const Word16 L_subfr, /* i : length of subframe */
- const Word16 nb_subfr, /* i : number of subframes */
+void ivas_find_wsp_fx(
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 L_subfr, /* i : length of subframe Q0*/
+ const Word16 nb_subfr, /* i : number of subframes Q0*/
const Word16 *A_fx,
/* i : A(z) filter coefficients */ // Q12
Word16 *Aw_fx,
@@ -63,7 +63,7 @@ void ivas_find_wsp(
/* i/o: W(Z) denominator memory */ // Q_new
const Word16 gamma,
/* i : weighting factor */ // Q15
- const Word16 L_look /* i : look-ahead */
+ const Word16 L_look /* i : look-ahead Q0*/
)
{
Word16 *p_Aw_fx, tmp_fx;
@@ -79,7 +79,7 @@ void ivas_find_wsp(
* Compute weighted speech for all subframes
*-----------------------------------------------------------------*/
p_Aw_fx = Aw_fx;
- for ( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr )
+ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr )
{
Residu3_fx( p_Aw_fx, &speech_fx[i_subfr], &wsp_fx[i_subfr], L_subfr, 0 );
p_Aw_fx += ( M + 1 );
diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c
index de81f19214e626801376295422c993120a79672c..7468c3dc77c5fd6064b8665f05a46dbb5e6c806b 100644
--- a/lib_enc/find_wsp_fx.c
+++ b/lib_enc/find_wsp_fx.c
@@ -31,17 +31,17 @@
* void
*/
void find_wsp_fx(
- const Word16 Az[], /* i : A(z) filter coefficients */
- const Word16 speech[], /* i : pointer to the denoised speech frame */
- Word16 wsp[], /* o : poitnter to the weighted speech frame */
- Word16 *mem_wsp, /* i/o: W(Z) denominator memory */
- const Word16 preemph_fac, /* i : pre - emphasis factor Q15 */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 lookahead, /* i : look-ahead */
- const Word16 L_subfr, /* i : length of subframe */
- Word16 *Aw, /* o : weighted A(z) filter coefficients */
- const Word16 gamma, /* i : weighting factor */
- const Word16 nb_subfr /* i : number of subframes */
+ const Word16 Az[], /* i : A(z) filter coefficients Q12*/
+ const Word16 speech[], /* i : pointer to the denoised speech frame Q_new-preemph_bits*/
+ Word16 wsp[], /* o : poitnter to the weighted speech frame Q_new-preemph_bits*/
+ Word16 *mem_wsp, /* i/o: W(Z) denominator memory Q_new-preemph_bits*/
+ const Word16 preemph_fac, /* i : pre - emphasis factor Q15*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 lookahead, /* i : look-ahead Q0*/
+ const Word16 L_subfr, /* i : length of subframe Q0*/
+ Word16 *Aw, /* o : weighted A(z) filter coefficients Q12*/
+ const Word16 gamma, /* i : weighting factor Q15*/
+ const Word16 nb_subfr /* i : number of subframes Q0*/
)
{
Word16 i_subfr, wtmp;
diff --git a/lib_enc/frame_spec_dif_cor_rate_fx.c b/lib_enc/frame_spec_dif_cor_rate_fx.c
index 117ced6baf87ef4209f4d88104b659e4b4c84856..3e2eb40155f5e006eda820818db061688d9d2299 100644
--- a/lib_enc/frame_spec_dif_cor_rate_fx.c
+++ b/lib_enc/frame_spec_dif_cor_rate_fx.c
@@ -20,10 +20,10 @@
*
*-------------------------------------------------------------------*/
void frame_spec_dif_cor_rate_fx(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word32 *spec_amp, /* i : spectral amplitude*/
- Word16 sacle, /* i : the scaling of spec_amp*/
- Word16 f_tonality_rate[3] /* o : tonality rate*/
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ Word32 *spec_amp, /* i : spectral amplitude scale*/
+ Word16 sacle, /* i : the scaling of spec_amp */
+ Word16 f_tonality_rate[3] /* o : tonality rate Qx*/
)
{
@@ -36,22 +36,23 @@ void frame_spec_dif_cor_rate_fx(
Word32 m, dx, dy;
Word16 *pre_spec_low_dif = hVAD_CLDFB->pre_spec_low_dif;
const Word32 FIX_cost1 = 2147484 /* 0.001f Q31 */;
-
+ move16();
+ move32();
p_dx_Q = &dx_Q;
maxVal = 0;
move32();
FOR( i = 0; i < PRE_SPEC_DIF_NUM; i++ )
{
- tmp = L_sub( spec_amp[i + 6], spec_amp[i + 5] );
+ tmp = L_sub( spec_amp[i + 6], spec_amp[i + 5] ); /* scale */
if ( tmp < 0 )
{
tmp = 0;
move32();
}
- tmpspec_low_dif[i] = tmp;
+ tmpspec_low_dif[i] = tmp; /* scale */
move32();
- maxVal = L_max( maxVal, tmp );
+ maxVal = L_max( maxVal, tmp ); /* scale */
}
resu = 31;
move16();
@@ -71,14 +72,14 @@ void frame_spec_dif_cor_rate_fx(
FOR( i = 0; i < PRE_SPEC_DIF_NUM; i++ )
{
- spec_low_dif_tmp = round_fx( L_shl( tmpspec_low_dif[i], scalefactor ) );
- m = L_mac0( m, spec_low_dif_tmp, pre_spec_low_dif[i] );
- dx = L_mac0( dx, spec_low_dif_tmp, spec_low_dif_tmp );
- dy = L_mac0( dy, pre_spec_low_dif[i], pre_spec_low_dif[i] );
+ spec_low_dif_tmp = round_fx( L_shl( tmpspec_low_dif[i], scalefactor ) ); /* scale + scalefactor - 16 */
+ m = L_mac0( m, spec_low_dif_tmp, pre_spec_low_dif[i] ); /* scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif */
+ dx = L_mac0( dx, spec_low_dif_tmp, spec_low_dif_tmp ); /* scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif */
+ dy = L_mac0( dy, pre_spec_low_dif[i], pre_spec_low_dif[i] ); /* scale + scalefactor - 16 */
pre_spec_low_dif[i] = spec_low_dif_tmp;
move16();
}
- dx = L_mult0( round_fx( dx ), round_fx( dy ) );
+ dx = L_mult0( round_fx( dx ), round_fx( dy ) ); /* 2 * (scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif) - 32 */
tmpq = add( sacle, scalefactor );
tmpq = sub( tmpq, 16 );
tmpq2 = add( tmpq, hVAD_CLDFB->scale_spec_low_dif );
@@ -88,11 +89,11 @@ void frame_spec_dif_cor_rate_fx(
move16();
IF( LT_16( *p_dx_Q, 31 ) )
{
- dx = L_add( dx, L_shr( FIX_cost1, limitScale32( sub( 31, *p_dx_Q ) ) ) );
+ dx = L_add( dx, L_shr( FIX_cost1, limitScale32( sub( 31, *p_dx_Q ) ) ) ); /* 2 * (scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif) - 32 */
}
ELSE
{
- dx = L_add( L_shr( dx, limitScale32( sub( *p_dx_Q, 31 ) ) ), FIX_cost1 );
+ dx = L_add( L_shr( dx, limitScale32( sub( *p_dx_Q, 31 ) ) ), FIX_cost1 ); /* Q31 */
*p_dx_Q = 31;
move16();
}
@@ -110,10 +111,10 @@ void frame_spec_dif_cor_rate_fx(
f_tonality_rate[0] = spec_dif_cor_rate;
move16();
- tmp = L_mac0( L_mult0( f_tonality_rate[1], 31456 /* 0.96 Q15 */ ), spec_dif_cor_rate, 1311 /* 0.04 Q15 */ );
+ tmp = L_mac0( L_mult0( f_tonality_rate[1], 31456 /* 0.96 Q15 */ ), spec_dif_cor_rate, 1311 /* 0.04 Q15 */ ); /* tmpq */
f_tonality_rate[1] = shl( round_fx( tmp ), 1 );
move16();
- tmp = L_mac0( L_mult0( f_tonality_rate[2], 29490 /* 0.90 Q15 */ ), spec_dif_cor_rate, 3277 /* 0.1 Q15 */ );
+ tmp = L_mac0( L_mult0( f_tonality_rate[2], 29490 /* 0.90 Q15 */ ), spec_dif_cor_rate, 3277 /* 0.1 Q15 */ ); /* tmpq */
f_tonality_rate[2] = shl( round_fx( tmp ), 1 );
move16();
hVAD_CLDFB->scale_spec_low_dif = tmpq;
diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c
index 30caee67e01193ed958623185ab36ec51ea19e42..2988a8fb847696a49d359953e79c31dd6abdf460 100644
--- a/lib_enc/gain_enc_fx.c
+++ b/lib_enc/gain_enc_fx.c
@@ -50,14 +50,14 @@ static Word16 Find_Opt_gainQ_fx( Word16 *coeff, Word16 *exp_coeff, Word16 *gain_
/*==========================================================================*/
void Es_pred_enc_fx(
- Word16 *Es_pred, /* o : predicited scaled innovation energy Q8 */
- Word16 *indice, /* o : indice of quantization */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 *res, /* i : residual signal */
- const Word16 *voicing, /* i : normalized correlation in three 1/2frames */
- const Word16 nb_bits, /* i : allocated number of bits */
- const Word16 no_ltp, /* i : no_ltp flag */
- Word16 Q_new /* i : Scaling in speech Q0 */
+ Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/
+ Word16 *indice, /* o : indice of quantization Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ const Word16 *voicing, /* i : normalized correlation in three 1/2frames Q15*/
+ const Word16 nb_bits, /* i : allocated number of bits Q0*/
+ const Word16 no_ltp, /* i : no_ltp flag Q0*/
+ Word16 Q_new /* i : Scaling in speech Q0*/
)
{
Word16 i, i_subfr, size, tmp16, tmp16_2, Q_res;
@@ -67,6 +67,7 @@ void Es_pred_enc_fx(
Word32 ener_fx, Lmean_ener_code, Ltmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Lmean_ener_code = L_deposit_l( 0 );
@@ -90,11 +91,11 @@ void Es_pred_enc_fx(
FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR )
{
/* calculate the energy of residual signal */
- tmp16 = mult_r( res[i_subfr + 0], 8192 ); /* remove 2bits */
+ tmp16 = mult_r( res[i_subfr + 0], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/
ener_fx = L_mult( tmp16, tmp16 );
FOR( i = 1; i < L_SUBFR; i++ )
{
- tmp16 = mult_r( res[i_subfr + i], 8192 ); /* remove 2bits */
+ tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/
#ifdef BASOP_NOGLOB
ener_fx = L_mac_o( ener_fx, tmp16, tmp16, &Overflow );
#else
@@ -119,6 +120,7 @@ void Es_pred_enc_fx(
if ( ( ener_dB < 0 ) && ( no_ltp == 0 ) )
{
ener_dB = 0;
+ move16();
}
/* update the average energy of residual signal */
@@ -142,22 +144,22 @@ void Es_pred_enc_fx(
{
case 5:
{
- qua_table = Es_pred_qua_5b_fx;
+ qua_table = Es_pred_qua_5b_fx; // Q8
BREAK;
}
case 4:
{
- qua_table = Es_pred_qua_4b_fx;
+ qua_table = Es_pred_qua_4b_fx; // Q8
BREAK;
}
case 3:
{
- qua_table = Es_pred_qua_3b_fx;
+ qua_table = Es_pred_qua_3b_fx; // Q8
BREAK;
}
default:
{
- qua_table = Es_pred_qua_5b_fx;
+ qua_table = Es_pred_qua_5b_fx; // Q8
BREAK;
}
}
@@ -166,13 +168,13 @@ void Es_pred_enc_fx(
{
mean_ener_code16 = extract_h( Lmean_ener_code ); /*Q8*/
- qua_table = Es_pred_qua_4b_no_ltp_fx;
+ qua_table = Es_pred_qua_4b_no_ltp_fx; // Q8
}
/*size = extract_l(pow2_fx[nb_bits]); */ /*maximum number of bit is 6 */
size = shl( 1, nb_bits ); /*maximum number of bit is 6 */
/* find the nearest neighbour (codevector) */
- *Es_pred = qua_table[0];
+ *Es_pred = qua_table[0]; // Q8
move16();
tmp16 = abs_s( sub( mean_ener_code16, qua_table[0] ) );
*indice = 0;
@@ -191,7 +193,7 @@ void Es_pred_enc_fx(
move16();
*indice = i;
move16();
- *Es_pred = qua_table[i];
+ *Es_pred = qua_table[i]; // Q8
move16();
}
}
@@ -209,24 +211,24 @@ void Es_pred_enc_fx(
* - the mean-squared weighted error criterion is used for codebook search
*---------------------------------------------------------------------*/
void gain_enc_mless_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 element_mode, /* i : element mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *xn, /* i : target vector */
- const Word16 *y1, /* i : zero-memory filtered adaptive excitation */
- const Word16 Q_xn, /* i : xn and y1 scaling */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word16 Es_pred, /* i : predicted scaled innovation energy */
- Word16 *gain_pit, /* o : quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 Q_xn, /* i : xn and y1 scaling */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/
)
{
@@ -242,6 +244,7 @@ void gain_enc_mless_fx(
Word32 L_frac_num, L_frac_den, L_div;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
@@ -304,6 +307,7 @@ void gain_enc_mless_fx(
/* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */
L_tmp = Isqrt_lc( L_tmp, &exp_inov );
*gain_inov = extract_h( L_shl( L_tmp, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/* gcode0 = pow(10, 0.05 * (Es_pred - Ei)) */
/*----------------------------------------------------------------*
@@ -325,7 +329,7 @@ void gain_enc_mless_fx(
* select the codebook, size and number of bits
* set the gains searching range
*-----------------------------------------------------------------*/
- nBits = gains_mode[shr( i_subfr, 6 )];
+ nBits = gains_mode[i_subfr >> 6];
move16();
test();
@@ -364,9 +368,9 @@ void gain_enc_mless_fx(
}
L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
- frac_den = extract_h( L_frac_den );
- frac_den = s_max( frac_den, 1 );
- L_frac_den = L_max( L_frac_den, 1 );
+ frac_den = extract_h( L_frac_den ); /* Q15 */
+ frac_den = s_max( frac_den, 1 ); /* Q15 */
+ L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */
exp = norm_l( L_frac_den );
tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/
@@ -409,11 +413,13 @@ void gain_enc_mless_fx(
{
L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/
exp_num = exp1;
+ move16();
}
ELSE
{
L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/
exp_num = exp2;
+ move16();
}
L_frac_num = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
@@ -428,6 +434,7 @@ void gain_enc_mless_fx(
move32(); /*Q16*/
*gain_pit = s_max( G_PITCH_MIN_TC192_Q14, s_min( *gain_pit, G_PITCH_MAX_TC192_Q14 ) );
+ move16();
/* set number of bits for two SQs */
nBits2 = shr( add( nBits, 1 ), 1 );
@@ -447,6 +454,7 @@ void gain_enc_mless_fx(
tmp = div_s( 16384, gcode0 ); /*Q15*/
L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/
*gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg );
@@ -477,7 +485,7 @@ void gain_enc_mless_fx(
case 6:
{
qua_table = gain_qua_mless_6b_fx;
- if ( GT_16( element_mode, EVS_MONO ) )
+ if ( element_mode > EVS_MONO )
{
#ifdef IVAS_CODE
qua_table = gain_qua_mless_6b_stereo;
@@ -494,7 +502,7 @@ void gain_enc_mless_fx(
}
case 5:
{
- qua_table = gain_qua_mless_5b_fx;
+ qua_table = gain_qua_mless_5b_fx; // Q14
move16();
if ( EQ_16( clip_gain, 1 ) )
{
@@ -504,7 +512,7 @@ void gain_enc_mless_fx(
}
default:
{
- qua_table = gain_qua_mless_6b_fx;
+ qua_table = gain_qua_mless_6b_fx; // Q14
move16();
if ( EQ_16( clip_gain, 1 ) )
{
@@ -525,7 +533,7 @@ void gain_enc_mless_fx(
/*-----------------------------------------------------------------*
* search for the best quantizer
*-----------------------------------------------------------------*/
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, qua_table, size );
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, qua_table, size ); // Q0
push_indice_fx( hBstr, IND_GAIN, index, nBits );
}
@@ -541,24 +549,24 @@ void gain_enc_mless_fx(
}
void gain_enc_mless_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 element_mode, /* i : element mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *xn, /* i : target vector */
- const Word16 *y1, /* i : zero-memory filtered adaptive excitation */
- const Word16 Q_xn, /* i : xn and y1 scaling */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word16 Es_pred, /* i : predicted scaled innovation energy */
- Word16 *gain_pit, /* o : quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 Q_xn, /* i : xn and y1 scaling */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/
)
{
@@ -574,6 +582,7 @@ void gain_enc_mless_ivas_fx(
Word32 L_frac_num, L_frac_den, L_div;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
@@ -636,6 +645,7 @@ void gain_enc_mless_ivas_fx(
/* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */
L_tmp = Isqrt_lc( L_tmp, &exp_inov );
*gain_inov = extract_h( L_shl( L_tmp, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/* gcode0 = pow(10, 0.05 * (Es_pred - Ei)) */
/*----------------------------------------------------------------*
@@ -657,7 +667,7 @@ void gain_enc_mless_ivas_fx(
* select the codebook, size and number of bits
* set the gains searching range
*-----------------------------------------------------------------*/
- nBits = gains_mode[shr( i_subfr, 6 )];
+ nBits = gains_mode[i_subfr >> 6];
move16();
test();
@@ -696,9 +706,9 @@ void gain_enc_mless_ivas_fx(
}
L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
- frac_den = extract_h( L_frac_den );
- frac_den = s_max( frac_den, 1 );
- L_frac_den = L_max( L_frac_den, 1 );
+ frac_den = extract_h( L_frac_den ); /* Q15 */
+ frac_den = s_max( frac_den, 1 ); /* Q15 */
+ L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */
exp = norm_l( L_frac_den );
tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/
@@ -741,11 +751,13 @@ void gain_enc_mless_ivas_fx(
{
L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/
exp_num = exp1;
+ move16();
}
ELSE
{
L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/
exp_num = exp2;
+ move16();
}
L_frac_num = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
@@ -779,6 +791,7 @@ void gain_enc_mless_ivas_fx(
tmp = div_s( 16384, gcode0 ); /*Q15*/
L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/
*gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg );
@@ -798,8 +811,7 @@ void gain_enc_mless_ivas_fx(
{
case 7:
{
- qua_table = gain_qua_mless_7b_fx;
- move16();
+ qua_table = gain_qua_mless_7b_fx; // Q14
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 30 );
@@ -808,12 +820,11 @@ void gain_enc_mless_ivas_fx(
}
case 6:
{
- qua_table = gain_qua_mless_6b_fx;
- if ( GT_16( element_mode, EVS_MONO ) )
+ qua_table = gain_qua_mless_6b_fx; // Q14
+ if ( element_mode > EVS_MONO )
{
qua_table = gain_qua_mless_6b_stereo_fx;
}
- move16();
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 14 );
@@ -822,8 +833,7 @@ void gain_enc_mless_ivas_fx(
}
case 5:
{
- qua_table = gain_qua_mless_5b_fx;
- move16();
+ qua_table = gain_qua_mless_5b_fx; // Q14
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 6 );
@@ -832,8 +842,7 @@ void gain_enc_mless_ivas_fx(
}
default:
{
- qua_table = gain_qua_mless_6b_fx;
- move16();
+ qua_table = gain_qua_mless_6b_fx; // Q14
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 14 );
@@ -862,7 +871,7 @@ void gain_enc_mless_ivas_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
return;
@@ -880,21 +889,21 @@ void gain_enc_mless_ivas_fx(
*---------------------------------------------------------------------*/
void gain_enc_SQ_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *xn, /* i : target vector Q_xn */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9 */
- const Word16 *code, /* i : algebraic excitation Q9 */
- const Word16 Es_pred, /* i : predicted scaled innovation energy Q8 */
- Word16 *gain_pit, /* o : quantized pitch gain Q14 */
- Word32 *gain_code, /* o : quantized codebook gain Q16 */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12 */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16 */
- Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const Word16 Q_xn /* i : xn and y1 scaling */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
)
{
Word16 index, nBits_pitch, nBits_code;
@@ -909,6 +918,7 @@ void gain_enc_SQ_fx(
Word32 L_frac_num, L_frac_den, L_div;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
@@ -931,16 +941,19 @@ void gain_enc_SQ_fx(
/* Compute scalar product */
coeff[2] = extract_h( Dot_product12( y2, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) );
move16(); /* -18 (y2 Q9) */
/* Compute scalar product */
coeff[3] = extract_h( Dot_product12( xn, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[3] = add( sub( exp, 9 ), Q_xn );
move16(); /* -9 (y2 Q9), (xn y2) */
/* Compute scalar product */
coeff[4] = extract_h( Dot_product12( yy1, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[4] = add( sub( exp, 9 ), Q_xn );
move16(); /* -9 (y2 Q9), (y1 y2) */
@@ -1031,9 +1044,9 @@ void gain_enc_SQ_fx(
}
L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
- frac_den = extract_h( L_frac_den );
- frac_den = s_max( frac_den, 1 );
- L_frac_den = L_max( L_frac_den, 1 );
+ frac_den = extract_h( L_frac_den ); /* Q15 */
+ frac_den = s_max( frac_den, 1 ); /* Q15 */
+ L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */
exp = norm_l( L_frac_den );
tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/
@@ -1081,11 +1094,13 @@ void gain_enc_SQ_fx(
{
L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/
exp_num = exp1;
+ move16();
}
ELSE
{
L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/
exp_num = exp2;
+ move16();
}
#ifdef BASOP_NOGLOB
L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/
@@ -1111,14 +1126,14 @@ void gain_enc_SQ_fx(
test();
test();
- IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) )
+ IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 /* 0.95 in Q14 */ ) )
{
- *gain_pit = 15565;
+ *gain_pit = 15565; /* 0.95 in Q14 */
move16();
}
- ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 ) )
+ ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 /* 0.65 in Q14 */ ) )
{
- *gain_pit = 10650;
+ *gain_pit = 10650; /* 0.65 in Q14 */
move16();
}
@@ -1126,7 +1141,8 @@ void gain_enc_SQ_fx(
* search for the best quantized values
*-----------------------------------------------------------------*/
- nBits_pitch = gains_mode[shr( i_subfr, 6 )];
+ nBits_pitch = gains_mode[i_subfr >> 6];
+ move16();
/* set number of bits for two SQs */
nBits_code = shr( add( nBits_pitch, 1 ), 1 );
@@ -1136,8 +1152,7 @@ void gain_enc_SQ_fx(
/*tmp1 = (G_PITCH_MAX - G_PITCH_MIN) / ((1 << nBits_pitch) - 1);*/ /* set quantization step */
tmp1 = mult_r( G_PITCH_MAX_Q13, div_s( 1, sub( shl( 1, nBits_pitch ), 1 ) ) ); /*Q13*/ /* set quantization step */
- index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) );
- move16();
+ index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) ); // Q0
push_indice_fx( hBstr, IND_GAIN_PIT, index, nBits_pitch );
/* gain_code Q */
@@ -1147,6 +1162,7 @@ void gain_enc_SQ_fx(
tmp = div_s( 16384, gcode0 ); /*Q15*/
L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/
*gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_Q14, LG10_G_CODE_MAX_Q13, nBits_code, &expg );
@@ -1164,28 +1180,28 @@ void gain_enc_SQ_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
return;
}
void gain_enc_SQ_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *xn, /* i : target vector Q_xn */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9 */
- const Word16 *code, /* i : algebraic excitation Q9 */
- const Word16 Es_pred, /* i : predicted scaled innovation energy Q8 */
- Word16 *gain_pit, /* o : quantized pitch gain Q14 */
- Word32 *gain_code, /* o : quantized codebook gain Q16 */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12 */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16 */
- Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const Word16 Q_xn /* i : xn and y1 scaling */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
)
{
Word16 index, nBits_pitch, nBits_code;
@@ -1200,6 +1216,7 @@ void gain_enc_SQ_ivas_fx(
Word32 L_frac_num, L_frac_den, L_div;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
@@ -1222,16 +1239,19 @@ void gain_enc_SQ_ivas_fx(
/* Compute scalar product */
coeff[2] = extract_h( Dot_product12( y2, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) );
move16(); /* -18 (y2 Q9) */
/* Compute scalar product */
coeff[3] = extract_h( Dot_product12( xn, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[3] = add( sub( exp, 9 ), Q_xn );
move16(); /* -9 (y2 Q9), (xn y2) */
/* Compute scalar product */
coeff[4] = extract_h( Dot_product12( yy1, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[4] = add( sub( exp, 9 ), Q_xn );
move16(); /* -9 (y2 Q9), (y1 y2) */
@@ -1322,9 +1342,9 @@ void gain_enc_SQ_ivas_fx(
}
L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
- frac_den = extract_h( L_frac_den );
- frac_den = s_max( frac_den, 1 );
- L_frac_den = L_max( L_frac_den, 1 );
+ frac_den = extract_h( L_frac_den ); /* Q15 */
+ frac_den = s_max( frac_den, 1 ); /* Q15 */
+ L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */
exp = norm_l( L_frac_den );
tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/
@@ -1358,15 +1378,17 @@ void gain_enc_SQ_ivas_fx(
#ifdef BASOP_NOGLOB
*gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/
-#else /* BASOP_NOGLOB */
+ move16();
+#else /* BASOP_NOGLOB */
*gain_pit = round_fx( L_shl( L_div, add( exp, exp_div ) ) ); /*Q14*/
-#endif /* BASOP_NOGLOB */
+ move16();
+#endif /* BASOP_NOGLOB */
// To be checked
#ifdef BASOP_NOGLOB
L_tmp1 = L_mult_o( coeff[1], coeff[4], &Overflow ); /*Q31*/
#else /* BASOP_NOGLOB */
- L_tmp1 = L_mult( coeff[1], coeff[4] ); /*Q31*/
+ L_tmp1 = L_mult( coeff[1], coeff[4] ); /*Q31*/
#endif /* BASOP_NOGLOB */
exp1 = add( exp_coeff[1], exp_coeff[4] );
@@ -1377,16 +1399,18 @@ void gain_enc_SQ_ivas_fx(
{
L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/
exp_num = exp1;
+ move16();
}
ELSE
{
L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/
exp_num = exp2;
+ move16();
}
#ifdef BASOP_NOGLOB
L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/
#else /* BASOP_NOGLOB */
- L_frac_num = L_sub( L_tmp2, L_tmp1 ); /*Q31*/
+ L_frac_num = L_sub( L_tmp2, L_tmp1 ); /*Q31*/
#endif /* BASOP_NOGLOB */
L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/
@@ -1407,14 +1431,14 @@ void gain_enc_SQ_ivas_fx(
test();
test();
- IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) )
+ IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 /* 0.95 in Q14 */ ) )
{
- *gain_pit = 15565;
+ *gain_pit = 15565; /* 0.95 in Q14 */
move16();
}
- ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 ) )
+ ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 /* 0.65 in Q14 */ ) )
{
- *gain_pit = 10650;
+ *gain_pit = 10650; /* 0.65 in Q14 */
move16();
}
@@ -1422,7 +1446,8 @@ void gain_enc_SQ_ivas_fx(
* search for the best quantized values
*-----------------------------------------------------------------*/
- nBits_pitch = gains_mode[shr( i_subfr, 6 )];
+ nBits_pitch = gains_mode[i_subfr >> 6];
+ move16();
/* set number of bits for two SQs */
nBits_code = shr( add( nBits_pitch, 1 ), 1 );
@@ -1433,7 +1458,6 @@ void gain_enc_SQ_ivas_fx(
tmp1 = mult_r( G_PITCH_MAX_Q13, div_s( 1, sub( shl( 1, nBits_pitch ), 1 ) ) ); /*Q13*/ /* set quantization step */
index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) );
- move16();
push_indice( hBstr, IND_GAIN_PIT, index, nBits_pitch );
/* gain_code Q */
@@ -1443,6 +1467,7 @@ void gain_enc_SQ_ivas_fx(
tmp = div_s( 16384, gcode0 ); /*Q15*/
L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/
*gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_Q14, LG10_G_CODE_MAX_Q13, nBits_code, &expg );
@@ -1460,7 +1485,7 @@ void gain_enc_SQ_ivas_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
return;
@@ -1471,12 +1496,12 @@ void gain_enc_SQ_ivas_fx(
*
* Quantization of gain for Gaussian codebook
*-------------------------------------------------------------------*/
-Word16 gain_enc_gaus_fx( /* o : Return index of quantization */
- Word32 *gain, /* i/o: Code gain to quantize */
- const Word16 bits, /* i : number of bits to quantize */
- const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8 */
- const Word16 stepSize, /* i : Step size choice Q14 */
- const Word16 inv_stepSize /* i : Step size choice Q15 */
+Word16 gain_enc_gaus_fx( /* o : Return index of quantization */
+ Word32 *gain, /* i/o: Code gain to quantize Q16*/
+ const Word16 bits, /* i : number of bits to quantize Q0*/
+ const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/
+ const Word16 stepSize, /* i : Step size choice Q14*/
+ const Word16 inv_stepSize /* i : Step size choice Q15*/
)
{
Word16 index, exp_gain, frac_gain, wtmp;
@@ -1484,6 +1509,7 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant
Word32 Ltmp, enr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*enr = 20.0 * log10(*gain + 0.001) codebook gain in dB */
exp_gain = norm_l( *gain );
@@ -1499,10 +1525,10 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant
wtmp = sub( wenr, lowBound ); /* Q8 */
- index = extract_l( L_shr( L_mac( 8388608, wtmp, inv_stepSize ), 16 + 8 ) );
+ index = extract_l( L_shr( L_mac( 8388608, wtmp, inv_stepSize ), 16 + 8 ) ); // Q0
/* index [0 (1<> 6]; // Q0
+ move16();
/*----------------------------------------------------------------*
* find the code pitch (for current subframe)
@@ -1774,7 +1808,7 @@ void gain_enc_tc_ivas_fx(
i = sub( exp_num, exp_den ); /* Gain_trans in Q7 */
g_code_fx = i_mult2( g_code_fx, tmp16 ); /* apply sign */
#ifdef BASOP_NOGLOB
- *gain_code_fx = L_shr_sat( L_deposit_l( g_code_fx ), i );
+ *gain_code_fx = L_shr_sat( L_deposit_l( g_code_fx ), i ); /* Q16 */
#else
*gain_code_fx = L_shr( L_deposit_l( g_code_fx ), i );
#endif
@@ -1828,6 +1862,7 @@ void gain_enc_tc_ivas_fx(
tmp16 = div_s( 16384, gcode0_fx ); /*Q15*/
L_tmp = Mult_32_16( *gain_code_fx, tmp16 ); /*Q16*/
*gain_code_fx = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
ELSE
{
@@ -1868,7 +1903,7 @@ void gain_enc_tc_ivas_fx(
{
/* 2-bit -> 3-bit decoding */
index = shr( index, 1 );
- wgain_code = tbl_gain_code_tc_fx[shl( index, 1 )];
+ wgain_code = tbl_gain_code_tc_fx[index * 2]; // Q13
move16();
/**gain_code *= gcode0;*/
L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */
@@ -1878,7 +1913,7 @@ void gain_enc_tc_ivas_fx(
}
ELSE /* nBits == 3 */
{
- wgain_code = tbl_gain_code_tc_fx[index];
+ wgain_code = tbl_gain_code_tc_fx[index]; // Q13
move16();
/**gain_code *= gcode0;*/
L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */
@@ -1900,7 +1935,7 @@ void gain_enc_tc_ivas_fx(
expg = s_max( expg, 0 );
tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx );
- *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) );
+ *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); // Q6
move32();
return;
}
@@ -1910,14 +1945,14 @@ void gain_enc_tc_ivas_fx(
* Find the best quantizer
*-----------------------------------------------------------------*/
static Word16 Find_Opt_gainQ_fx(
- Word16 *coeff,
+ Word16 *coeff, /* exp(exp_coeff) */
Word16 *exp_coeff,
- Word16 *gain_pit,
- Word32 *gain_code,
- Word16 gcode0,
+ Word16 *gain_pit, /* Q14 */
+ Word32 *gain_code, /* Q16 */
+ Word16 gcode0, /* exp(exp_gcode0) */
Word16 exp_gcode0,
- const Word16 *cdbk, /* i : Codebook used */
- const Word16 size /* i : size of Codebook used */
+ const Word16 *cdbk, /* i : Codebook used Q14*/
+ const Word16 size /* i : size of Codebook used Q0*/
)
{
Word16 index, i, j;
@@ -1930,6 +1965,7 @@ static Word16 Find_Opt_gainQ_fx(
Word32 L_tmp, L_tmp1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -1993,7 +2029,7 @@ static Word16 Find_Opt_gainQ_fx(
}
/* searching of codebook */
- p = cdbk;
+ p = cdbk; // Q14
move16();
dist_min = L_deposit_h( MAX_16 );
index = 0;
@@ -2005,8 +2041,8 @@ static Word16 Find_Opt_gainQ_fx(
g_code = *p++;
move16();
- g_code = mult_r( g_code, gcode0 );
- g2_pitch = mult_r( g_pitch, g_pitch );
+ g_code = mult_r( g_code, gcode0 ); // exp_gcode - 1
+ g2_pitch = mult_r( g_pitch, g_pitch ); // Q13
g_pit_cod = mult_r( g_code, g_pitch );
L_tmp = L_mult( g_code, g_code );
g2_code_lo = L_Extract_lc( L_tmp, &g2_code );
@@ -2019,11 +2055,11 @@ static Word16 Find_Opt_gainQ_fx(
L_tmp = L_mac( L_tmp, coeff_lo[3], g_code );
L_tmp = L_mac( L_tmp, coeff_lo[4], g_pit_cod );
L_tmp = L_shr( L_tmp, 12 );
- L_tmp = L_mac( L_tmp, coeff[0], g2_pitch );
- L_tmp = L_mac( L_tmp, coeff[1], g_pitch );
- L_tmp = L_mac( L_tmp, coeff[2], g2_code );
- L_tmp = L_mac( L_tmp, coeff[3], g_code );
- L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod );
+ L_tmp = L_mac( L_tmp, coeff[0], g2_pitch ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[1], g_pitch ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[2], g2_code ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[3], g_code ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */
#ifdef BASOP_NOGLOB
L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow );
@@ -2038,7 +2074,7 @@ static Word16 Find_Opt_gainQ_fx(
dist_min = L_min( L_tmp, dist_min );
}
- p = &cdbk[add( index, index )];
+ p = &cdbk[add( index, index )]; // Q14
move16();
*gain_pit = *p++; /* selected pitch gain in Q14 */
@@ -2070,10 +2106,10 @@ static Word16 Find_Opt_gainQ_fx(
*---------------------------------------------------------------------*/
void gain_enc_lbr_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 coder_type, /* i : coding type Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
const Word16 *xn, /* i : target vector Q_xn*/
const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
const Word16 Q_xn, /* i : xn and y1 format */
@@ -2084,10 +2120,10 @@ void gain_enc_lbr_fx(
Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const int16_t L_subfr /* i : subframe length */
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 L_subfr /* i : subframe length Q0*/
)
{
@@ -2097,6 +2133,8 @@ void gain_enc_lbr_fx(
Word16 coeff[5], exp_coeff[5];
Word16 exp, exp_code, exp_inov, exp_gcode0, frac, tmp, L_subfr_sf;
Word32 L_tmp, L_tmp1, L_inov;
+ move16();
+ move16();
L_subfr_sf = 6;
move16();
@@ -2128,18 +2166,21 @@ void gain_enc_lbr_fx(
}
#endif
coeff[2] = extract_h( Dot_product12( y2, y2, L_subfr, &exp ) );
+ move16();
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */
move16();
/* Compute scalar product -2* */
coeff[3] = extract_h( L_negate( Dot_product12( xn, y2, L_subfr, &exp ) ) );
+ move16();
exp_coeff[3] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 xn y2) */
move16();
/* Compute scalar product 2* */
coeff[4] = extract_h( Dot_product12( y1, y2, L_subfr, &exp ) );
+ move16();
exp_coeff[4] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 yy1 y2) */
move16();
@@ -2155,6 +2196,7 @@ void gain_enc_lbr_fx(
exp_inov = sub( exp_code, add( 18, L_subfr_sf ) );
L_inov = Isqrt_lc( L_inov, &exp_inov );
*gain_inov = extract_h( L_shl( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/*-----------------------------------------------------------------*
@@ -2172,9 +2214,10 @@ void gain_enc_lbr_fx(
* calculate prediction of gcode
* search for the best codeword
*-----------------------------------------------------------------*/
+ test();
IF( i_subfr == 0 )
{
- b = b_1sfr_fx;
+ b = b_1sfr_fx; // Q12
move16();
n_pred = 2;
move16();
@@ -2183,43 +2226,38 @@ void gain_enc_lbr_fx(
{
case 8:
{
- cdbk = gp_gamma_1sfr_8b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_8b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 60 );
}
- move16();
BREAK;
}
case 7:
{
- cdbk = gp_gamma_1sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 27 );
}
- move16();
BREAK;
}
case 6:
{
- cdbk = gp_gamma_1sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 10 );
}
- move16();
BREAK;
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
+ move16();
/* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode));
gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode));
@@ -2251,7 +2289,7 @@ void gain_enc_lbr_fx(
/* output of Pow2() will be: */
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
gc_mem[0] = *gain_code;
move16(); /*Q16*/
@@ -2269,30 +2307,26 @@ void gain_enc_lbr_fx(
{
case 7:
{
- cdbk = gp_gamma_2sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_2sfr_7b_fx; /* Q14/Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 30 );
}
- move16();
BREAK;
}
case 6:
{
- cdbk = gp_gamma_2sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_2sfr_6b_fx; /* Q14/Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 12 );
}
- move16();
BREAK;
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2305,6 +2339,7 @@ void gain_enc_lbr_fx(
L_tmp1 = Mpy_32_16( exp, frac, 9864 );
move16(); /* Q16 */
aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
aux[3] = shr( gp_mem[0], 2 );
move16(); /*Q12*/
@@ -2323,15 +2358,15 @@ void gain_enc_lbr_fx(
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
- gc_mem[1] = *gain_code;
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
+ gc_mem[1] = *gain_code; // Q16
move32();
- gp_mem[1] = *gain_pit;
+ gp_mem[1] = *gain_pit; // Q14
move16();
}
ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
{
- b = b_3sfr_fx;
+ b = b_3sfr_fx; // Q12
move16();
n_pred = 6;
move16();
@@ -2349,15 +2384,14 @@ void gain_enc_lbr_fx(
}
ELSE
{
- cdbk = gp_gamma_3sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_3sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 11 );
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2369,6 +2403,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[0])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[3] = (float)log10(gc_mem[1]);
= log2(gc_mem[1])*log10(2);*/
@@ -2377,6 +2412,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[1])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
aux[4] = shr( gp_mem[0], 2 );
move16(); /*Q12*/
@@ -2426,14 +2462,14 @@ void gain_enc_lbr_fx(
index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
- gc_mem[2] = *gain_code;
+ gc_mem[2] = *gain_code; // Q16
move32();
- gp_mem[2] = *gain_pit;
+ gp_mem[2] = *gain_pit; // Q14
move16();
}
ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) )
{
- b = b_4sfr_fx;
+ b = b_4sfr_fx; // Q12
move16();
n_pred = 8;
move16();
@@ -2451,16 +2487,14 @@ void gain_enc_lbr_fx(
}
ELSE
{
- cdbk = gp_gamma_4sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_4sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 11 );
- move16();
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2472,6 +2506,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[0])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[3] = (float)log10(gc_mem[1]);
= log2(gc_mem[1])*log10(2);*/
@@ -2480,6 +2515,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[1])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[4] = (float)log10(gc_mem[2]);
@@ -2489,6 +2525,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[2])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[4] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
aux[5] = shr( gp_mem[0], 2 );
move16(); /*Q12*/
@@ -2510,7 +2547,7 @@ void gain_enc_lbr_fx(
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
}
/* *norm_gain_code = *gain_code / *gain_inov; */
@@ -2518,7 +2555,7 @@ void gain_enc_lbr_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
{
push_indice_fx( hBstr, IND_GAIN, index, nBits );
@@ -2527,10 +2564,10 @@ void gain_enc_lbr_fx(
}
void gain_enc_lbr_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 coder_type, /* i : coding type Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
const Word16 *xn, /* i : target vector Q_xn*/
const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
const Word16 Q_xn, /* i : xn and y1 format */
@@ -2541,10 +2578,10 @@ void gain_enc_lbr_ivas_fx(
Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const int16_t L_subfr /* i : subframe length */
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 L_subfr /* i : subframe length Q0*/
)
{
@@ -2554,6 +2591,7 @@ void gain_enc_lbr_ivas_fx(
Word16 coeff[5], exp_coeff[5];
Word16 exp, exp_code, exp_inov, exp_gcode0, frac, tmp, L_subfr_sf;
Word32 L_tmp, L_tmp1, L_inov;
+ move16();
L_subfr_sf = 6;
move16();
@@ -2585,18 +2623,21 @@ void gain_enc_lbr_ivas_fx(
}
#endif
coeff[2] = extract_h( Dot_product12( y2, y2, L_subfr, &exp ) );
+ move16();
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */
move16();
/* Compute scalar product -2* */
coeff[3] = extract_h( L_negate( Dot_product12( xn, y2, L_subfr, &exp ) ) );
+ move16();
exp_coeff[3] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 xn y2) */
move16();
/* Compute scalar product 2* */
coeff[4] = extract_h( Dot_product12( y1, y2, L_subfr, &exp ) );
+ move16();
exp_coeff[4] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 yy1 y2) */
move16();
@@ -2612,6 +2653,7 @@ void gain_enc_lbr_ivas_fx(
exp_inov = sub( exp_code, add( 18, L_subfr_sf ) );
L_inov = Isqrt_lc( L_inov, &exp_inov );
*gain_inov = extract_h( L_shl_sat( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/*-----------------------------------------------------------------*
@@ -2629,9 +2671,10 @@ void gain_enc_lbr_ivas_fx(
* calculate prediction of gcode
* search for the best codeword
*-----------------------------------------------------------------*/
+ test();
IF( i_subfr == 0 )
{
- b = b_1sfr_fx;
+ b = b_1sfr_fx; // Q12
move16();
n_pred = 2;
move16();
@@ -2640,43 +2683,38 @@ void gain_enc_lbr_ivas_fx(
{
case 8:
{
- cdbk = gp_gamma_1sfr_8b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_8b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 60 );
}
- move16();
BREAK;
}
case 7:
{
- cdbk = gp_gamma_1sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 27 );
}
- move16();
BREAK;
}
case 6:
{
- cdbk = gp_gamma_1sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 10 );
}
- move16();
BREAK;
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
+ move16();
/* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode));
gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode));
@@ -2717,7 +2755,7 @@ void gain_enc_lbr_ivas_fx(
}
ELSE IF( EQ_16( i_subfr, L_SUBFR ) || EQ_16( L_subfr, 2 * L_SUBFR ) )
{
- b = b_2sfr_fx;
+ b = b_2sfr_fx; // Q12
move16();
n_pred = 4;
move16();
@@ -2726,8 +2764,7 @@ void gain_enc_lbr_ivas_fx(
{
case 7:
{
- cdbk = gp_gamma_2sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_2sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 30 );
@@ -2736,8 +2773,7 @@ void gain_enc_lbr_ivas_fx(
}
case 6:
{
- cdbk = gp_gamma_2sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_2sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 12 );
@@ -2747,7 +2783,7 @@ void gain_enc_lbr_ivas_fx(
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2778,21 +2814,21 @@ void gain_enc_lbr_ivas_fx(
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
- gc_mem[1] = *gain_code;
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
+ gc_mem[1] = *gain_code; // Q16
move32();
- gp_mem[1] = *gain_pit;
+ gp_mem[1] = *gain_pit; // Q14
move16();
}
ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
{
- b = b_3sfr_fx;
+ b = b_3sfr_fx; // Q12
move16();
n_pred = 6;
move16();
IF( EQ_16( nBits, 7 ) )
{
- cdbk = gp_gamma_3sfr_7b_fx;
+ cdbk = gp_gamma_3sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 28 );
@@ -2800,15 +2836,14 @@ void gain_enc_lbr_ivas_fx(
}
ELSE
{
- cdbk = gp_gamma_3sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_3sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 11 );
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; // Q12
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2820,6 +2855,7 @@ void gain_enc_lbr_ivas_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[0])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[3] = (float)log10(gc_mem[1]);
= log2(gc_mem[1])*log10(2);*/
@@ -2878,21 +2914,20 @@ void gain_enc_lbr_ivas_fx(
index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
- gc_mem[2] = *gain_code;
+ gc_mem[2] = *gain_code; /* Q16 */
move32();
- gp_mem[2] = *gain_pit;
+ gp_mem[2] = *gain_pit; /* Q14 */
move16();
}
ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) )
{
- b = b_4sfr_fx;
+ b = b_4sfr_fx; /* Q12 */
move16();
n_pred = 8;
move16();
IF( EQ_16( nBits, 7 ) )
{
- cdbk = gp_gamma_4sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_4sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 25 );
@@ -2900,15 +2935,14 @@ void gain_enc_lbr_ivas_fx(
}
ELSE
{
- cdbk = gp_gamma_4sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_4sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 11 );
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; // Q12
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2960,7 +2994,7 @@ void gain_enc_lbr_ivas_fx(
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
}
/* *norm_gain_code = *gain_code / *gain_inov; */
@@ -2968,7 +3002,7 @@ void gain_enc_lbr_ivas_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
{
push_indice( hBstr, IND_GAIN, index, nBits );
@@ -2989,20 +3023,20 @@ void gain_enc_lbr_ivas_fx(
void gain_enc_amr_wb_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *xn, /* i : target vector */
- const Word16 Q_xn, /* i : xn and yy1 format Q0 */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word32 core_brate, /* i : core bitrate */
- Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- Word16 *past_qua_en /* i/o: gain quantization memory (4 words) */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 Q_xn, /* i : xn and yy1 format */
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/
)
{
@@ -3015,15 +3049,16 @@ void gain_enc_amr_wb_fx(
const Word16 *t_qua_gain, *p;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
* Find the initial quantization pitch index
* Set gains search range
*----------------------------------------------------------------*/
- IF( core_brate >= ACELP_12k65 )
+ IF( GE_32( core_brate, ACELP_12k65 ) )
{
- t_qua_gain = t_qua_gain7b_fx;
+ t_qua_gain = t_qua_gain7b_fx; // Q14
move16();
/* pt at 1/4th of table */
p = t_qua_gain7b_fx + RANGE;
@@ -3038,14 +3073,14 @@ void gain_enc_amr_wb_fx(
}
min_ind = 0;
move16();
- g_pitch = *gain_pit;
+ g_pitch = *gain_pit; // Q14
move16();
FOR( i = 0; i < j; i++ )
{
if ( GT_16( g_pitch, *p ) )
{
- min_ind = add( min_ind, 1 );
+ min_ind = add( min_ind, 1 ); // Q0
}
p += 2;
}
@@ -3055,7 +3090,7 @@ void gain_enc_amr_wb_fx(
}
ELSE
{
- t_qua_gain = t_qua_gain6b_fx;
+ t_qua_gain = t_qua_gain6b_fx; // Q14
min_ind = 0;
move16();
size = RANGE;
@@ -3090,14 +3125,20 @@ void gain_enc_amr_wb_fx(
/* Compute scalar product */
coeff[2] = extract_h( Dot_product12( y2, y2, L_SUBFR, &exp ) );
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */
+ move16();
+ move16();
/* Compute scalar product -2* */
coeff[3] = extract_h( L_negate( Dot_product12( xn, y2, L_SUBFR, &exp ) ) );
exp_coeff[3] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 xn y2) */
+ move16();
+ move16();
/* Compute scalar product 2* */
coeff[4] = extract_h( Dot_product12( yy1, y2, L_SUBFR, &exp ) );
exp_coeff[4] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 yy1 y2) */
+ move16();
+ move16();
/*----------------------------------------------------------------*
* Find energy of code and compute:
@@ -3112,6 +3153,7 @@ void gain_enc_amr_wb_fx(
exp_inov = sub( exp_code, 18 + 6 );
L_inov = Isqrt_lc( L_inov, &exp_inov );
*gain_inov = extract_h( L_shl( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
exp_code = sub( exp_code, 18 + 6 + 31 );
frac = Log2_lc( L_tmp, &exp );
@@ -3208,7 +3250,7 @@ void gain_enc_amr_wb_fx(
/* Codebook search */
dist_min = L_add( MAX_32, 0 );
- p = &t_qua_gain[shl( min_ind, 1 )];
+ p = &t_qua_gain[shl( min_ind, 1 )]; // Q14
move16();
index = 0;
@@ -3220,8 +3262,8 @@ void gain_enc_amr_wb_fx(
g_code = *p++;
move16();
- g_code = mult_r( g_code, gcode0 );
- g2_pitch = mult_r( g_pitch, g_pitch );
+ g_code = mult_r( g_code, gcode0 ); // exp(gcode) - 1
+ g2_pitch = mult_r( g_pitch, g_pitch ); // Q13
g_pit_cod = mult_r( g_code, g_pitch );
L_tmp = L_mult( g_code, g_code );
L_Extract( L_tmp, &g2_code, &g2_code_lo );
@@ -3234,11 +3276,11 @@ void gain_enc_amr_wb_fx(
L_tmp = L_mac( L_tmp, coeff_lo[3], g_code );
L_tmp = L_mac( L_tmp, coeff_lo[4], g_pit_cod );
L_tmp = L_shr( L_tmp, 12 );
- L_tmp = L_mac( L_tmp, coeff[0], g2_pitch );
- L_tmp = L_mac( L_tmp, coeff[1], g_pitch );
- L_tmp = L_mac( L_tmp, coeff[2], g2_code );
- L_tmp = L_mac( L_tmp, coeff[3], g_code );
- L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod );
+ L_tmp = L_mac( L_tmp, coeff[0], g2_pitch ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[1], g_pitch ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[2], g2_code ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[3], g_code ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */
#ifdef BASOP_NOGLOB
L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow );
@@ -3292,13 +3334,13 @@ void gain_enc_amr_wb_fx(
* update table of past quantized energies
*----------------------------------------------------------------*/
- past_qua_en[3] = past_qua_en[2];
+ past_qua_en[3] = past_qua_en[2]; // Q10
move16();
- past_qua_en[2] = past_qua_en[1];
+ past_qua_en[2] = past_qua_en[1]; // Q10
move16();
- past_qua_en[1] = past_qua_en[0];
+ past_qua_en[1] = past_qua_en[0]; // Q10
move16();
- past_qua_en[0] = qua_ener;
+ past_qua_en[0] = qua_ener; // Q10
move16();
@@ -3306,7 +3348,7 @@ void gain_enc_amr_wb_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
push_indice_fx( hBstr, IND_GAIN, index, nBits );
diff --git a/lib_enc/gaus_enc.c b/lib_enc/gaus_enc.c
deleted file mode 100644
index d441f6ead49ddcb3a6a1ffab0962633db8157cd0..0000000000000000000000000000000000000000
--- a/lib_enc/gaus_enc.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c
index 9b91bd505c9273da79cb65a2f25c626463fc1f98..1f91a5d95c4936688f898ecefaf3d362d5259b08 100644
--- a/lib_enc/gaus_enc_fx.c
+++ b/lib_enc/gaus_enc_fx.c
@@ -28,6 +28,8 @@ static Word16 cod_2pos_fx( const Word16 ind1, const Word16 ind2, const Word16 si
static void gauss2v_fx( BSTR_ENC_HANDLE hBstr, const Word16 h[], const Word16 xn[], const Word16 dn[], Word16 code[], Word16 y1[], Word32 *gain, const Word16 lg, const Word16 shift, const Word16 Q_new, const Word16 nb_bits );
+static void gauss2v_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 h[], const Word16 xn[], const Word16 dn[], Word16 code[], Word16 y1[], Word32 *gain, const Word16 lg, const Word16 shift, const Word16 Q_new, const Word16 nb_bits );
+
/*-------------------------------------------------------------------*
* Gaus_encode
*
@@ -39,22 +41,22 @@ static void gauss2v_fx( BSTR_ENC_HANDLE hBstr, const Word16 h[], const Word16 xn
*-------------------------------------------------------------------*/
Word16 gaus_encode_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *h1, /* i : weighted filter input response */
- const Word16 *xn, /* i : target vector */
- Word16 *exc, /* o : pointer to excitation signal frame */
- Word16 *mem_w0, /* o : weighting filter denominator memory */
- Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm */
- Word16 *tilt_code, /* o : synthesis excitation spectrum tilt */
- Word16 *code, /* o : algebraic excitation Q9 */
- Word32 *gain_code, /* o : Code gain. Q16 */
- Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9 */
- Word16 *gain_inov, /* o : innovation gain Q12 */
- Word16 *voice_fac, /* o : voicing factor Q15 */
- Word16 *gain_pit, /* o : adaptive excitation gain Q14 */
- const Word16 Q_new, /* i : scaling factor */
- const Word16 shift, /* i : scaling factor */
- Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16 */
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *h1, /* i : weighted filter input response Q14*/
+ const Word16 *xn, /* i : target vector Q12*/
+ Word16 *exc, /* o : pointer to excitation signal frame Q_new*/
+ Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/
+ Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/
+ Word16 *code, /* o : algebraic excitation Q9*/
+ Word32 *gain_code, /* o : Code gain. Q16*/
+ Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/
+ Word16 *gain_inov, /* o : innovation gain Q12*/
+ Word16 *voice_fac, /* o : voicing factor Q15*/
+ Word16 *gain_pit, /* o : adaptive excitation gain Q14*/
+ const Word16 Q_new, /* i : scaling factor */
+ const Word16 shift, /* i : scaling factor */
+ Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/
)
{
Word16 nb_bits, idx;
@@ -64,6 +66,7 @@ Word16 gaus_encode_fx(
Word16 exp, tmp, tmp_idx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
@@ -74,7 +77,7 @@ Word16 gaus_encode_fx(
corr_xh_fx( xn, dn, h1 );
tmp_idx = shr( i_subfr, 6 );
- nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx];
+ nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx]; /* Q0 */
move16();
gauss2v_fx( st_fx->hBstr, h1, xn, dn, code, y2, gain_code, L_SUBFR, shift, Q_new, shr( nb_bits, 1 ) );
@@ -90,10 +93,10 @@ Word16 gaus_encode_fx(
Ltmp = Isqrt_lc( Ltmp, &exp_code );
*gain_inov = extract_h( L_shl( Ltmp, sub( exp_code, 3 ) ) ); /* g_code_inov in Q12 */
- nb_bits = st_fx->acelp_cfg.gains_mode[tmp_idx];
+ nb_bits = st_fx->acelp_cfg.gains_mode[tmp_idx]; /* Q0 */
move16();
/* low bound = -30; stepSize = 1.71875; inv_stepSize = 0.5818181 */
- idx = gain_enc_gaus_fx( gain_code, nb_bits, -7680, 28160, 19065 );
+ idx = gain_enc_gaus_fx( gain_code, nb_bits, -7680, 28160, 19065 ); /* Q0 */
push_indice_fx( st_fx->hBstr, IND_GAIN, idx, nb_bits );
/*----------------------------------------------------------------*
@@ -106,20 +109,21 @@ Word16 gaus_encode_fx(
#endif /* BASOP_NOGLOB */
FOR( i = 0; i < L_SUBFR; i++ )
{
- exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) );
+ exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) ); /* Q_new */
}
/*----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
*----------------------------------------------------------------*/
- Ltmp = L_mult( gcode, y2[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
+ Ltmp = L_mult( gcode, y2[L_SUBFR - 1] ); /* Q_new + 10 */
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); /* Q_new + 15 + shift */
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 );
+ Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 ); /* Q_new + 15 + shift */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- *mem_w0 = round_fx_sat( Ltmp );
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 16 */
+ *mem_w0 = round_fx_sat( Ltmp ); /* Q_new */
+ move16();
#else
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
*mem_w0 = round_fx( Ltmp );
@@ -128,14 +132,14 @@ Word16 gaus_encode_fx(
*gain_pit = 0;
*tilt_code = 0;
- move16(); /* purely unvoiced */
- *voice_fac = -32768;
- move16(); /* purely unvoiced */
+ move16(); /* purely unvoiced */
+ *voice_fac = -32768; /* -1 in Q31 */
+ move16(); /* purely unvoiced */
exp = sub( norm_s( *gain_inov ), 1 );
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); /* Q16 */
move16();
return ( L_SUBFR << 6 );
@@ -143,31 +147,33 @@ Word16 gaus_encode_fx(
Word16 gaus_encode_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *h1, /* i : weighted filter input response */
- const Word16 *xn, /* i : target vector */
- Word16 *exc, /* o : pointer to excitation signal frame */
- Word16 *mem_w0, /* o : weighting filter denominator memory */
- Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm */
- Word16 *tilt_code, /* o : synthesis excitation spectrum tilt */
- Word16 *code, /* o : algebraic excitation Q9 */
- Word32 *gain_code, /* o : Code gain. Q16 */
- Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9 */
- Word16 *gain_inov, /* o : innovation gain Q12 */
- Word16 *voice_fac, /* o : voicing factor Q15 */
- Word16 *gain_pit, /* o : adaptive excitation gain Q14 */
- const Word16 Q_new, /* i : scaling factor */
- const Word16 shift, /* i : scaling factor */
- Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16 */
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *h1, /* i : weighted filter input response Q14*/
+ const Word16 *xn, /* i : target vector Q12*/
+ Word16 *exc, /* o : pointer to excitation signal frame Q_new*/
+ Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/
+ Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/
+ Word16 *code, /* o : algebraic excitation Q9*/
+ Word32 *gain_code, /* o : Code gain. Q16*/
+ Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/
+ Word16 *gain_inov, /* o : innovation gain Q12*/
+ Word16 *voice_fac, /* o : voicing factor Q15*/
+ Word16 *gain_pit, /* o : adaptive excitation gain Q14*/
+ const Word16 Q_new, /* i : scaling factor */
+ const Word16 shift, /* i : scaling factor */
+ Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/
)
{
Word16 nb_bits, idx;
Word16 i = 0;
+ move16();
Word32 Ltmp;
Word16 dn[L_SUBFR], exp_code, gcode; /* Correlation between xn and h1 */
Word16 exp, tmp, tmp_idx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
@@ -178,10 +184,10 @@ Word16 gaus_encode_ivas_fx(
corr_xh_fx( xn, dn, h1 );
tmp_idx = shr( i_subfr, 6 );
- nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx];
+ nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx]; /* Q0 */
move16();
- gauss2v_fx( st_fx->hBstr, h1, xn, dn, code, y2, gain_code, L_SUBFR, shift, Q_new, shr( nb_bits, 1 ) );
+ gauss2v_ivas_fx( st_fx->hBstr, h1, xn, dn, code, y2, gain_code, L_SUBFR, shift, Q_new, shr( nb_bits, 1 ) );
/*----------------------------------------------------------------*
* Encode gaussian gain
@@ -194,10 +200,10 @@ Word16 gaus_encode_ivas_fx(
Ltmp = Isqrt_lc( Ltmp, &exp_code );
*gain_inov = extract_h( L_shl( Ltmp, sub( exp_code, 3 ) ) ); /* g_code_inov in Q12 */
- nb_bits = st_fx->acelp_cfg.gains_mode[tmp_idx];
+ nb_bits = st_fx->acelp_cfg.gains_mode[tmp_idx]; /* Q0 */
move16();
/* low bound = -30; stepSize = 1.71875; inv_stepSize = 0.5818181 */
- idx = gain_enc_gaus_fx( gain_code, nb_bits, -7680, 28160, 19065 );
+ idx = gain_enc_gaus_fx( gain_code, nb_bits, -7680, 28160, 19065 ); /* Q0 */
push_indice( st_fx->hBstr, IND_GAIN, idx, nb_bits );
/*----------------------------------------------------------------*
@@ -210,20 +216,21 @@ Word16 gaus_encode_ivas_fx(
#endif /* BASOP_NOGLOB */
FOR( i = 0; i < L_SUBFR; i++ )
{
- exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) );
+ exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) ); /* Q_new */
}
/*----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
*----------------------------------------------------------------*/
- Ltmp = L_mult( gcode, y2[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
+ Ltmp = L_mult( gcode, y2[L_SUBFR - 1] ); /* Q_new + 10 */
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); /* Q_new + 15 + shift */
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 );
+ Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 ); /* Q_new + 15 + shift */
#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- *mem_w0 = round_fx_sat( Ltmp );
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 16 */
+ *mem_w0 = round_fx_sat( Ltmp ); /* Q_new */
+ move16();
#else
Ltmp = L_shl( Ltmp, sub( 1, shift ) );
*mem_w0 = round_fx( Ltmp );
@@ -232,14 +239,14 @@ Word16 gaus_encode_ivas_fx(
*gain_pit = 0;
*tilt_code = 0;
- move16(); /* purely unvoiced */
- *voice_fac = -32768;
- move16(); /* purely unvoiced */
+ move16(); /* purely unvoiced */
+ *voice_fac = -32768; /* -1 in Q15 */
+ move16(); /* purely unvoiced */
exp = sub( norm_s( *gain_inov ), 1 );
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); /* Q16 */
move16();
return ( L_SUBFR << 6 );
@@ -253,6 +260,497 @@ Word16 gaus_encode_ivas_fx(
* One Gaussian vector of 192 values vectors delayed by 2
*-------------------------------------------------------------------*/
void gauss2v_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
+ const Word16 h[], /* i : weighted LP filter impulse response Q15 */
+ const Word16 xn[], /* i : target signal Q12 */
+ const Word16 dn[], /* i : backward filtered target Q12 */
+ Word16 code[], /* o : gaussian excitation Q9 */
+ Word16 y1[], /* o : zero-memory filtered gauss. excitation Q8 */
+ Word32 *gain, /* o : excitation gain. 32-bit number in Q16 */
+ const Word16 lg, /* i : subframe size Q0 */
+ const Word16 shift, /* i : Scaling factor Q0 */
+ const Word16 Q_new, /* i : Scaling factor Q0 */
+ const Word16 nb_bits /* i : nb ob bits per track (max 6) Q0 */
+)
+{
+ Word16 i, j, ind1, ind2;
+ Word16 nvec, step;
+ Word32 cor, cora, dotprod;
+ Word16 enerw;
+ Word32 eneri, cor2;
+ Word32 enerw32, cor2w32;
+ Word16 *cpt1;
+ Word16 *pt1, *pt2;
+ Word32 max_val[NMAX + 1];
+ Word16 *pos[NMAX + 1];
+ Word32 sign[NMAX + 1];
+ Word32 ener[NMAX + 1], corr[NMAX + 1], ener1;
+ Word16 dico2[L_SUBFR * NMAX];
+ Word16 exp_num;
+ Word16 exp_den;
+ Word16 Num;
+ Word16 Den;
+ Word32 GainPortion1;
+ Word32 GainPortion2;
+ Word32 cor_abs;
+ Word16 cor_neg;
+ Word16 div_result;
+ Word32 ener_sqrt;
+ Word32 Portion;
+ Word16 sign1, sign2;
+ Word16 enerw_norm, enerw_mantissa;
+ Word16 cor2w_norm, cor2w_mantissa;
+ Word16 eneri_norm, eneri_mantissa;
+ Word16 cor2_norm, cor2_mantissa;
+ Word16 difference_norm;
+ Word32 cor32; /* 32-bit intermediate value*/
+ Word16 hi1, lo1;
+ Word16 update_best;
+ Word16 idx;
+ Word32 Lc0, Lc1, Lnum, Lden;
+ Word16 gxx, gcc, index_delta, delta, m_sign, inv_delta;
+ Word16 hg[190], Gaus_dico2[190];
+ Word16 shiftP3;
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+ move32();
+#endif
+
+ /*----------------------------------------------------------------*
+ * Encode the tilt of gaussian excitation
+ *----------------------------------------------------------------*/
+
+ /* Compute spectral tilt of target */
+ Lc0 = L_mult( xn[1], xn[1] ); /* Q25 */
+ Lc1 = L_mult( xn[1], xn[0] ); /* Q25 */
+ FOR( i = 2; i < L_SUBFR; i++ )
+ {
+ /* fc0 += xn[i]*xn[i] */
+ /* fc1 += xn[i]*xn[i-1] */
+#ifdef BASOP_NOGLOB
+ Lc0 = L_mac_sat( Lc0, xn[i], xn[i] ); /* Q25 */
+ Lc1 = L_mac_sat( Lc1, xn[i], xn[i - 1] ); /* Q25 */
+#else
+ Lc0 = L_mac( Lc0, xn[i], xn[i] );
+ Lc1 = L_mac( Lc1, xn[i], xn[i - 1] );
+#endif
+ }
+ /* fgxx = fc1/fc0 */
+ exp_num = sub( norm_l( Lc1 ), 1 );
+ Num = extract_h( L_shl( Lc1, exp_num ) );
+ m_sign = s_or( shr( Num, 16 ), 1 ); /* Remove sign */
+ Num = abs_s( Num );
+ Lc0 = L_max( Lc0, 1 );
+ exp_den = norm_l( Lc0 );
+ Den = extract_h( L_shl( Lc0, exp_den ) ); /* Q9 + exp_den */
+ gxx = shr( div_s( Num, Den ), sub( exp_num, sub( exp_den, 2 ) ) ); /* Q13 */
+ gxx = i_mult2( gxx, m_sign ); /* Apply sign */
+
+ set16_fx( hg, 0, 190 ); /* Compute spectral tilt of filtered codebook */
+ Copy( h, hg, L_SUBFR ); // Q15
+ conv_fx( gaus_dico_fx, hg, Gaus_dico2, 190 ); // Q12
+
+ Lc0 = L_mult( Gaus_dico2[1], Gaus_dico2[1] ); /* Q25 */
+ Lc1 = L_mult( Gaus_dico2[1], Gaus_dico2[0] ); /* Q25 */
+ FOR( i = 2; i < 190; i++ )
+ {
+ /* fc0 += fgaus_dico2[i]*fgaus_dico2[i] */
+ /* fc1 += fgaus_dico2[i]*fgaus_dico2[i-1] */
+ Lc0 = L_mac( Lc0, Gaus_dico2[i], Gaus_dico2[i] ); /* Q25 */
+ Lc1 = L_mac( Lc1, Gaus_dico2[i], Gaus_dico2[i - 1] ); /* Q25 */
+ }
+
+ /* fgcc = fc1/fc0 */
+
+ exp_num = sub( norm_l( Lc1 ), 1 );
+ Num = extract_h( L_shl( Lc1, exp_num ) );
+ m_sign = s_or( shr( Num, 16 ), 1 ); /* Remove sign */
+ Num = abs_s( Num );
+
+ Lc0 = L_max( Lc0, 1 );
+ exp_den = norm_l( Lc0 );
+ Den = extract_h( L_shl( Lc0, exp_den ) );
+ gcc = shr( div_s( Num, Den ), sub( exp_num, sub( exp_den, 2 ) ) ); /* Q13 */
+ gcc = i_mult2( gcc, m_sign ); /* Apply sign */
+
+ /* fdelta = (1-fgcc*fgxx) / (2*fgcc+fgxx) Compute and quantize spectral tilt modification factor */
+ Lnum = L_sub( 134217728L, L_mult( gcc, gxx ) ); /* Q30 */
+ Lden = L_mac( L_mult( gxx, 8192 ), gcc, 16384 ); /* Q30 */
+
+ exp_num = sub( norm_l( Lnum ), 1 );
+ Num = extract_h( L_shl( Lnum, exp_num ) ); /* Q14 + exp_den */
+ m_sign = s_or( shr( Num, 16 ), 1 ); /* Remove sign */
+ Num = abs_s( Num );
+
+ Lden = L_max( Lden, 1 );
+ exp_den = norm_l( Lden );
+ Den = extract_h( L_shl( Lden, exp_den ) );
+
+#ifdef BASOP_NOGLOB
+ delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */
+#else /* BASOP_NOGLOB */
+ delta = shr( div_s( Num, Den ), sub( exp_num, exp_den ) ); /* Q15 */
+#endif
+ delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/
+ /* index_delta = (short)(FAC_DELTA * fdelta) */
+ index_delta = shr( delta, SFAC_DELTA );
+
+ /* index_delta [0,7] */
+ index_delta = s_max( index_delta, 0 );
+ index_delta = s_min( index_delta, 7 );
+
+ /* fdelta = STEP_DELTA * (float)index_delta */
+ delta = shl( index_delta, 11 ); /* delta in Q15 */
+
+ IF( delta > 0 ) /* Adapt spectral tilt of initial codebook */
+ {
+ /* Computation of 1 / (1+fdelta*fdelta) */
+ inv_delta = inv_delta_tab[sub( index_delta, 1 )];
+ move16(); /* Q15 */
+
+ /* fgaus_dico2[0] = gaus_dico[0] */
+ Gaus_dico2[0] = gaus_dico_fx[0]; /* Q12 */
+ move16();
+ FOR( i = 1; i < 190; i++ )
+ {
+ /* fgaus_dico2[i] = (gaus_dico[i] - fdelta*gaus_dico[i-1]) / (1 + fdelta*fdelta) */
+ Lnum = L_msu( L_deposit_h( gaus_dico_fx[i] ), delta, gaus_dico_fx[i - 1] );
+ Gaus_dico2[i] = round_fx( Mpy_32_16_1( Lnum, inv_delta ) );
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < 190; i++ )
+ {
+ /* fgaus_dico2[i] = gaus_dico[i] */
+ Gaus_dico2[i] = gaus_dico_fx[i]; /* Q12 */
+ move16();
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Initializations
+ *----------------------------------------------------------------*/
+
+ ind1 = 0;
+ move16();
+ ind2 = 0;
+ move16();
+
+ nvec = shl( 1, nb_bits );
+ step = shr( 0x80, nb_bits );
+
+ /*----------------------------------------------------------------*
+ * dot product between dn and gaussian codevectors,
+ * keep NMAX best vectors
+ *----------------------------------------------------------------*/
+
+ set32_fx( max_val, 0, NMAX + 1 );
+ set32_fx( sign, 0, NMAX + 1 );
+
+ FOR( i = 0; i < NMAX + 1; i++ )
+ {
+ pos[i] = (Word16 *) Gaus_dico2;
+ }
+
+ cpt1 = Gaus_dico2;
+ move16();
+
+ FOR( i = 0; i < nvec; i++ )
+ {
+ /* Dot product without normalization, because values are compared with each other afterwards. */
+ cor = Dot_product( cpt1, dn, lg ); /* Q12 * Q12 * length of 64 + 1 left shift ==> Q31*/
+ cora = L_abs( cor );
+ j = NMAX - 1;
+ move16();
+
+ DO
+ {
+ IF( GE_32( cora, max_val[j] ) )
+ {
+ max_val[j + 1] = max_val[j];
+ move32(); /*Q31*/
+ pos[j + 1] = pos[j];
+ move16(); /*Pointer*/
+ sign[j + 1] = sign[j];
+ move32(); /*Q31*/
+ max_val[j] = cora;
+ move32(); /*Q31*/
+ pos[j] = cpt1;
+ move16(); /*Pointer*/
+ sign[j] = cor;
+ move32(); /*Q31*/
+ }
+ j--;
+ }
+ WHILE( j >= 0 );
+ cpt1 += step;
+ }
+
+ /*----------------------------------------------------------------*
+ * filter selected vectors
+ * put sign
+ * compute energy
+ *----------------------------------------------------------------*/
+
+ pt1 = dico2;
+ move16();
+ FOR( i = 0; i < NMAX; i++ )
+ {
+ /* Input vector (pos) Q12, filter coefs in Q15, result in same format as input vector (Q12) */
+ conv_fx( pos[i], h, pt1, lg );
+
+ /* put sign and compute energy */
+ IF( sign[i] < 0 )
+ {
+ FOR( j = 0; j < lg; j++ )
+ {
+ pt1[j] = negate( pt1[j] );
+ move16(); /*Store into dico2*/
+ }
+ }
+ ener[i] = Dot_product( pt1, pt1, lg ); /* pt1 points to filtered vector in dico2, in Q12 */
+ move32(); /* Result is for Q12 * Q12 with length of 64 (6 bits) + 1 left shift => Q31 */
+ corr[i] = Dot_product( pt1, xn, lg ); /* must be equal to sign[i] !! */
+ move32(); /* pt1 points into dico2, in Q12. xn is in Q12 */
+ /* Result is for Q12 * Q12 with length of 64 (6 bits) + 1 left shift => Q31 */
+ pt1 += L_SUBFR;
+ }
+
+ /*------------------------------------------------------------------------*
+ * try all combinations of NMAX best vectors
+ *------------------------------------------------------------------------*/
+
+ pt1 = dico2;
+ move16();
+
+ /* Initial values for search algorithm */
+ enerw32 = L_deposit_h( 0x80 );
+ cor2w32 = L_deposit_l( -2 );
+ enerw_norm = norm_l( enerw32 );
+ cor2w_norm = norm_l( cor2w32 );
+ cor2w_mantissa = round_fx( L_shl( cor2w32, cor2w_norm ) );
+ enerw_mantissa = round_fx( L_shl( enerw32, enerw_norm ) );
+
+ FOR( i = 0; i < NMAX; i++ )
+ {
+ pt2 = pt1;
+ move16();
+ FOR( j = i; j < NMAX; j++ )
+ {
+ cor32 = L_add( corr[i], corr[j] ); /* Q31 */
+
+ dotprod = Dot_product( pt1, pt2, lg ); /* Q12 * Q12 * length of 64 + 1 left shift ==> Q31 */
+
+ /* eneri = round_fx(ener[i]) + round_fx(ener[j]) + 2*round_fx(dotprod) */
+ /* Use ScalingShift to stay aligned with ener[] */
+ eneri = L_shl( dotprod, 1 ); /* One left shift added for factor of 2 */
+ eneri = L_add( ener[i], eneri );
+ eneri = L_add( ener[j], eneri ); /* Q31 */
+
+ lo1 = L_Extract_lc( cor32, &hi1 );
+ cor2 = Sad_32( 0, hi1, lo1 ); /* Square + Add */
+
+ cor2_norm = norm_l( cor2 );
+ eneri_norm = norm_l( eneri );
+#ifdef BASOP_NOGLOB
+ cor2_mantissa = round_fx_o( L_shl_o( cor2, cor2_norm, &Overflow ), &Overflow );
+ eneri_mantissa = round_fx_o( L_shl_o( eneri, eneri_norm, &Overflow ), &Overflow );
+#else
+ cor2_mantissa = round_fx( L_shl( cor2, cor2_norm ) );
+ eneri_mantissa = round_fx( L_shl( eneri, eneri_norm ) );
+#endif
+ difference_norm = sub( add( cor2_norm, enerw_norm ), add( cor2w_norm, eneri_norm ) );
+
+ update_best = 0;
+ move16();
+
+ IF( difference_norm > 0 )
+ {
+ if ( GT_32( L_shr( L_mult( cor2_mantissa, enerw_mantissa ), difference_norm ),
+ L_mult( cor2w_mantissa, eneri_mantissa ) ) )
+ {
+ update_best = 1;
+ move16();
+ }
+ }
+ ELSE
+ {
+ if ( L_msu_sat( L_shl( L_mult( cor2w_mantissa, eneri_mantissa ), difference_norm ), cor2_mantissa, enerw_mantissa ) < 0 ) // Saturation to be revisited
+ {
+ update_best = 1;
+ move16();
+ }
+ }
+ IF( update_best != 0 )
+ {
+ cor2w_mantissa = cor2_mantissa;
+ move16();
+ cor2w_norm = cor2_norm;
+ move16();
+ enerw_mantissa = eneri_mantissa;
+ move16();
+ enerw_norm = eneri_norm;
+ move16();
+ ind1 = i;
+ move16();
+ ind2 = j;
+ move16();
+ }
+ pt2 += L_SUBFR;
+ }
+ pt1 += L_SUBFR;
+ }
+
+ enerw = round_fx( L_shr( L_deposit_h( enerw_mantissa ), enerw_norm ) );
+
+ /*----------------------------------------------------------------*
+ * Compute zero-memory filtered gauss. excitation y
+ *----------------------------------------------------------------*/
+
+ pt1 = dico2 + ind1 * L_SUBFR;
+ move16(); /*Pointer arithmetic*/
+ pt2 = dico2 + ind2 * L_SUBFR;
+ move16();
+
+ shiftP3 = add( shift, 3 );
+ FOR( i = 0; i < lg; i++ )
+ {
+ /* Sum of 2 Q12 values, must give a Q1.8 */
+ y1[i] = shr( add( pt1[i], pt2[i] ), shiftP3 );
+ move16(); /* Compensate for "shift" */
+ }
+
+ /*----------------------------------------------------------------*
+ * signs of vectors
+ *----------------------------------------------------------------*/
+
+ sign1 = ( -32768 );
+ move16();
+ if ( sign[ind1] >= 0 )
+ {
+ sign1 = 32767;
+ move16();
+ }
+
+ sign2 = ( -32768 );
+ move16();
+ if ( sign[ind2] >= 0 )
+ {
+ sign2 = 32767;
+ move16();
+ }
+
+ /*----------------------------------------------------------------*
+ * Compute code
+ *----------------------------------------------------------------*/
+
+ pt1 = pos[ind1];
+ move16(); /* Points to gaussian vector (gaus_dico_fx) in Q12 */
+ pt2 = pos[ind2];
+ move16(); /* Points to gaussian vector (gaus_dico_fx) in Q12 */
+
+ /* sign[ind1] and sign[ind2] */
+ FOR( i = 0; i < lg; i++ )
+ {
+ /* code[i]=(pt1[i]*sign1 + pt2[i]*sign2) /8 */
+ /* Division by 8 (shift by 3) is for scaling (Q12 to Q0.9 output) */
+ code[i] = shr( add( mult( pt1[i], sign1 ), mult( pt2[i], sign2 ) ), 3 );
+ move16();
+ }
+
+ cor = L_add( corr[ind1], corr[ind2] );
+
+ /*----------------------------------------------------------------*
+ * Compute index
+ *----------------------------------------------------------------*/
+
+ i = (Word16) ( ( pos[ind1] - Gaus_dico2 ) / step ); /* Division by step can be replaced by shift. Pointer arithmetic */
+ j = (Word16) ( ( pos[ind2] - Gaus_dico2 ) / step ); /* Division by step can be replaced by shift. Pointer arithmetic */
+
+ idx = cod_2pos_fx( i, j, sign1, sign2, nvec ); /* Q0 */
+ move16();
+
+ push_indice_fx( hBstr, IND_GAUS_CDBK_INDEX, idx, 2 * nb_bits + 1 );
+ push_indice_fx( hBstr, IND_TILT_FACTOR, index_delta, 3 );
+
+ /*----------------------------------------------------------------*
+ * Find quantized gain
+ *----------------------------------------------------------------*/
+
+ /* Divide cor/enerw: intermediate result stored into GainPortion1 */
+ cor_neg = 0;
+ move16();
+ if ( cor < 0 ) /* Make Num positive. */
+ {
+ cor_neg = 1;
+ move16();
+ }
+ cor_abs = L_abs( cor );
+
+ exp_num = sub( norm_l( cor_abs ), 1 );
+ exp_den = norm_s( enerw );
+ Num = round_fx( L_shl( cor_abs, exp_num ) );
+ Den = shl( enerw, exp_den );
+
+ GainPortion1 = L_deposit_l( 0 ); /* Unexpected division by zero. Eliminate this gain contribution */
+ IF( Den != 0 ) /* Protection against division by zero */
+ {
+ div_result = div_s( Num, Den ); /* Q15 */
+ IF( cor_neg != 0 )
+ {
+ div_result = negate( div_result ); /* Retrieve sign */
+ }
+ /* Re-scale to compensate for normalization*/
+ GainPortion1 = L_shr( L_deposit_l( div_result ), sub( exp_num, exp_den ) );
+ }
+
+ ener1 = Dot_product( xn, xn, lg ); /* Q12 * Q12 * length of 64 + 1 left shift ==> Q31 */
+
+ exp_num = sub( norm_s( enerw ), 1 );
+ exp_den = norm_l( ener1 );
+ Num = shl( enerw, exp_num );
+#ifdef BASOP_NOGLOB
+ Den = round_fx_sat( L_shl_sat( ener1, exp_den ) );
+#else
+ Den = round_fx( L_shl( ener1, exp_den ) );
+#endif
+ GainPortion2 = L_deposit_l( 0 ); /* Unexpected division by zero. Eliminate this gain contribution */
+ IF( Den != 0 ) /* Protection against division by zero */
+ {
+ div_result = div_s( Num, Den ); /* Q15 */
+
+ /* Re-scale to compensate for normalization*/
+#ifdef BASOP_NOGLOB
+ GainPortion2 = L_shr_sat( L_deposit_l( div_result ), sub( exp_num, exp_den ) );
+#else
+ GainPortion2 = L_shr( L_deposit_l( div_result ), sub( exp_num, exp_den ) );
+#endif
+ }
+
+#ifdef BASOP_NOGLOB
+ ener_sqrt = Isqrt( L_shl_sat( GainPortion2, 1 ) ); /* Make value a Q16 prior to division (align on power of 4) */
+#else
+ ener_sqrt = Isqrt( L_shl( GainPortion2, 1 ) ); /* Make value a Q16 prior to division (align on power of 4) */
+#endif
+ ener_sqrt = L_shr( ener_sqrt, 8 ); /* Left-shift Q23 result to make a Q15 result */
+
+ Portion = Mult_32_16( GainPortion1, 19661 ); /* Performs GainPortion1*.6 */
+ Portion = Madd_32_16( Portion, ener_sqrt, 13107 ); /* Performs ener_sqrt*.4 */
+
+ /* Gain must be output in a 32-bit variable as a Q16 */
+ /* Compensate for Q_new */
+#ifdef BASOP_NOGLOB
+ *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); /* Q16 */
+#else
+ *gain = L_shl( Portion, sub( 13, Q_new ) );
+#endif
+ move32();
+
+ return;
+}
+
+void gauss2v_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
const Word16 h[], /* i : weighted LP filter impulse response Q15 */
const Word16 xn[], /* i : target signal Q12 */
@@ -306,6 +804,7 @@ void gauss2v_fx(
Word16 shiftP3;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
@@ -402,11 +901,13 @@ void gauss2v_fx(
/* fgaus_dico2[0] = gaus_dico[0] */
Gaus_dico2[0] = gaus_dico_fx[0];
+ move16();
FOR( i = 1; i < 190; i++ )
{
/* fgaus_dico2[i] = (gaus_dico[i] - fdelta*gaus_dico[i-1]) / (1 + fdelta*fdelta) */
Lnum = L_msu( L_deposit_h( gaus_dico_fx[i] ), delta, gaus_dico_fx[i - 1] );
Gaus_dico2[i] = round_fx( Mpy_32_16_1( Lnum, inv_delta ) );
+ move16();
}
}
ELSE
@@ -662,8 +1163,8 @@ void gauss2v_fx(
idx = cod_2pos_fx( i, j, sign1, sign2, nvec );
move16();
- push_indice_fx( hBstr, IND_GAUS_CDBK_INDEX, idx, 2 * nb_bits + 1 );
- push_indice_fx( hBstr, IND_TILT_FACTOR, index_delta, 3 );
+ push_indice( hBstr, IND_GAUS_CDBK_INDEX, idx, 2 * nb_bits + 1 );
+ push_indice( hBstr, IND_TILT_FACTOR, index_delta, 3 );
/*----------------------------------------------------------------*
* Find quantized gain
@@ -741,16 +1242,15 @@ void gauss2v_fx(
return;
}
-
/*---------------------------------------------------------------------*
* Put selected codevector positions and signs into quantization index
*---------------------------------------------------------------------*/
-static Word16 cod_2pos_fx( /* o : codebook quantization index */
- const Word16 ind1, /* i : index of 1st gaussian vector */
- const Word16 ind2, /* i : index of 2nd gaussian vector */
- const Word16 sign1, /* i : sign of 1st gaussian vector */
- const Word16 sign2, /* i : sign of 2nd gaussian vector */
- const Word16 n /* i : nb. of codebook vectors */
+static Word16 cod_2pos_fx( /* o : codebook quantization index */
+ const Word16 ind1, /* i : index of 1st gaussian vector Q0*/
+ const Word16 ind2, /* i : index of 2nd gaussian vector Q0*/
+ const Word16 sign1, /* i : sign of 1st gaussian vector Qx*/
+ const Word16 sign2, /* i : sign of 2nd gaussian vector Qx*/
+ const Word16 n /* i : nb. of codebook vectors Q0*/
)
{
Word16 i1, i2, index, s1, s2;
@@ -774,16 +1274,16 @@ static Word16 cod_2pos_fx( /* o : codebook quantization in
{
IF( LE_16( ind1, ind2 ) )
{
- i1 = ind1;
+ i1 = ind1; /* Q0 */
move16();
- i2 = ind2;
+ i2 = ind2; /* Q0 */
move16();
}
ELSE
{
- i1 = ind2;
+ i1 = ind2; /* Q0 */
move16();
- i2 = ind1;
+ i2 = ind1; /* Q0 */
move16();
}
}
@@ -791,16 +1291,16 @@ static Word16 cod_2pos_fx( /* o : codebook quantization in
{
IF( GT_16( ind1, ind2 ) )
{
- i1 = ind1;
+ i1 = ind1; /* Q0 */
move16();
- i2 = ind2;
+ i2 = ind2; /* Q0 */
move16();
}
ELSE
{
- i1 = ind2;
+ i1 = ind2; /* Q0 */
move16();
- i2 = ind1;
+ i2 = ind1; /* Q0 */
move16();
s1 = s2;
move16();
diff --git a/lib_enc/gp_clip.c b/lib_enc/gp_clip.c
deleted file mode 100644
index 7dd2c1f21169fdc182f70f2f4e86aa4bb3106165..0000000000000000000000000000000000000000
--- a/lib_enc/gp_clip.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "prot.h"
-#include "cnst.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c
index bf532a085cf9fc3164f867f3c3e3db1a1de82d13..4ca86a09cbd191637cf4340ec52a0a8bb5dd75d2 100644
--- a/lib_enc/gp_clip_fx.c
+++ b/lib_enc/gp_clip_fx.c
@@ -68,7 +68,7 @@
* Pitch Gain clipping initializations
*-------------------------------------------------------------------*/
void init_gp_clip_fx(
- Word16 mem[] /* o : memory of gain of pitch clipping algorithm */
+ Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
)
{
mem[0] = DIST_ISF_MAX;
@@ -98,13 +98,13 @@ void init_gp_clip_fx(
*-------------------------------------------------------------------*/
Word16 gp_clip_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 *voicing, /* i : normalized correlations (from OL pitch) */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : type of coder */
- const Word16 xn[], /* i : target vector */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ const Word16 xn[], /* i : target vector Q_new*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
const Word16 Q_new /* i : scaling factor */
)
{
@@ -116,16 +116,16 @@ Word16 gp_clip_fx(
Word16 thres;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
clip = 0;
move16();
test();
test();
- IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || GT_16( element_mode, EVS_MONO ) )
+ IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || element_mode > EVS_MONO )
{
- thres = add( 14746, mult( 1638, extract_l( L_mult( mem[0], (Word16) ( 16384 / DIST_ISF_MAX_IO ) ) ) ) ); /* clipping is activated when filtered pitch gain > threshold (0.94 to 1 in Q14) */
- test();
+ thres = add( 14746 /* 0.9 in Q14 */, mult( 1638 /* 0.1 in Q14 */, extract_l( L_mult( mem[0], (Word16) ( 16384 / DIST_ISF_MAX_IO ) ) ) ) ); /* clipping is activated when filtered pitch gain > threshold (0.94 to 1 in Q14) */
if ( GT_16( mem[1], thres ) )
{
clip = 1;
@@ -160,7 +160,7 @@ Word16 gp_clip_fx(
e_ener = norm_l( ener );
f_ener = Log2_norm_lc( L_shl( ener, e_ener ) );
e_ener = sub( 30, e_ener );
- IF( GT_16( element_mode, EVS_MONO ) )
+ IF( element_mode > EVS_MONO )
{
e_ener = sub( e_ener, Q_new * 2 + 1 );
}
@@ -168,20 +168,20 @@ Word16 gp_clip_fx(
{
e_ener = sub( e_ener, Q_new );
}
- ener = Mpy_32_16( e_ener, f_ener, LG10 );
- wener = round_fx( L_shl( ener, 10 ) );
+ ener = Mpy_32_16( e_ener, f_ener, LG10 ); /* Q14 */
+ wener = round_fx( L_shl( ener, 10 ) ); /* Q8 */
test();
- if ( LT_16( wener, sub( mem[2], 1536 ) ) && GT_16( mem[1], 16384 ) )
+ if ( LT_16( wener, sub( mem[2], 1536 /* 6.0f in Q8 */ ) ) && GT_16( mem[1], 16384 /* 1 in Q14 */ ) )
{
clip = 1;
move16();
}
- mem[2] = wener;
+ mem[2] = wener; /* Q8 */
move16();
- L_tmp = L_mult( ALPHA1, mem[4] );
+ L_tmp = L_mult( ALPHA1, mem[4] ); /* Q30 */
test();
test();
@@ -189,19 +189,19 @@ Word16 gp_clip_fx(
{
/* mem[4] = (1-ALPHA1) + ALPHA1 * mem[4], if branch taken */
/* mem[4] = ALPHA1 * mem[4], otherwise */
- L_tmp = L_add( L_tmp, 32768L * ( 32768 - ALPHA1 ) );
+ L_tmp = L_add( L_tmp, 32768L * ( 32768 - ALPHA1 ) ); /* Q30 */
}
- mem[4] = round_fx( L_tmp );
+ mem[4] = round_fx( L_tmp ); /* Q14 */
L_tmp = L_mult( ALPHA4, mem[5] );
- if ( i_subfr == 0 )
+ IF( i_subfr == 0 )
{
/* mem[5] = (1-ALPHA4) * voicing[0] + ALPHA4 * mem[5] */
mem[5] = mac_r( L_tmp, ( 32768 - ALPHA4 ) / 2, voicing[0] );
move16(); /* /2 to put voicing from Q15 to Q14 */
}
- if ( EQ_16( i_subfr, 2 * L_SUBFR ) )
+ IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
{
/* mem[5] = (1-ALPHA4) * voicing[1] + ALPHA4 * mem[5] */
mem[5] = mac_r( L_tmp, ( 32768 - ALPHA4 ) / 2, voicing[1] );
@@ -219,7 +219,7 @@ Word16 gp_clip_fx(
}
ELSE
{
- mem[3] = add( mem[3], 1 );
+ mem[3] = add( mem[3], 1 ); /* Q0 */
move16();
}
@@ -233,16 +233,16 @@ Word16 gp_clip_fx(
*-------------------------------------------------------------------*/
void gp_clip_test_isf_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 isf[], /* i : isf values (in frequency domain) */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/
)
{
Word16 i, dist, dist_min, m;
- dist_min = sub( isf[1], isf[0] );
+ dist_min = sub( isf[1], isf[0] ); /* Q2.56 */
m = M;
move16();
@@ -255,15 +255,15 @@ void gp_clip_test_isf_fx(
move16(); /* ptr init*/
FOR( i = 2; i < m; i++ )
{
- dist = sub( isf[i], isf[i - 1] );
- dist_min = s_min( dist, dist_min );
+ dist = sub( isf[i], isf[i - 1] ); /* Q2.56 */
+ dist_min = s_min( dist, dist_min ); /* Q2.56 */
}
- dist = extract_h( L_mac( L_mult( 26214, mem[0] ), 6554, dist_min ) );
+ dist = extract_h( L_mac( L_mult( 26214 /* 0.8f in Q15 */, mem[0] ), 6554 /* 0.2f in Q15 */, dist_min ) ); /* Q15 */
test();
test();
- IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || GT_16( element_mode, EVS_MONO ) )
+ IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || element_mode > EVS_MONO )
{
dist = s_min( dist, DIST_ISF_MAX_IO );
}
@@ -271,7 +271,7 @@ void gp_clip_test_isf_fx(
{
dist = s_min( dist, DIST_ISF_MAX );
}
- mem[0] = dist;
+ mem[0] = dist; /* Q15 */
move16();
return;
@@ -284,10 +284,10 @@ void gp_clip_test_isf_fx(
*-------------------------------------------------------------------*/
void gp_clip_test_gain_pit_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 gain_pit, /* i : gain of quantized pitch Q14 */
- Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14 */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 gain_pit, /* i : gain of quantized pitch Q14*/
+ Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/
)
{
Word16 gain;
@@ -295,19 +295,19 @@ void gp_clip_test_gain_pit_fx(
test();
test();
- IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || GT_16( element_mode, EVS_MONO ) )
+ IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || element_mode > EVS_MONO )
{
- L_tmp = L_mult( 32113, mem[1] ); /* long term LTP gain average (>250ms) */
- L_tmp = L_mac( L_tmp, 655, gain_pit );
+ L_tmp = L_mult( 32113 /* 0.98 in Q15 */, mem[1] ); /* long term LTP gain average (>250ms) */
+ L_tmp = L_mac( L_tmp, 655 /* 0.02 in Q15 */, gain_pit );
}
ELSE
{
- L_tmp = L_mult( 29491, mem[1] );
- L_tmp = L_mac( L_tmp, 3277, gain_pit );
+ L_tmp = L_mult( 29491 /* 0.9 in Q15 */, mem[1] );
+ L_tmp = L_mac( L_tmp, 3277 /* 0.1 in Q15 */, gain_pit );
}
gain = extract_h( L_tmp );
gain = s_max( gain, GAIN_PIT_MIN );
- mem[1] = gain;
+ mem[1] = gain; /* Q14 */
move16();
return;
@@ -323,10 +323,10 @@ void gp_clip_test_gain_pit_fx(
* prediction (lp_gp > 0.9)
* - target energy drops by 6 dB AND a good pitch prediction (lp_gp>1.0)
*-------------------------------------------------------------------*/
-Word16 Mode2_gp_clip(
+Word16 Mode2_gp_clip_fx(
const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : type of coder */
+ const Word16 i_subfr, /* i : subframe index Q0 */
+ const Word16 coder_type, /* i : type of coder Q0 */
const Word16 xn[], /* i : target vector Q_xn */
Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
/* mem[0]: Q0 */
@@ -335,8 +335,8 @@ Word16 Mode2_gp_clip(
/* mem[3]: Q0 (integer) */
/* mem[4]: Q14 */
/* mem[5]: Q14 */
- const Word16 L_subfr,
- const Word16 Q_xn /* i : scaling factor of vector xn[] */
+ const Word16 L_subfr, /* Q0 */
+ const Word16 Q_xn /* i : scaling factor of vector xn[] */
)
{
Word16 clip, tmp, exp_xn;
@@ -344,6 +344,7 @@ Word16 Mode2_gp_clip(
Word32 wener, Ltmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
move16();
clip = 0;
@@ -393,20 +394,20 @@ Word16 Mode2_gp_clip(
if ( s_or( (Word16) EQ_16( coder_type, GENERIC ), (Word16) EQ_16( coder_type, TRANSITION ) ) )
{
- Ltmp = L_add( Ltmp, ALPHA1_M1 );
+ Ltmp = L_add( Ltmp, ALPHA1_M1 ); /* Q30 */
}
- mem[4] = round_fx( Ltmp );
+ mem[4] = round_fx( Ltmp ); /* Q14 */
Ltmp = Mpy_32_16_1( ALPHA4, mem[5] ); /* mem[5] in Q14 format, Ltmp in Q14 */
IF( i_subfr == 0 )
{
- move16(); /* voicing: Q15 */
- mem[5] = round_fx( L_add( Mpy_32_16_1( ALPHA4_M1, voicing[0] ), Ltmp ) );
+ move16(); /* voicing: Q15 */
+ mem[5] = round_fx( L_add( Mpy_32_16_1( ALPHA4_M1, voicing[0] ), Ltmp ) ); /* Q14 */
}
ELSE IF( EQ_16( i_subfr, shl( L_subfr, 1 ) ) )
{
move16();
- mem[5] = round_fx( L_add( Mpy_32_16_1( ALPHA4_M1, voicing[1] ), Ltmp ) );
+ mem[5] = round_fx( L_add( Mpy_32_16_1( ALPHA4_M1, voicing[1] ), Ltmp ) ); /* Q14 */
}
IF( GT_16( mem[3], WINDOW_SIZE ) )
@@ -421,7 +422,7 @@ Word16 Mode2_gp_clip(
ELSE
{
move16();
- mem[3] = add( mem[3], 1 );
+ mem[3] = add( mem[3], 1 ); /* Q0 */
}
@@ -434,10 +435,10 @@ Word16 Mode2_gp_clip(
* check the minimum distance of LSFs for pitch gain clipping flag
*-------------------------------------------------------------------*/
void gp_clip_test_lsf_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28 */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 m /* i : dimension of lsf */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ const Word16 m /* i : dimension of lsf Q0*/
)
{
Word16 i;
@@ -445,22 +446,22 @@ void gp_clip_test_lsf_fx(
dist_max = DIST_ISF_MAX;
move16();
- if ( GT_16( element_mode, EVS_MONO ) )
+ if ( element_mode > EVS_MONO )
{
dist_max = DIST_ISF_MAX_IO;
move16();
}
- dist_min = sub( lsf[1], lsf[0] );
+ dist_min = sub( lsf[1], lsf[0] ); /* 14Q1*1.28 */
FOR( i = 2; i < m - 1; i++ )
{
- dist = sub( lsf[i], lsf[i - 1] );
+ dist = sub( lsf[i], lsf[i - 1] ); /* 14Q1*1.28 */
dist_min = s_min( dist, dist_min );
}
/*dist = 0.8f*mem[0] + 0.2f*dist_min;*/
- dist = s_min( dist_max, mac_r( L_mult( 26214 /*0.8f Q15*/, mem[0] ), 6554 /*0.2f Q15*/, dist_min ) );
+ dist = s_min( dist_max, mac_r( L_mult( 26214 /*0.8f Q15*/, mem[0] ), 6554 /*0.2f Q15*/, dist_min ) ); /* x2.56 */
- mem[0] = dist;
+ mem[0] = dist; /* x2.56 */
move16();
@@ -468,18 +469,18 @@ void gp_clip_test_lsf_fx(
}
void gp_clip_test_lsf_ivas_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 lsf[], /* i : LSF vector */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/
)
{
Word16 i;
Word16 m;
Word16 dist, dist_min;
- dist_min = sub( lsf[1], lsf[0] );
+ dist_min = sub( lsf[1], lsf[0] ); /* 14Q1*1.28 */
IF( Opt_AMR_WB )
{
@@ -494,12 +495,12 @@ void gp_clip_test_lsf_ivas_fx(
FOR( i = 2; i < m; i++ )
{
- dist = sub( lsf[i], lsf[i - 1] );
+ dist = sub( lsf[i], lsf[i - 1] ); /* 14Q1*1.28 */
dist_min = s_min( dist, dist_min );
}
// dist = 0.8f * mem[0] + 0.2f * dist_min;
- dist = mac_r( L_mult( 26214 /*0.8f Q15*/, mem[0] ), 6554 /*0.2f Q15*/, dist_min );
+ dist = mac_r( L_mult( 26214 /*0.8f Q15*/, mem[0] ), 6554 /*0.2f Q15*/, dist_min ); /* 2.56x */
test();
test();
@@ -517,7 +518,7 @@ void gp_clip_test_lsf_ivas_fx(
move16();
}
- mem[0] = dist;
+ mem[0] = dist; /* 2.56x */
move16();
return;
diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c
index 91701fd7f73a18ba66e3b3a3e4cd3205c7151c67..148ef885e016235ee72ad9d4f24c367bcb3331df 100644
--- a/lib_enc/hq_core_enc.c
+++ b/lib_enc/hq_core_enc.c
@@ -68,7 +68,7 @@ void hq_core_enc_ivas_fx(
Word16 two_frames_buffer[2 * L_FRAME48k];
Word16 tmp;
Word16 Aq_old_fx[M + 1];
- Word16 output_fx[L_FRAME16k];
+ Word16 output_fx[L_FRAME48k];
Word16 Q_audio;
Word16 out_q = 0, old_q = 0;
move16();
@@ -87,7 +87,7 @@ void hq_core_enc_ivas_fx(
set32_fx( wtda_audio_fx32, 0, 2 * L_FRAME48k );
st->Nb_ACELP_frames = 0;
move16();
- set_zero_fx( t_audio_fx, L_FRAME48k );
+ set_zero_fx( t_audio_fx, L_FRAME48k_EXT );
/* set input_frame length */
input_frame = input_frame_orig;
@@ -282,7 +282,7 @@ void hq_core_enc_ivas_fx(
* Transform-domain encoding
*--------------------------------------------------------------------------*/
- scale_sig32( t_audio_fx, L_FRAME48k, sub( Q12, Q_audio ) );
+ scale_sig32( t_audio_fx, L_FRAME48k_EXT, sub( Q12, Q_audio ) );
scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q12, Q_audio ) );
Q_audio = 12;
move16();
@@ -394,7 +394,7 @@ void hq_core_enc_ivas_fx(
{
/* Store LB synthesis in case of switch to ACELP */
Copy( output_fx, st->hLPDmem->old_exc, L_FRAME16k );
- st->hLPDmem->q_lpd_old_exc = 15;
+ st->hLPDmem->q_lpd_old_exc = 0;
move16();
}
pop_wmops();
diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c
index 4d26d0a5c13f1d201ee64a7787f4b51f0d8a8706..faef4c1e0e99888c1480cef1ffcdd8d4ade86135 100644
--- a/lib_enc/hq_core_enc_fx.c
+++ b/lib_enc/hq_core_enc_fx.c
@@ -372,8 +372,12 @@ void HQ_core_enc_init_fx(
#ifdef MSAN_FIX
hHQ_core->crest_lp_fx = HQ_CREST_THRESHOLD_FX;
move32();
+ hHQ_core->crest_lp_q = Q28;
+ move16();
hHQ_core->crest_mod_lp_fx = HQ_CREST_MOD_THRESHOLD_FX;
move32();
+ hHQ_core->crest_mod_lp_q = Q29;
+ move16();
#endif
return;
diff --git a/lib_enc/hq_hr_enc.c b/lib_enc/hq_hr_enc.c
index 07080804eb0063c217028438ad92480e21232fde..c72e682e0e0a75e2190b8f5654bcc390495257ef 100644
--- a/lib_enc/hq_hr_enc.c
+++ b/lib_enc/hq_hr_enc.c
@@ -265,6 +265,7 @@ void hq_hr_enc_ivas_fx(
IF( NE_16( hqswb_clas, HQ_HVQ ) )
{
apply_envelope_enc_ivas_fx( t_audio_q_norm, ynrm, num_sfm, sfm_start, sfm_end, t_audio_q_fx );
+ scale_sig32( t_audio_q_fx, length, sub( Q12, Q_audio ) ); // Q12
}
IF( is_transient )
diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c
index 4fa98f20bfbd8f3c6339e546163407e4005a3762..9ca1cd5fc529e32ae8dd845d85a26bbd4349c4ff 100644
--- a/lib_enc/igf_enc.c
+++ b/lib_enc/igf_enc.c
@@ -184,7 +184,7 @@ static Word16 IGF_getSFM_new_fx(
const Word16 *logSpec, /* i : log of power spectrum */
const Word16 start, /* i : start subband index */
const Word16 stop, /* i : stop subband index */
- Word16 e_ps /*Stores exp related to power spectrum*/
+ Word16 *e_ps /*Stores exp related to power spectrum*/
)
{
Word16 n;
@@ -215,7 +215,7 @@ static Word16 IGF_getSFM_new_fx(
move32();
move16();
num = add( num, n );
- denom = BASOP_Util_Add_Mant32Exp( tmp, e_ps, denom, denom_e, &denom_e );
+ denom = BASOP_Util_Add_Mant32Exp( tmp, e_ps[i], denom, denom_e, &denom_e );
}
numf = BASOP_Util_Divide1616_Scale( num, sub( stop, start ), &numf_e );
@@ -232,8 +232,6 @@ static Word16 IGF_getSFM_new_fx(
return sfm;
}
-
-
/*-------------------------------------------------------------------*
* IGF_getTilt()
*
@@ -340,6 +338,94 @@ static Word32 IGF_getTNR_fx(
return tonalToNoise;
}
+static Word32 IGF_getTNR_ivas_fx(
+ const Word32 *powerSpectrum, /* i : energies */
+ const Word16 start, /* i : start subband index */
+ const Word16 stop, /* i : stop subband index */
+ const Word16 adap, /* i : SFB width adaptation */
+ Word16 *e_ps, /*Stores exponent for powerSpectrum*/
+ Word16 e_adap /*Stores exponent for adap*/
+)
+{
+ Word16 i;
+ Word16 width;
+ Word32 avg;
+ Word32 tonal;
+ Word16 tonal_e; /* holds exp for tonal*/
+ Word32 noise;
+ Word16 noise_e; /* holds exp for noise*/
+ Word32 tonalToNoise;
+ Word32 rootSpec[300];
+ Word16 rootSpec_e[300]; /*rootSpec_e[i] holds exp for rootSpec[i]*/
+ Word16 avg_e; /* holds exp for avg*/
+ Word16 tmp_e;
+ avg = 0;
+ tonal = 0;
+ noise = EPSILON_FX;
+ tonal_e = 0;
+ noise_e = 0;
+ avg_e = 0;
+ tmp_e = 0;
+ move32();
+ move32();
+ move32();
+ move16();
+ move16();
+ move16();
+ move16();
+
+ set32_fx( rootSpec, 0, 300 );
+ set16_fx( rootSpec_e, 0, 300 );
+
+ width = sub( stop, start );
+ FOR( i = start; i < stop; i++ )
+ {
+ rootSpec_e[( i - start )] = e_ps[i];
+ move16();
+ rootSpec[( i - start )] = Sqrt32( powerSpectrum[i], &rootSpec_e[( i - start )] ); /*rootSpec[i - start] = sqrtf( powerSpectrum[i] );*/
+ move32();
+ avg = BASOP_Util_Add_Mant32Exp( avg, avg_e, rootSpec[( i - start )], rootSpec_e[( i - start )], &avg_e ); /*avg += rootSpec[i - start];resultant exponent is avg_e*/
+ }
+ avg = BASOP_Util_Divide3216_Scale( avg, width, &tmp_e ); /*avg /= width;*/
+ avg_e = add( 16, sub( add( avg_e, tmp_e ), 15 ) );
+
+ FOR( i = start; i < stop; i++ )
+ {
+ Word16 normSpec_e; /*stores resultant exponent for normSpec*/
+ Word16 normSpec = BASOP_Util_Divide3232_Scale( rootSpec[i - start], avg, &normSpec_e ); /*rootSpec[i - start] / avg;*/
+ normSpec_e = add( normSpec_e, sub( rootSpec_e[i - start], avg_e ) );
+ IF( GT_32( normSpec, L_add_sat( L_shl_sat( 1, sub( 15, normSpec_e ) ), L_shl_sat( adap, sub( e_adap, normSpec_e ) ) ) ) )
+ {
+ tonal = BASOP_Util_Add_Mant32Exp( tonal, tonal_e, rootSpec[( i - start )], rootSpec_e[( i - start )], &tonal_e ); /*tonal += rootSpec[i - start];*/
+ }
+ ELSE IF( LT_32( normSpec, L_shl_sat( 1, sub( 15, normSpec_e ) ) ) )
+ {
+ noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, rootSpec[( i - start )], rootSpec_e[( i - start )], &noise_e ); /*noise += rootSpec[i - start];*/
+ }
+ }
+
+ /*tonalToNoise = 20.f * log10f( max( 1e-018f, tonal / noise ) )*/
+ IF( noise == 0 ) // To handle condition if denom = 0
+ {
+ tonalToNoise = imult3216( L_shr( L_add( L_shl( 18 /* log10f(1e-018f) */, Q25 ), Mpy_32_16_1( L_add( BASOP_Util_Log2( tonal ), L_shl( tonal_e, Q25 ) ) /*Q25*/, INV_Log2_10_Q15 ) /*25+15-15*/ ), 3 ) /*Q22*/, 20 );
+ }
+ ELSE
+ {
+ Word16 temp = BASOP_Util_Divide3232_Scale( tonal, noise, &tmp_e ); /*tonal / noise*/
+ tmp_e = add( tmp_e, sub( tonal_e, noise_e ) );
+ IF( GE_16( temp, 1 ) )
+ {
+ tonalToNoise = imult3216( Mult_32_16( L_add( BASOP_Util_Log2( temp ), L_shl( add( 16, tmp_e ), Q25 ) ) /*Q25*/, INV_Log2_10_Q12 ) /*25+12-15*/, 20 ); /*Q22*/
+ }
+ ELSE
+ {
+ tonalToNoise = -1509949440; /*-360.f Q22*/
+ move32();
+ }
+ }
+
+ return tonalToNoise;
+}
/*-------------------------------------------------------------------*
* IGF_CalculateEnvelope()
@@ -352,7 +438,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
Word32 *pMDCTSpectrum_fx, /* i : MDCT spectrum */
Word16 e_mdct, /* i : exp of MDCT spectrum */
Word32 *pPowerSpectrum_fx, /* i : MDCT^2 + MDST^2 spectrum, or estimate */
- Word16 e_ps, /* i : exp of power spectrum */
+ Word16 *e_ps, /* i : exp of power spectrum */
const Word16 igfGridIdx, /* i : IGF grid index */
const Word16 isTransient, /* i : flag indicating if transient is detected */
const Word16 last_core_acelp, /* i : indicator if last frame was ACELP core */
@@ -438,7 +524,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
{
IF( LT_32( 1, pPowerSpectrum_fx[sb] ) )
{
- hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps, Q25 ) ), Q25 ) );
+ hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps[sb], Q25 ) ), Q25 ) );
move16();
}
ELSE
@@ -477,14 +563,16 @@ static void IGF_CalculateEnvelope_ivas_fx(
move16();
FOR( sb = swb_offset[sfb]; sb < swb_offset[sfb + 1]; sb++ )
{
- sfbEnergyC = BASOP_Util_Add_Mant32Exp( sfbEnergyC, sfbEnergyC_e, pPowerSpectrum_fx[sb], e_ps, &sfbEnergyC_e );
+ Word16 shift = norm_l( pPowerSpectrum_fx[sb] );
+ sfbEnergyC = BASOP_Util_Add_Mant32Exp( sfbEnergyC, sfbEnergyC_e, L_shl( pPowerSpectrum_fx[sb], shift ), sub( e_ps[sb], shift ), &sfbEnergyC_e );
// sfbEnergyTileR = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR, sfbEnergyTileR_e, Mult_32_32( pMDCTSpectrum_fx[strt_cpy], pMDCTSpectrum_fx[strt_cpy] ), shl( e_mdct, 1 ), &sfbEnergyTileR_e );
Word64 tmp64 = W_mult_32_32( pMDCTSpectrum_fx[strt_cpy], pMDCTSpectrum_fx[strt_cpy] );
Word16 tmp64_e = W_norm( tmp64 );
tmp64 = W_shl( tmp64, tmp64_e );
sfbEnergyTileR = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR, sfbEnergyTileR_e, W_extract_h( tmp64 ), shl( e_mdct, 1 ) - tmp64_e, &sfbEnergyTileR_e );
- sfbEnergyTileC = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC, sfbEnergyTileC_e, pPowerSpectrum_fx[strt_cpy], e_ps, &sfbEnergyTileC_e );
+ shift = norm_l( pPowerSpectrum_fx[strt_cpy] );
+ sfbEnergyTileC = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC, sfbEnergyTileC_e, L_shl( pPowerSpectrum_fx[strt_cpy], shift ), sub( e_ps[strt_cpy], shift ), &sfbEnergyTileC_e );
strt_cpy = add( strt_cpy, 1 );
}
@@ -656,7 +744,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
}
ELSE
{
- y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps, Q25 ) ) ), INV_Log2_10_Q15 ), Q25 ) ) ); /*Q0*/
+ y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps[sb], Q25 ) ) ), INV_Log2_10_Q15 ), Q25 ) ) ); /*Q0*/
}
mean_y_fx_tmp = L_mac0( mean_y_fx_tmp, y, 1 ); /*Q0*/
mean_xy_fx = L_add( mean_xy_fx, L_mult0( y, x ) ); /*Q0*/
@@ -728,7 +816,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
tonalToNoise_e = 9;
move16();
adap = BASOP_Util_Divide1616_Scale( width, 40, &adap_e );
- tonalToNoise = IGF_getTNR_fx( pPowerSpectrum_fx, swb_offset[sfb], swb_offset[sfb + 1], adap, e_ps, adap_e ); /*Q22*/
+ tonalToNoise = IGF_getTNR_ivas_fx( pPowerSpectrum_fx, swb_offset[sfb], swb_offset[sfb + 1], adap, e_ps, adap_e ); /*Q22*/
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( tonalToNoise, tonalToNoise_e, L_add( L_shl( 10, sub( 15, adap_e ) ), adap ), add( 16, adap_e ) ), -1 ) )
{
@@ -1590,7 +1678,7 @@ static void IGF_Whitening_ivas_fx(
IF( LT_32( powerSpectrum[sb], 1 ) )
hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP )*/
ELSE
- hPrivateData->logSpec[sb] = extract_l( L_max( 0, L_shr( L_add( BASOP_Util_Log2( powerSpectrum[sb] ), L_shl( *powerSpectrum_e, Q25 ) ), Q25 ) ) );
+ hPrivateData->logSpec[sb] = extract_l( L_max( 0, L_shr( L_add( BASOP_Util_Log2( powerSpectrum[sb] ), L_shl( powerSpectrum_e[sb], Q25 ) ), Q25 ) ) );
move16();
}
}
@@ -1606,7 +1694,7 @@ static void IGF_Whitening_ivas_fx(
}
ELSE
{
- tmp = BASOP_Util_Divide1616_Scale( IGF_getSFM_new_fx( powerSpectrum, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], *powerSpectrum_e ), IGF_getCrest_new_fx( hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], &crest_e ), &tmp_e );
+ tmp = BASOP_Util_Divide1616_Scale( IGF_getSFM_new_fx( powerSpectrum, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], powerSpectrum_e ), IGF_getCrest_new_fx( hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], &crest_e ), &tmp_e );
tmp_e = sub( tmp_e, crest_e );
}
@@ -2487,7 +2575,7 @@ void IGFEncApplyMono_ivas_fx(
Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */
Word16 e_mdct, /* i : exponent of pMDCTspectrum */
Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
- Word16 e_ps, /* i : exponent of pPowerSpectrum */
+ Word16 *e_ps, /* i : exponent of pPowerSpectrum */
const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
const Word8 isTNSActive, /* i : flag indicating if the TNS is active */
const Word16 sp_aud_decision0, /* i : first stage switching decision */
@@ -2495,11 +2583,15 @@ void IGFEncApplyMono_ivas_fx(
)
{
Word32 *pPowerSpectrumParameter_fx;
+ Word16 *pPowerSpectrumParameter_exp;
Word16 att_fx = MAX16B;
Word16 last_core_acelp;
Word16 highPassEner_exp;
move16();
+ Word32 common_pPowerSpectrum_fx[N_MAX + L_MDCT_OVLP_MAX];
+ Word16 common_pPowerSpectrum_exp = MIN16B;
+ move16();
test();
IF( st->last_core == ACELP_CORE )
{
@@ -2516,10 +2608,12 @@ void IGFEncApplyMono_ivas_fx(
IF( !isTNSActive && isTCX20 )
{
pPowerSpectrumParameter_fx = pPowerSpectrum_fx;
+ pPowerSpectrumParameter_exp = e_ps;
}
ELSE
{
pPowerSpectrumParameter_fx = NULL;
+ pPowerSpectrumParameter_exp = NULL;
}
IGF_UpdateInfo( st->hIGFEnc, igfGridIdx );
@@ -2530,28 +2624,43 @@ void IGFEncApplyMono_ivas_fx(
calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
}
- IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, e_ps, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx );
+ IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx );
test();
IF( isTCX20 )
{
pPowerSpectrumParameter_fx = pPowerSpectrum_fx;
+ pPowerSpectrumParameter_exp = e_ps;
}
ELSE
{
pPowerSpectrumParameter_fx = NULL;
+ pPowerSpectrumParameter_exp = NULL;
}
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, &e_ps, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->element_brate, st->element_mode );
+ IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->element_brate, st->element_mode );
}
ELSE
{
- IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, &e_ps, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->total_brate, st->element_mode );
+ IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->total_brate, st->element_mode );
}
- IGF_ErodeSpectrum( &highPassEner_exp, st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, e_ps, igfGridIdx );
+ IF( pPowerSpectrumParameter_fx )
+ {
+ FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ )
+ {
+ common_pPowerSpectrum_exp = s_max( common_pPowerSpectrum_exp, pPowerSpectrumParameter_exp[i] );
+ }
+
+ FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ )
+ {
+ common_pPowerSpectrum_fx[i] = L_shl( common_pPowerSpectrum_fx[i], sub( pPowerSpectrumParameter_exp[i], common_pPowerSpectrum_exp ) );
+ move16();
+ }
+ }
+ IGF_ErodeSpectrum( &highPassEner_exp, st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, common_pPowerSpectrum_exp, igfGridIdx );
}
@@ -2581,6 +2690,7 @@ void IGFEncApplyStereo_fx(
Word16 coreMsMask[N_MAX];
Word16 sfb, ch, last_core_acelp;
STEREO_MDCT_BAND_PARAMETERS *sfbConf;
+ Word16 exp_pPowerSpectrum[L_FRAME48k];
/* assumptions: stereo filling was already done on the flattened spectra
* IGF region is always coded M/S, never L/R (to be done in the encoder)
@@ -2644,7 +2754,9 @@ void IGFEncApplyStereo_fx(
pPowerSpectrumParameter_fx[ch] = NULL;
}
- IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], &sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode );
+ set16_fx( exp_pPowerSpectrum, sts[ch]->hTcxEnc->spectrum_e[frameno], L_FRAME48k );
+
+ IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], &exp_pPowerSpectrum[0], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode );
IGF_ErodeSpectrum( &highPassEner_exp, hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx );
}
@@ -2661,13 +2773,18 @@ void IGFEncApplyStereo_fx(
void IGFSaveSpectrumForITF_ivas_fx(
IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */
const Word16 igfGridIdx, /* i : IGF grid index */
- const Word32 *pITFSpectrum /* i : MDCT spectrum */
-)
+ const Word32 *pITFSpectrum, /* i : MDCT spectrum */
+ Word16 exp_pITFSpectrum )
{
IGF_UpdateInfo( hIGFEnc, igfGridIdx );
Copy32( pITFSpectrum + IGF_START_MN, hIGFEnc->spec_be_igf, sub( hIGFEnc->infoStopLine, IGF_START_MN ) );
+ scale_sig32( hIGFEnc->spec_be_igf, sub( hIGFEnc->infoStopLine, IGF_START_MN ), sub( exp_pITFSpectrum, s_max( exp_pITFSpectrum, hIGFEnc->spec_be_igf_e ) ) );
+ scale_sig32( hIGFEnc->spec_be_igf + sub( hIGFEnc->infoStopLine, IGF_START_MN ), sub( N_MAX_TCX - IGF_START_MN, sub( hIGFEnc->infoStopLine, IGF_START_MN ) ), sub( hIGFEnc->spec_be_igf_e, s_max( exp_pITFSpectrum, hIGFEnc->spec_be_igf_e ) ) );
+ hIGFEnc->spec_be_igf_e = s_max( exp_pITFSpectrum, hIGFEnc->spec_be_igf_e );
+ move16();
+
return;
}
diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c
index 5ac4f4e3e9c278705e73817d0c46402ae38b93bb..04ca67979f1eb2a809bf66b850d15804691b9c61 100644
--- a/lib_enc/igf_scf_enc.c
+++ b/lib_enc/igf_scf_enc.c
@@ -93,11 +93,11 @@ static void arith_encode_bits(
FOR( i = nBits - 1; i >= 0; --i ) /* nBits > 0 */
{
bit = s_and( shr( x, i ), 1 );
- hPrivateData->ptrBitIndex = ari_encode_14bits_sign( ptr,
- hPrivateData->ptrBitIndex,
- 32767, /* disable the bit count limitation */
- &hPrivateData->acState,
- bit );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_sign_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ 32767, /* disable the bit count limitation */
+ &hPrivateData->acState,
+ bit );
}
}
@@ -128,11 +128,11 @@ static void arith_encode_residual(
{
x = sub( x, IGF_MIN_ENC_SEPARATE - 1 ); /* (x - IGF_MIN_ENC_SEPARATE) + 1 */
/* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */
- hPrivateData->ptrBitIndex = ari_encode_14bits_ext( ptr,
- hPrivateData->ptrBitIndex,
- &hPrivateData->acState,
- x,
- cumulativeFrequencyTable );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ &hPrivateData->acState,
+ x,
+ cumulativeFrequencyTable );
return;
}
@@ -141,21 +141,21 @@ static void arith_encode_residual(
{
/* send escape code 0 to indicate x <= IGF_MIN_ENC_SEPARATE - 1 */
extra = sub( IGF_MIN_ENC_SEPARATE - 1, x );
- hPrivateData->ptrBitIndex = ari_encode_14bits_ext( ptr,
- hPrivateData->ptrBitIndex,
- &hPrivateData->acState,
- 0,
- cumulativeFrequencyTable );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ &hPrivateData->acState,
+ 0,
+ cumulativeFrequencyTable );
}
ELSE /* x > IGF_MAX_ENC_SEPARATE */
{
/* send escape code (IGF_SYMBOLS_IN_TABLE - 1) to indicate x >= IGF_MAX_ENC_SEPARATE + 1 */
extra = sub( x, IGF_MAX_ENC_SEPARATE + 1 );
- hPrivateData->ptrBitIndex = ari_encode_14bits_ext( ptr,
- hPrivateData->ptrBitIndex,
- &hPrivateData->acState,
- IGF_SYMBOLS_IN_TABLE - 1,
- cumulativeFrequencyTable );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ &hPrivateData->acState,
+ IGF_SYMBOLS_IN_TABLE - 1,
+ cumulativeFrequencyTable );
}
/* encode one of the tails of the distribution */
@@ -221,11 +221,11 @@ static void encode_sfe_vector(
{
/* (t == 0) && (f == 0) */
/* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */
- hPrivateData->ptrBitIndex = ari_encode_14bits_ext( ptr,
- hPrivateData->ptrBitIndex,
- &hPrivateData->acState,
- shr( x[f], 2 ),
- (const UWord16 *) hPrivateData->cf_se00 );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ &hPrivateData->acState,
+ shr( x[f], 2 ),
+ (const UWord16 *) hPrivateData->cf_se00 );
arith_encode_bits( hPrivateData, ptr, x[f] & 3, 2 ); /* LSBs as 2 bit raw */
}
ELSE IF( EQ_16( f, 1 ) )
@@ -298,7 +298,7 @@ Word16 IGFSCFEncoderEncode(
encode_sfe_vector( hPublicData, ptr, hPublicData->t, hPublicData->prev, sfe, hPublicData->scfCountLongBlock[igfGridIdx] );
- hPublicData->ptrBitIndex = ari_done_encoding_14bits( ptr, hPublicData->ptrBitIndex, &hPublicData->acState ); /* finish AC encoding */
+ hPublicData->ptrBitIndex = ari_done_encoding_14bits_ivas_fx( ptr, hPublicData->ptrBitIndex, &hPublicData->acState ); /* finish AC encoding */
hPublicData->bitCount = add( hPublicData->bitCount, hPublicData->ptrBitIndex );
move16();
move16();
diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c
index e7c66738847aeba5512e56f56b3fb895f45af8a3..7d046db5ff8c5601d00294cdb54ad60dd53717d3 100644
--- a/lib_enc/init_enc.c
+++ b/lib_enc/init_enc.c
@@ -1072,7 +1072,8 @@ ivas_error init_encoder_ivas_fx(
}
st->currEnergyHF_fx = 0;
move32();
-
+ st->currEnergyHF_e_fx = 0;
+ move16();
#ifdef MSAN_FIX
st->prevEnergyHF_fx = 0;
move32();
diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c
index 725cad9132e818521df6c8cc3e363bcd326227ae..a2567535209f5e6777477e7da66811aa8bc78e3e 100644
--- a/lib_enc/inov_enc_fx.c
+++ b/lib_enc/inov_enc_fx.c
@@ -504,7 +504,7 @@ Word16 inov_encode_ivas_fx(
// Word16 Rw_e = E_ACELP_hh_corr( h2, Rw, L_SUBFR, 3 );
corr_hh_ivas_fx( h2, Rw, &Rw_q, L_subfr ); // Q(Rw) = Q11-2
- E_ACELP_conv_ivas( xn2, h2, cn ); // Qcn = Qxn2
+ E_ACELP_conv_ivas_fx( xn2, h2, cn ); // Qcn = Qxn2
/* dn_e -> Rw_e*Q_xn */
// Scale_sig(Rw, L_SUBFR, sub(5, Rw_e)); //Q9
diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c
index 761542c4f51decbf9c993c49aeaacdc06705ab13..dcc55f5ad00003a0d2d1a9dae89a19b9ab97905d 100644
--- a/lib_enc/ivas_agc_enc.c
+++ b/lib_enc/ivas_agc_enc.c
@@ -32,11 +32,12 @@
#include
+#include
+#include
#include "options.h"
#include "ivas_prot.h"
#include "prot.h"
-#include
-#include
+#include "rom_com.h"
#include "wmc_auto.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
@@ -209,7 +210,7 @@ Word32 pow32_fx( Word16 inp, Word16 indx )
/*! r: AGC enable flag */
Word16 ivas_agc_enc_get_flag(
- const Word16 nchan_transport /* i : number of transport channels */
+ const Word16 nchan_transport /* i : number of transport channels Q0*/
)
{
Word16 agc_flag;
@@ -235,15 +236,16 @@ Word16 ivas_agc_enc_get_flag(
static void ivas_agc_enc_init_fx(
ivas_agc_enc_state_t *hAgcEnc,
- const Word16 input_frame,
- const Word16 nchan_inp,
- const Word16 delay )
+ const Word16 input_frame, /* Q0 */
+ const Word16 nchan_inp, /* Q0 */
+ const Word16 delay /* Q0 */
+)
{
Word16 i;
ivas_agc_enc_chan_state_t *ptrG = hAgcEnc->gain_state;
ivas_agc_chan_data_t *ptr = hAgcEnc->gain_data;
- hAgcEnc->agc_com.in_delay = delay;
+ hAgcEnc->agc_com.in_delay = delay; /* Q0 */
move16();
hAgcEnc->agc_com.num_coeff = FOA_CHANNELS;
move16();
@@ -283,9 +285,9 @@ static void ivas_agc_enc_init_fx(
ptrG++;
/* gain_data */
- ptr->absGainExp = hAgcEnc->agc_com.absEmin;
+ ptr->absGainExp = hAgcEnc->agc_com.absEmin; /* Q0 */
move16();
- ptr->absGainExpCurr = hAgcEnc->agc_com.absEmin;
+ ptr->absGainExpCurr = hAgcEnc->agc_com.absEmin; /* Q0 */
move16();
ptr++;
}
@@ -302,8 +304,8 @@ static void ivas_agc_enc_init_fx(
ivas_error ivas_spar_agc_enc_open_fx(
ivas_agc_enc_state_t **hAgcEnc, /* i/o: SPAR AGC encoder handle */
- const Word32 input_Fs, /* i : input sampling rate */
- const Word16 nchan_inp /* i : number of input channels */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
+ const Word16 nchan_inp /* i : number of input channels Q0*/
)
{
ivas_agc_enc_state_t *hAgc;
@@ -314,7 +316,7 @@ ivas_error ivas_spar_agc_enc_open_fx(
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR AGC encoder" );
}
- input_frame = extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) );
+ input_frame = extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ); /* Q0 */
delay = NS2SA_FX2( input_Fs, ( IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ) );
IF( ( hAgc->agc_com.winFunc_fx = (Word16 *) malloc( sizeof( Word16 ) * ( input_frame - delay ) ) ) == NULL )
@@ -385,9 +387,9 @@ void ivas_spar_agc_enc_close_fx(
void ivas_agc_enc_process_fx(
ivas_agc_enc_state_t *hAgcEnc, /* i/o: AGC encoder handle */
BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */
- Word32 **ppPcm_in, /* i : input audio channels */
- Word32 **ppPcm_out, /* o : output audio channels */
- const Word16 n_channels, /* i : number of channels */
+ Word32 **ppPcm_in, /* i : input audio channels q_ppPcm*/
+ Word32 **ppPcm_out, /* o : output audio channels q_ppPcm*/
+ const Word16 n_channels, /* i : number of channels Q0*/
const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
Word16 *q_ppPcm )
{
@@ -399,8 +401,8 @@ void ivas_agc_enc_process_fx(
Word16 q_predMaxAbsVal, q_MaxAbsVal;
ivas_agc_enc_state_t *pState = hAgcEnc;
- input_frame = extract_l( Mpy_32_16_1( hEncoderConfig->input_Fs, INV_FRAME_PER_SEC_Q15 ) );
- offset = sub( input_frame, pState->agc_com.in_delay );
+ input_frame = extract_l( Mpy_32_16_1( hEncoderConfig->input_Fs, INV_FRAME_PER_SEC_Q15 ) ); /* Q0 */
+ offset = sub( input_frame, pState->agc_com.in_delay ); /* Q0 */
AGC_flag = 0;
move16();
@@ -428,20 +430,20 @@ void ivas_agc_enc_process_fx(
IF( LT_16( pState->gain_state[i].q_lastGain_fx, Q31 ) )
{
gain_norm = norm_l( L_abs( pState->gain_state[i].lastGain_fx ) );
- pState->gain_state[i].lastGain_fx = L_shl( pState->gain_state[i].lastGain_fx, gain_norm );
+ pState->gain_state[i].lastGain_fx = L_shl( pState->gain_state[i].lastGain_fx, gain_norm ); /* pState->gain_state[i].q_lastGain_fx + gain_norm */
move32();
pState->gain_state[i].q_lastGain_fx = add( pState->gain_state[i].q_lastGain_fx, gain_norm );
move16();
}
FOR( j = 0; j < input_frame; j++ )
{
- sampleAbsVal = L_abs( ppPcm_in[i][j] );
+ sampleAbsVal = L_abs( ppPcm_in[i][j] ); /* q_ppPcm */
q_sampleAbsVal = q_ppPcm[i];
move16();
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp_sat( sampleAbsVal, sub( Q31, q_sampleAbsVal ), MaxAbsVal, sub( Q31, q_MaxAbsVal ) ), 1 ) )
{
- MaxAbsVal = sampleAbsVal;
+ MaxAbsVal = sampleAbsVal; /* q_sampleAbsVal */
move32();
q_MaxAbsVal = q_sampleAbsVal;
move16();
@@ -453,14 +455,14 @@ void ivas_agc_enc_process_fx(
{
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp_sat( sampleAbsVal, sub( Q31, q_sampleAbsVal ), predMaxAbsVal, sub( Q31, q_predMaxAbsVal ) ), 1 ) )
{
- predMaxAbsVal = sampleAbsVal;
+ predMaxAbsVal = sampleAbsVal; /* q_sampleAbsVal */
move32();
q_predMaxAbsVal = q_sampleAbsVal;
move16();
}
}
- ppPcm_out[i][j] = Mpy_32_32( ppPcm_in[i][j], pState->gain_state[i].lastGain_fx );
+ ppPcm_out[i][j] = Mpy_32_32( ppPcm_in[i][j], pState->gain_state[i].lastGain_fx ); /* q_ppPcm + State->gain_state[i].q_lastGain_fx - 31 */
move32();
q_pcm = add( q_ppPcm[i], sub( pState->gain_state[i].q_lastGain_fx, Q31 ) );
IF( !isClipped )
@@ -500,7 +502,7 @@ void ivas_agc_enc_process_fx(
}
}
- pState->gain_state[i].MaxAbsVal_del_fx = predMaxAbsVal;
+ pState->gain_state[i].MaxAbsVal_del_fx = predMaxAbsVal; /* q_predMaxAbsVal */
move32();
pState->gain_state[i].q_MaxAbsVal_del_fx = q_predMaxAbsVal;
move16();
@@ -536,10 +538,10 @@ void ivas_agc_enc_process_fx(
temp1 = Mpy_32_32( pState->smFact_fx, MaxAbsVal ); // q_MaxAbsVal
temp2 = Mpy_32_32( ( L_sub( ONE_IN_Q31, pState->smFact_fx ) ), pState->gain_state[i].lastMaxAbs_fx ); // q_lastMaxAbs_fx
- smoothedMaxAbsVal = BASOP_Util_Add_Mant32Exp( temp1, sub( Q31, q_MaxAbsVal ), temp2, sub( Q31, pState->gain_state[i].q_lastMaxAbs_fx ), &e_result );
+ smoothedMaxAbsVal = BASOP_Util_Add_Mant32Exp( temp1, sub( Q31, q_MaxAbsVal ), temp2, sub( Q31, pState->gain_state[i].q_lastMaxAbs_fx ), &e_result ); /* exp(e_result) */
q_smoothedMaxAbsVal = sub( Q31, e_result );
- pState->gain_state[i].lastMaxAbs_fx = smoothedMaxAbsVal;
+ pState->gain_state[i].lastMaxAbs_fx = smoothedMaxAbsVal; /* q_smoothedMaxAbsVal */
move32();
pState->gain_state[i].q_lastMaxAbs_fx = q_smoothedMaxAbsVal;
move16();
@@ -547,7 +549,7 @@ void ivas_agc_enc_process_fx(
Comp_flag = BASOP_Util_Cmp_Mant32Exp_sat( smoothedMaxAbsVal, sub( Q31, q_smoothedMaxAbsVal ), MaxAbsVal, sub( Q31, q_MaxAbsVal ) );
IF( EQ_16( Comp_flag, 1 ) )
{
- temp1 = smoothedMaxAbsVal;
+ temp1 = smoothedMaxAbsVal; /* q_smoothedMaxAbsVal */
move32();
q_temp = q_smoothedMaxAbsVal;
move16();
@@ -559,9 +561,9 @@ void ivas_agc_enc_process_fx(
q_temp = q_MaxAbsVal;
move16();
}
- temp1 = Mpy_32_32( temp1, TWO_IN_Q29 );
+ temp1 = Mpy_32_32( temp1, TWO_IN_Q29 ); /* q_temp + 29 - 31 */
q_temp = add( q_temp, Q29 - Q31 );
- maxGain = Mpy_32_32( temp1, pState->gain_state[i].lastGain_fx );
+ maxGain = Mpy_32_32( temp1, pState->gain_state[i].lastGain_fx ); /* q_temp + pState->gain_state[i].q_lastGain_fx - 31 */
q_maxGain = add( q_temp, sub( pState->gain_state[i].q_lastGain_fx, Q31 ) );
temp2 = ONE_MINUS_M_DELTA_PROD_FLT_FC; // Q15
@@ -581,7 +583,7 @@ void ivas_agc_enc_process_fx(
}
ELSE
{
- pState->gain_state[i].lastMaxAbs_fx = MaxAbsVal;
+ pState->gain_state[i].lastMaxAbs_fx = MaxAbsVal; /* q_MaxAbsVal */
move32();
pState->gain_state[i].q_lastMaxAbs_fx = q_MaxAbsVal;
move16();
@@ -603,7 +605,7 @@ void ivas_agc_enc_process_fx(
Word32 temp1, temp2;
actualMaxAbsVal = Mpy_32_32( pState->gain_state[i].lastMaxAbs_fx, pState->gain_state[i].lastGain_fx ); // QlastGain_fx
q_actualMaxAbsVal = add( pState->gain_state[i].q_lastMaxAbs_fx, sub( pState->gain_state[i].q_lastGain_fx, Q31 ) );
- idx = s_min( sub( offset, 1 ), MaxAbsValIdx );
+ idx = s_min( sub( offset, 1 ), MaxAbsValIdx ); /* Q0 */
q_actualMaxAbsVal = add( q_actualMaxAbsVal, norm_l( actualMaxAbsVal ) );
temp1 = L_shl( actualMaxAbsVal, norm_l( actualMaxAbsVal ) );
@@ -619,16 +621,16 @@ void ivas_agc_enc_process_fx(
}
ELSE
{
- temp_16 = BASOP_Util_Divide3232_Scale( temp1, temp2, &div_e );
+ temp_16 = BASOP_Util_Divide3232_Scale( temp1, temp2, &div_e ); /* exp(div_e) */
IF( div_e < 0 )
{
temp_16 = shr( temp_16, (Word16) abs( div_e ) );
div_e = 0;
move16();
}
- temp_16 = ceil_fx( temp_16, sub( Q15, div_e ) );
+ temp_16 = ceil_fx( temp_16, sub( Q15, div_e ) ); /* Q0 */
}
- pState->gain_state[i].gainExpVal = temp_16;
+ pState->gain_state[i].gainExpVal = temp_16; /* Q0 */
move16();
WHILE( !isCompensated )
@@ -640,7 +642,7 @@ void ivas_agc_enc_process_fx(
move16();
Word32 tmp_2 = ONE_IN_Q31;
move16();
- tmp_1 = pState->gain_state[i].gainExpVal;
+ tmp_1 = pState->gain_state[i].gainExpVal; /* Q0 */
move16();
FOR( idx = clippedIdx; idx <= MaxAbsValIdx; idx++ )
{
@@ -650,21 +652,21 @@ void ivas_agc_enc_process_fx(
move16();
IF( tmp_1 < 0 )
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) ); /* Q31 */
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
ELSE
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 ); /* Q31 */
q_tmp_2 = Q31;
move16();
}
@@ -673,15 +675,15 @@ void ivas_agc_enc_process_fx(
{
IF( tmp_1 < 0 )
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], ( negate( tmp_1 ) ) );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], ( negate( tmp_1 ) ) ); /* Q31 */
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
@@ -693,7 +695,7 @@ void ivas_agc_enc_process_fx(
}
}
- tmpSignal = Mpy_32_32( ppPcm_out[i][idx], tmp_2 );
+ tmpSignal = Mpy_32_32( ppPcm_out[i][idx], tmp_2 ); /* q_pcm + q_tmp_2 - 31 */
q_tmpSignal = add( q_pcm, sub( q_tmp_2, 31 ) );
Word16 comp_flag_1 = BASOP_Util_Cmp_Mant32Exp_sat( tmpSignal, sub( Q31, q_tmpSignal ), ONE_MINUS_M_DELTA_PROD_FLT_FC, Q16 );
@@ -729,13 +731,13 @@ void ivas_agc_enc_process_fx(
}
IF( !isCompensated )
{
- pState->gain_state[i].gainExpVal = add( pState->gain_state[i].gainExpVal, 1 );
+ pState->gain_state[i].gainExpVal = add( pState->gain_state[i].gainExpVal, 1 ); /* Q0 */
move16();
}
IF( GT_16( pState->gain_state[i].gainExpVal, currMaxAttExp ) )
{
- pState->gain_state[i].gainExpVal = s_min( pState->gain_state[i].gainExpVal, currMaxAttExp );
+ pState->gain_state[i].gainExpVal = s_min( pState->gain_state[i].gainExpVal, currMaxAttExp ); /* Q0 */
move16();
BREAK;
}
@@ -747,7 +749,7 @@ void ivas_agc_enc_process_fx(
{
Word16 tmp_1, q_tmp_2, e_div;
Word32 tmp_2;
- tmp_1 = pState->gain_state[i].gainExpVal;
+ tmp_1 = pState->gain_state[i].gainExpVal; /* Q0 */
move16();
IF( GT_16( offset, idx ) )
@@ -757,18 +759,18 @@ void ivas_agc_enc_process_fx(
tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], ( negate( tmp_1 ) ) );
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
ELSE
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], tmp_1 );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], tmp_1 ); /* Q31 */
q_tmp_2 = Q31;
move16();
}
@@ -777,21 +779,21 @@ void ivas_agc_enc_process_fx(
{
IF( tmp_1 < 0 )
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) ); /* Q31 */
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
ELSE
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 ); /* Q31 */
q_tmp_2 = Q31;
move16();
}
@@ -805,29 +807,29 @@ void ivas_agc_enc_process_fx(
Word16 tmp_1, q_tmp_2, e_div;
Word32 tmp_2;
- tmp_1 = pState->gain_state[i].gainExpVal;
+ tmp_1 = pState->gain_state[i].gainExpVal; /* Q0 */
move16();
IF( tmp_1 < 0 )
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) ); /* Q31 */
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
ELSE
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 ); /* Q31 */
q_tmp_2 = Q31;
move16();
}
- pState->gain_state[i].lastGain_fx = Mpy_32_32( pState->gain_state[i].lastGain_fx, tmp_2 );
+ pState->gain_state[i].lastGain_fx = Mpy_32_32( pState->gain_state[i].lastGain_fx, tmp_2 ); /* pState->gain_state[i].q_lastGain_fx + q_tmp_2 - 31 */
move32();
pState->gain_state[i].q_lastGain_fx = add( pState->gain_state[i].q_lastGain_fx, sub( q_tmp_2, Q31 ) );
move16();
@@ -859,11 +861,11 @@ void ivas_agc_enc_process_fx(
{
IF( pState->gain_state[i].gainExpVal <= 0 )
{
- pState->gain_state[i].gainExpVal = add( pState->agc_com.maxAttExp, 1 );
+ pState->gain_state[i].gainExpVal = add( pState->agc_com.maxAttExp, 1 ); /* Q0 */
move16();
}
}
- pState->gain_data[i].absGainExpCurr = sub( pState->gain_data[i].absGainExp, pState->gain_state[i].gainExpVal );
+ pState->gain_data[i].absGainExpCurr = sub( pState->gain_data[i].absGainExp, pState->gain_state[i].gainExpVal ); /* Q0 */
move16();
test();
diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c
index 0b2a3923106999dcdd1d7e42110319c2024ef2dc..a691405329f4a1b880546efa9ec988965d03ddac 100644
--- a/lib_enc/ivas_core_enc.c
+++ b/lib_enc/ivas_core_enc.c
@@ -49,40 +49,41 @@
/*-------------------------------------------------------------------*
- * ivas_core_enc()
+ * ivas_core_enc_fx()
*
* Principal IVAS core coder routine, where number of core channels is 1 or 2
*-------------------------------------------------------------------*/
-ivas_error ivas_core_enc(
- SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- const Word16 n_CoreChannels, /* i : number of core channels to be coded */
- Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal */
- Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal */
- Word32 ener_fx[], /* i : residual energy from Levinson-Durbin Q6 */
- Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes */
- Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q */
+ivas_error ivas_core_enc_fx(
+ SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
+ const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/
+ Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/
+ Word16 Q_new[],
+ Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/
Word16 epsP_fx_q[], /* i : LP prediction errors */
- Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15 */
- Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15 */
- const Word16 vad_hover_flag[], /* i : VAD hanglover flag */
- Word16 attack_flag[], /* i : attack flag (GSC or TC) */
- Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
- Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
+ Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/
+ Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/
+ Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/
+ Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/
Word16 *q_re_im_buf,
- Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer */
+ Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/
Word16 e_old_wsp[],
- const Word16 loc_harm[], /* i : harmonicity flag */
- const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8 */
- const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO */
- Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
- Word16 enerBuffer_fx_exp[], /* o : energy buffer */
- Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer */
- const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag */
- const Word16 ivas_format, /* i : IVAS format */
- const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */
+ const Word16 loc_harm[], /* i : harmonicity flag Q0*/
+ const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/
+ const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 enerBuffer_fx_exp[], /* o : energy buffer */
+ Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/
+ const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/
+ const Word16 ivas_format, /* i : IVAS format Q0*/
+ const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
)
{
Word16 n, input_frame;
@@ -90,7 +91,6 @@ ivas_error ivas_core_enc(
Encoder_State **sts, *st;
STEREO_ICBWE_ENC_HANDLE hStereoICBWE;
STEREO_TD_ENC_DATA_HANDLE hStereoTD;
- Word16 Q_new[CPE_CHANNELS] = { 0 };
move16();
move16();
Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; /* Q15 */
@@ -150,9 +150,9 @@ ivas_error ivas_core_enc(
sts = hSCE->hCoreCoder;
hStereoTD = NULL;
hStereoICBWE = NULL;
- element_brate = hSCE->element_brate;
+ element_brate = hSCE->element_brate; /* Q0 */
move32();
- last_element_brate = hSCE->last_element_brate;
+ last_element_brate = hSCE->last_element_brate; /* Q0 */
move32();
last_element_mode = IVAS_SCE;
move16();
@@ -161,7 +161,7 @@ ivas_error ivas_core_enc(
}
ELSE
{
- cpe_id = hCPE->cpe_id;
+ cpe_id = hCPE->cpe_id; /* Q0 */
move16();
MCT_flag = 0;
move16();
@@ -172,17 +172,17 @@ ivas_error ivas_core_enc(
}
sts = hCPE->hCoreCoder;
hStereoICBWE = hCPE->hStereoICBWE;
- element_brate = hCPE->element_brate;
+ element_brate = hCPE->element_brate; /* Q0 */
move32();
- last_element_brate = hCPE->last_element_brate;
+ last_element_brate = hCPE->last_element_brate; /* Q0 */
move32();
- last_element_mode = hCPE->last_element_mode;
+ last_element_mode = hCPE->last_element_mode; /* Q0 */
move16();
IF( hCPE->hStereoTD != NULL )
{
hStereoTD = hCPE->hStereoTD;
- tdm_Pitch_reuse_flag = hCPE->hStereoTD->tdm_Pitch_reuse_flag;
+ tdm_Pitch_reuse_flag = hCPE->hStereoTD->tdm_Pitch_reuse_flag; /* Q0 */
move16();
}
ELSE
@@ -211,7 +211,7 @@ ivas_error ivas_core_enc(
unbits[n] = 0;
move16();
- st->element_brate = element_brate;
+ st->element_brate = element_brate; /* Q0 */
move32();
/*---------------------------------------------------------------------*
@@ -224,7 +224,7 @@ ivas_error ivas_core_enc(
tmp_shift = sub( tmp_shift, 5 );
IF( tmp_shift < 0 )
{
- scale_sig32( enerBuffer_fx[n], st->cldfbAnaEnc->no_channels, tmp_shift );
+ scale_sig32( enerBuffer_fx[n], st->cldfbAnaEnc->no_channels, tmp_shift ); /* enerBuffer_fx_exp[n] - tmp_shift */
enerBuffer_fx_exp[n] = sub( enerBuffer_fx_exp[n], tmp_shift );
move16();
}
@@ -250,9 +250,9 @@ ivas_error ivas_core_enc(
}
IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- IF( NE_32( ( error = pre_proc_ivas( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
- &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
- vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
+ IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
+ &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
+ vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
IVAS_ERR_OK ) )
{
return error;
@@ -260,9 +260,9 @@ ivas_error ivas_core_enc(
}
ELSE
{
- IF( NE_32( ( error = pre_proc_ivas( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
- &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
- vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
+ IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
+ &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
+ vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
IVAS_ERR_OK ) )
{
return error;
@@ -308,8 +308,8 @@ ivas_error ivas_core_enc(
/* write TD stereo spatial parameters */
move_indices( hStereoTD->tdm_hBstr_tmp.ind_list, st->hBstr->ind_list, hStereoTD->tdm_hBstr_tmp.nb_ind_tot );
- st->hBstr->nb_ind_tot = add( st->hBstr->nb_ind_tot, hStereoTD->tdm_hBstr_tmp.nb_ind_tot );
- st->hBstr->nb_bits_tot = add( st->hBstr->nb_bits_tot, hStereoTD->tdm_hBstr_tmp.nb_bits_tot );
+ st->hBstr->nb_ind_tot = add( st->hBstr->nb_ind_tot, hStereoTD->tdm_hBstr_tmp.nb_ind_tot ); /* Q0 */
+ st->hBstr->nb_bits_tot = add( st->hBstr->nb_bits_tot, hStereoTD->tdm_hBstr_tmp.nb_bits_tot ); /* Q0 */
reset_indices_enc( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP );
}
@@ -342,7 +342,7 @@ ivas_error ivas_core_enc(
/* ACELP core encoder */
Word16 Q_old_syn_12k8_16k = 0;
move16();
- IF( NE_32( ( error = acelp_core_enc( st, inp_fx[n], /*ener[n],*/ A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], &Q_old_syn_12k8_16k, pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n] ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = acelp_core_enc_ivas_fx( st, inp_fx[n], /*ener[n],*/ A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], &Q_old_syn_12k8_16k, pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n] ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -363,10 +363,9 @@ ivas_error ivas_core_enc(
Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q1, Q_new[n] ) ); // Q0
Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0
- Scale_sig( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64, sub( -1, st->hTcxEnc->q_Txnq ) );
+ Scale_sig( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64, sub( negate( 1 ), st->hTcxEnc->q_Txnq ) ); /* Q(-1) */
st->hTcxEnc->q_Txnq = -Q1;
move16();
-
Q_spec_old = hTcxEnc->spectrum_long_e;
move16();
/* TCX core encoder */
@@ -645,18 +644,12 @@ ivas_error ivas_core_enc(
st->q_old_inp = st->q_inp = 0;
move16();
move16();
-
- if ( st->hTcxEnc != NULL )
- {
- st->hTcxEnc->exp_buf_speech_ltp = 31; // Q0
- move16();
- }
IF( st->hBWE_FD != NULL )
{
- Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) );
- st->Q_old_wtda = -1; // This reset is required for resolving crash issue. Needs to be looked into further
+ Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( negate( 1 ), st->Q_old_wtda ) ); // Q(-1)
+ st->Q_old_wtda = -1; // This reset is required for resolving crash issue. Needs to be looked into further
move16();
- Scale_sig( st->hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( sub( Q_new[n], 1 ), st->hBWE_FD->prev_Q_input_lp ) );
+ Scale_sig( st->hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( sub( Q_new[n], 1 ), st->hBWE_FD->prev_Q_input_lp ) ); /* Q_new[n] - 1 */
st->hBWE_FD->prev_Q_input_lp = sub( Q_new[n], 1 );
move16();
}
@@ -743,7 +736,7 @@ ivas_error ivas_core_enc(
}
Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, input_frame );
- Scale_sig( new_swb_speech_buffer_fx_16, q_new_swb_speech_buffer, input_frame ); // Q0->q_new_swb_speech_buffer
+ Scale_sig( new_swb_speech_buffer_fx_16, input_frame, q_new_swb_speech_buffer ); // Q0->q_new_swb_speech_buffer
/* SWB TBE encoder */
test();
@@ -834,7 +827,7 @@ ivas_error ivas_core_enc(
IF( !MCT_flag ) /* for MCT do this later, otherwise there can be a problem because TCX quant happens later and might get the wrong last_core on a bit rate switch */
{
- updt_enc_common_ivas_fx( st );
+ updt_enc_common_ivas_fx( st, Q_new[n] );
}
IF( st->hBWE_FD != NULL )
@@ -842,10 +835,6 @@ ivas_error ivas_core_enc(
st->hBWE_FD->prev_Q_input_lp = sub( Q_new[n], 1 );
move16();
}
- IF( st->hTcxEnc != NULL )
- {
- Scale_sig( st->hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( st->hTcxEnc->exp_buf_speech_ltp ) ); // Q0
- }
}
/*------------------------------------------------------------------*
diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c
index 5bbd635cbe1bc994844b5a1327e837be509183e8..8c2c31adb023e7ded5165a82b24593b48b56e3dd 100644
--- a/lib_enc/ivas_core_pre_proc.c
+++ b/lib_enc/ivas_core_pre_proc.c
@@ -45,40 +45,40 @@
#include "basop_util.h"
/*-------------------------------------------------------------------*
- * pre_proc_ivas()
+ * pre_proc_ivas_fx()
*
* Pre-processing (Selection of internal Fs, classification, SC VBR decision,
* Decision matrix, Preprocessing at other Fs, core switching decision, ...)
*--------------------------------------------------------------------*/
-ivas_error pre_proc_ivas(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 element_brate, /* i : element bitrate */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 input_frame, /* i : frame length */
- Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal */
- Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz */
- Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame*/
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q6 */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */
- Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q */
- Word16 *epsP_fx_q, /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */
- Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
- Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */
- Word16 old_wsp_fx[], /* i : weighted input signal buffer */
+ivas_error pre_proc_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 last_element_mode, /* i : last element mode Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word32 last_element_brate, /* i : last element bitrate Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */
+ Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */
+ Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
+ Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/
+ Word16 *epsP_fx_q, /* i : LP prediction errors */
+ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
+ Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/
+ Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/
+ Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/
Word16 e_old_wsp,
- const Word16 loc_harm, /* i : harmonicity flag */
- const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ const Word16 loc_harm, /* i : harmonicity flag Q0*/
+ const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */
Word16 e_enerBuffer,
- Word16 fft_buff_fx[2 * L_FFT],
- Word16 cor_map_sum_fx, // Q8
+ Word16 fft_buff_fx[2 * L_FFT], /* Qx */
+ Word16 cor_map_sum_fx, /* Q8 */
Word16 *Q_new )
{
Word16 L_look, element_mode, lMemRecalc_12k8;
@@ -138,13 +138,13 @@ ivas_error pre_proc_ivas(
IF( st->core_brate == FRAME_NO_DATA )
{
/* prevent "L_frame" changes in CNG segments */
- st->L_frame = st->last_L_frame;
+ st->L_frame = st->last_L_frame; /* Q0 */
move16();
}
ELSE IF( EQ_32( st->core_brate, SID_2k40 ) && GE_16( st->bwidth, WB ) && st->hDtxEnc->first_CNG && ( st->hTdCngEnc != NULL && LT_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) )
{
/* prevent "L_frame" changes in SID frame after short segment of active frames */
- st->L_frame = st->hDtxEnc->last_CNG_L_frame;
+ st->L_frame = st->hDtxEnc->last_CNG_L_frame; /* Q0 */
move16();
}
ELSE IF( ( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && GE_32( st->element_brate, IVAS_64k ) && GE_16( st->bwidth, SWB ) ) || ( EQ_16( element_mode, IVAS_SCE ) && GT_32( st->total_brate, MAX_ACELP_BRATE ) && GE_16( st->bwidth, SWB ) ) ) && NE_32( st->core_brate, SID_2k40 ) )
@@ -191,7 +191,7 @@ ivas_error pre_proc_ivas(
if ( st->ini_frame == 0 )
{
/* avoid switching of internal ACELP Fs in the very first frame */
- st->last_L_frame = st->L_frame;
+ st->last_L_frame = st->L_frame; /* Q0 */
move16();
}
@@ -217,9 +217,9 @@ ivas_error pre_proc_ivas(
move16();
}
- st->sr_core = L_mult0( st->L_frame, FRAMES_PER_SEC );
- st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS );
- st->encoderPastSamples_enc = shr( ( imult1616( st->L_frame, 9 ) ), 4 );
+ st->sr_core = L_mult0( st->L_frame, FRAMES_PER_SEC ); /* Q0 */
+ st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); /* Q0 */
+ st->encoderPastSamples_enc = shr( ( imult1616( st->L_frame, 9 ) ), 4 ); /* Q0 */
move32();
move16();
move16();
@@ -248,7 +248,7 @@ ivas_error pre_proc_ivas(
test();
test();
/* enforce TRANSITION frames */
- IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) && NE_16( st->last_L_frame, st->L_frame ) && NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) && NE_32( st->last_core_brate, FRAME_NO_DATA ) && NE_32( st->last_core_brate, SID_2k40 ) && NE_16( st->coder_type_raw, VOICED ) )
+ IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) && NE_16( st->last_L_frame, st->L_frame ) && st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) && st->last_core_brate != FRAME_NO_DATA && NE_32( st->last_core_brate, SID_2k40 ) && NE_16( st->coder_type_raw, VOICED ) )
{
/* enforce TC frame in case of ACELP@12k8 <-> ACELP@16k core switching */
st->coder_type = TRANSITION;
@@ -298,10 +298,11 @@ ivas_error pre_proc_ivas(
st->mdct_sw_enable = MODE1;
move16();
move16();
+
test();
test();
test();
- IF( ( LE_32( st->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) || LT_16( st->bwidth, SWB ) || st->flag_ACELP16k ) && st->GSC_IVAS_mode == 0 )
+ if ( ( LE_32( st->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) || LT_16( st->bwidth, SWB ) || st->flag_ACELP16k ) && st->GSC_IVAS_mode == 0 )
{
st->GSC_noisy_speech = 0;
move16();
@@ -311,7 +312,7 @@ ivas_error pre_proc_ivas(
ivas_decision_matrix_enc_fx( st, element_brate, fft_buff_fx, enerBuffer_fx, e_enerBuffer, last_element_mode );
test();
test();
- IF( EQ_16( st->L_frame, L_FRAME16k ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, UNVOICED ) ) ) /* VOICED and UNVOICED are not supported in ACELP@16k */
+ if ( EQ_16( st->L_frame, L_FRAME16k ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, UNVOICED ) ) ) /* VOICED and UNVOICED are not supported in ACELP@16k */
{
st->coder_type = GENERIC;
move16();
@@ -323,22 +324,22 @@ ivas_error pre_proc_ivas(
st->Nb_ACELP_frames = 0;
move16();
/* Configure TCX with the same bitrate as given when (re-)initializing TCX */
- total_brate_tmp = st->total_brate;
+ total_brate_tmp = st->total_brate; /* Q0 */
move32();
- st->total_brate = L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC );
+ st->total_brate = L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ); /* Q0 */
move32();
- SetModeIndex_ivas_fx( st, st->last_bits_frame_nominal * FRAMES_PER_SEC, last_element_mode, MCT_flag );
+ SetModeIndex_ivas_fx( st, imult3216( st->last_bits_frame_nominal, FRAMES_PER_SEC ), last_element_mode, MCT_flag );
- st->sr_core = getCoreSamplerateMode2( element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format );
+ st->sr_core = getCoreSamplerateMode2( element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); /* Q0 */
move16();
- st->total_brate = total_brate_tmp;
+ st->total_brate = total_brate_tmp; /* Q0 */
move32();
- st->L_frame = extract_l( Mpy_32_32( st->sr_core, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ st->L_frame = extract_l( Mpy_32_32( st->sr_core, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
move16();
- st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS );
- st->encoderPastSamples_enc = shr( ( imult1616( st->L_frame, 9 ) ), 4 );
+ st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); /* Q0 */
+ st->encoderPastSamples_enc = shr( ( imult1616( st->L_frame, 9 ) ), 4 ); /* Q0 */
move16();
move16();
@@ -393,7 +394,7 @@ ivas_error pre_proc_ivas(
test();
test();
- IF( NE_16( st->extl, -1 ) && NE_16( st->extl, IGF_BWE ) && EQ_16( st->igf, 1 ) )
+ if ( NE_16( st->extl, -1 ) && NE_16( st->extl, IGF_BWE ) && EQ_16( st->igf, 1 ) )
{
st->igf = 0;
move16();
@@ -409,12 +410,12 @@ ivas_error pre_proc_ivas(
test();
IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 50 << 8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) )
{
- st->last_harm_flag_acelp = add( st->last_harm_flag_acelp, 1 );
+ st->last_harm_flag_acelp = add( st->last_harm_flag_acelp, 1 ); /* Q0 */
move16();
IF( GT_16( st->last_harm_flag_acelp, 10 ) )
{
- st->last_harm_flag_acelp = 10;
+ st->last_harm_flag_acelp = 10; /* Q0 */
move16();
}
}
@@ -430,22 +431,22 @@ ivas_error pre_proc_ivas(
IF( EQ_16( st->coder_type, AUDIO ) )
{
- st->audio_frame_cnt = add( st->audio_frame_cnt, AUDIO_COUNTER_STEP );
+ st->audio_frame_cnt = add( st->audio_frame_cnt, AUDIO_COUNTER_STEP ); /* Q0 */
move16();
}
- ELSE IF( NE_16( st->coder_type, INACTIVE ) )
+ ELSE IF( st->coder_type != INACTIVE )
{
- st->audio_frame_cnt = sub( st->audio_frame_cnt, 1 );
+ st->audio_frame_cnt = sub( st->audio_frame_cnt, 1 ); /* Q0 */
move16();
}
- IF( GT_16( st->audio_frame_cnt, AUDIO_COUNTER_MAX ) )
+ if ( GT_16( st->audio_frame_cnt, AUDIO_COUNTER_MAX ) )
{
- st->audio_frame_cnt = AUDIO_COUNTER_MAX;
+ st->audio_frame_cnt = AUDIO_COUNTER_MAX; /* Q0 */
move16();
}
- IF( st->audio_frame_cnt < 0 )
+ if ( st->audio_frame_cnt < 0 )
{
st->audio_frame_cnt = 0;
move16();
@@ -478,7 +479,7 @@ ivas_error pre_proc_ivas(
/* channel-aware mode - due to lack of signaling bit, sharpFlag is 1 always in RF mode */
test();
test();
- IF( st->rf_mode && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) ) )
+ if ( st->rf_mode && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) ) )
{
st->sharpFlag = 1;
move16();
@@ -491,7 +492,7 @@ ivas_error pre_proc_ivas(
st->sharpFlag = 0;
move16();
test();
- IF( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) )
+ if ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) )
{
st->sharpFlag = 1;
move16();
@@ -528,76 +529,84 @@ ivas_error pre_proc_ivas(
sr_core_tmp = L_max( INT_FS_16k, st->sr_core );
}
- L_look = NS2SA( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) */
+ L_look = NS2SA( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) Q0*/
move16();
inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look;
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
Word16 Q_old_inp_16k = -1;
+ move16();
Word16 Q_r[2] = { 0 };
+ move16();
+ move16();
inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look;
- Word16 shift = getScaleFactor16( st->old_inp_12k8_fx, 240 );
- Scale_sig( st->old_inp_12k8_fx, 240, shift );
+ Word16 shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM );
+ Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift );
move16();
- Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( Q_old_inp_16k, sub( Q15, Q_old_inp_16k ) ) );
+ Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q15 - st->exp_old_inp_16k */
st->exp_old_inp_16k = sub( Q15, Q_old_inp_16k );
- if ( st->hBWE_FD != NULL )
+ move16();
+
+ IF( st->hBWE_FD != NULL )
{
- Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) );
- st->Q_old_wtda = -1; // This reset needs to be looked into
+ Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) ); /* -1Q */
+ st->Q_old_wtda = -1; // This reset needs to be looked into
+ move16();
}
-#endif
- st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_mem_preemph_enc ) ) );
+
+ st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_mem_preemph_enc ) ) ); /* Q15 - Q_old_inp_16k */
move16();
st->exp_mem_preemph_enc = sub( Q15, Q_old_inp_16k );
move16();
- Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ) );
+ Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_buf_speech_enc = sub( Q15, Q_old_inp_16k );
move16();
- Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc_pe ) ) );
+ Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_buf_speech_enc_pe = sub( Q15, Q_old_inp_16k );
move16();
Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) );
st->q_inp = -1;
- Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) );
+ move16();
+ Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k );
move16();
+ Word16 Q_old_inp_128k = *Q_new;
+ move16();
IF( !flag_16k_smc )
{
error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx,
A_fx, Aw_fx,
epsP_fx,
- lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new );
- IF( NE_32( error, IVAS_ERR_OK ) )
+ lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new, 0 );
+ IF( error != IVAS_ERR_OK )
{
return error;
}
*epsP_fx_q = add( Q_r[0], 1 );
+ move16();
}
test();
- Scale_sig( old_inp_12k8_fx, L_INP_12k8, *Q_new ); // Q_new-1
IF( !( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) )
{
/* update signal buffers */
- Copy( new_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame, L_FRAME );
+ Copy_Scale_sig( new_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame, L_FRAME, sub( sub( Q15, st->exp_buf_speech_enc_pe ), sub( *Q_new, Q1 ) ) );
Copy( st->buf_speech_enc + L_FRAME32k, st->buf_speech_enc + st->L_frame, L_FRAME );
test();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, st->buf_speech_enc + st->L_frame - STEREO_DFT_OVL_12k8, STEREO_DFT_OVL_12k8 );
+ Copy( st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, st->buf_speech_enc + st->L_frame - STEREO_DFT_OVL_12k8, STEREO_DFT_OVL_12k8 ); /* Q_new - 1 */
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
- Copy( st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, st->buf_speech_enc + st->L_frame - lMemRecalc_12k8 - L_FILT, lMemRecalc_12k8 + L_FILT );
+ Copy( st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, st->buf_speech_enc + st->L_frame - lMemRecalc_12k8 - L_FILT, lMemRecalc_12k8 + L_FILT ); /* Q_new - 1 */
}
ELSE IF( EQ_16( element_mode, IVAS_SCE ) )
{
- Copy( st->buf_speech_enc + L_FRAME32k - L_FILT, st->buf_speech_enc + st->L_frame - L_FILT, L_FILT );
+ Copy( st->buf_speech_enc + L_FRAME32k - L_FILT, st->buf_speech_enc + st->L_frame - L_FILT, L_FILT ); /* Q_new - 1 */
}
IF( st->tcxonly == 0 )
@@ -608,7 +617,7 @@ ivas_error pre_proc_ivas(
IF( flag_16k_smc )
{
- Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k );
+ Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_new - 1 */
}
/*-----------------------------------------------------------------*
@@ -616,20 +625,21 @@ ivas_error pre_proc_ivas(
*-----------------------------------------------------------------*/
/* update old weighted speech buffer - for OL pitch analysis */
- Copy( &old_wsp_fx[L_FRAME], st->old_wsp_fx, L_WSP_MEM );
+ Copy( &old_wsp_fx[L_FRAME], st->old_wsp_fx, L_WSP_MEM ); /* exp(e_old_wsp) */
st->exp_old_wsp = e_old_wsp;
move16();
- st->exp_buf_speech_enc_pe = sub( Q15, *Q_new - 1 );
- move16();
/* set the pointer of the current frame for the ACELP core */
IF( EQ_16( st->L_frame, L_FRAME ) )
{
- *inp_fx = inp_12k8_fx;
+ *inp_fx = inp_12k8_fx; /* Q_old_inp_128k */
+ *Q_new = Q_old_inp_128k;
+ move16();
}
ELSE
{
*inp_fx = inp_16k_fx;
+ Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_128k ) );
}
/* Update VAD hangover frame counter in active frames */
@@ -642,7 +652,7 @@ ivas_error pre_proc_ivas(
test();
IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && vad_hover_flag )
{
- st->hTdCngEnc->burst_ho_cnt = add( st->hTdCngEnc->burst_ho_cnt, 1 );
+ st->hTdCngEnc->burst_ho_cnt = add( st->hTdCngEnc->burst_ho_cnt, 1 ); /* Q0 */
move16();
if ( GT_16( st->hTdCngEnc->burst_ho_cnt, HO_HIST_SIZE ) )
{
@@ -668,21 +678,23 @@ ivas_error pre_proc_ivas(
*--------------------------------------------------------------------*/
ivas_error ivas_compute_core_buffers_fx(
Encoder_State *st, /* i/o: encoder state structure */
- Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame */
- Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz */
- Word16 new_inp_resamp16k_out_fx[], /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
- const Word16 input_frame, /* i : frame length */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 sr_core, /* i : core-coder sampling rate */
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */
- Word32 epsP_fx[M + 1], /* i/o: LP prediction errors */
- Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */
+ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/
+ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/
+ Word16 new_inp_resamp16k_out_fx[], /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_old_inp_16k*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 last_element_mode, /* i : last element mode Q0*/
+ const Word32 sr_core, /* i : core-coder sampling rate Q0*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q14*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
+ Word32 epsP_fx[M + 1], /* i/o: LP prediction errors Q_r*/
+ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
Word16 Q_old_inp_16k,
Word16 Q_r[2],
- Word16 *Q_new )
+ Word16 *Q_new,
+ Word16 downscale_buf_speech_enc_pe /* Q0 */
+)
{
Word16 *inp_16k_fx, *new_inp_16k_fx;
Word16 delay, element_mode;
@@ -709,11 +721,11 @@ ivas_error ivas_compute_core_buffers_fx(
#endif
set16_fx( epsP_h, 0, M + 1 );
set16_fx( epsP_l, 0, M + 1 );
- signal_in_fx = st->input_fx;
+ signal_in_fx = st->input_fx; /* st->q_inp */
- input_Fs = st->input_Fs;
+ input_Fs = st->input_Fs; /* Q0 */
move32();
- element_mode = st->element_mode;
+ element_mode = st->element_mode; /* Q0 */
move16();
lMemRecalc_16k = 0;
@@ -757,15 +769,15 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k );
+ Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k ); /* Q_new - 1 */
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
- Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_MEM_RECALC_16K - L_FILT16k );
+ Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_MEM_RECALC_16K - L_FILT16k ); /* Q_new - 1 */
}
ELSE
{
- Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k );
+ Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k ); /* Q_new - 1 */
}
/*---------------------------------------------------------------*
@@ -781,18 +793,18 @@ ivas_error ivas_compute_core_buffers_fx(
delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS );
move16();
Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx, delay );
- Copy( signal_in_fx, new_inp_16k_fx + delay, input_frame );
- Copy( signal_in_fx + input_frame - shl( delay, 1 ), st->mem_decim16k_fx, shl( delay, 1 ) );
+ Copy( signal_in_fx, new_inp_16k_fx + delay, input_frame ); /* st->q_inp */
+ Copy( signal_in_fx + input_frame - shl( delay, 1 ), st->mem_decim16k_fx, shl( delay, 1 ) ); /* st->q_inp */
}
ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) )
{
- size_modified = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_16k_fx, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_16k_fx, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
- Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX );
+ Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
- size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
@@ -803,9 +815,9 @@ ivas_error ivas_compute_core_buffers_fx(
/* no resampling needed, only delay adjustment to account for the FIR resampling delay */
delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS );
move16();
- Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx - sub( lMemRecalc, add( delay, L_FILT16k ) ), delay );
- Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - add( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) );
- Copy( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ) );
+ Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx - sub( lMemRecalc, add( delay, L_FILT16k ) ), delay ); /* Q(-1) */
+ Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - add( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) ); /* st->q_inp */
+ Copy( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ) ); /* st->q_inp */
}
ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) )
{
@@ -817,30 +829,30 @@ ivas_error ivas_compute_core_buffers_fx(
Word16 length_16k = NS2SA_FX2( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS );
move16();
- Copy( signal_in_fx - lMemRecalc - length_inp - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) );
- size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_16k_fx - lMemRecalc_16k - length_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ Copy( signal_in_fx - lMemRecalc - length_inp - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_16k_fx - lMemRecalc_16k - length_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
- size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX );
IF( lMemRecalc > 0 )
{
- size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
- size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
}
ELSE IF( st->idchan == 0 )
{
/* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */
- Copy( signal_in_fx + input_frame - NS2SA( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) );
+ Copy( signal_in_fx + input_frame - NS2SA( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */
}
/*------------------------------------------------*
@@ -856,12 +868,12 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
/* save input resampled at 16kHz, non-preemphasised.*/
- Copy( new_inp_16k_fx, new_inp_resamp16k_fx, L_FRAME16k );
+ Copy( new_inp_16k_fx, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_old_inp_16k */
IF( EQ_16( st->bwidth, WB ) )
{
- Copy_Scale_sig( new_inp_16k_fx - delay, st->hBWE_FD->old_input_wb_fx, delay, -( Q_old_inp_16k + 1 ) ); /* Scaling to Q(-1) */
- Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - STEREO_DFT_OVL_16k + delay, STEREO_DFT_OVL_16k - delay ); /* Check Q here once. Q should be Q_old_wtda */
+ Copy_Scale_sig( new_inp_16k_fx - delay, st->hBWE_FD->old_input_wb_fx, delay, negate( add( Q_old_inp_16k, 1 ) ) ); /* Scaling to Q(-1) */
+ Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - STEREO_DFT_OVL_16k + delay, sub( STEREO_DFT_OVL_16k, delay ) ); /* Check Q here once. Q should be Q_old_wtda */
}
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
@@ -872,18 +884,18 @@ ivas_error ivas_compute_core_buffers_fx(
test();
IF( EQ_16( st->bwidth, WB ) && st->hBWE_FD != NULL )
{
- Copy_Scale_sig( new_inp_16k_fx + L_FILT16k - delay, st->hBWE_FD->old_input_wb_fx, delay, -( Q_old_inp_16k + 1 ) ); /* Scaling to Q(-1) */
- Copy( new_inp_16k_fx - L_MEM_RECALC_16K, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k + delay, L_MEM_RECALC_16K + L_FILT16k - delay ); /* Check Q here once. Q should be Q_old_wtda */
+ Copy_Scale_sig( new_inp_16k_fx + L_FILT16k - delay, st->hBWE_FD->old_input_wb_fx, delay, negate( add( Q_old_inp_16k, 1 ) ) ); /* Scaling to Q(-1) */
+ Copy( new_inp_16k_fx - L_MEM_RECALC_16K, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k + delay, sub( L_MEM_RECALC_16K + L_FILT16k, delay ) ); /* Check Q here once. Q should be Q_old_wtda */
}
}
ELSE IF( element_mode == IVAS_SCE )
{
/* save input resampled at 16kHz, non-preemphasised */
- Copy( new_inp_16k_fx + L_FILT16k, new_inp_resamp16k_fx, L_FRAME16k );
+ Copy( new_inp_16k_fx + L_FILT16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_old_inp_16k */
IF( EQ_16( st->bwidth, WB ) )
{
- Copy_Scale_sig( new_inp_16k_fx, st->hBWE_FD->old_input_wb_fx + delay - L_FILT16k, L_FILT16k, -( Q_old_inp_16k + 1 ) ); /* Scaling to Q(-1) */
+ Copy_Scale_sig( new_inp_16k_fx, st->hBWE_FD->old_input_wb_fx + delay - L_FILT16k, L_FILT16k, negate( add( Q_old_inp_16k, 1 ) ) ); /* Scaling to Q(-1) */
/* all buffer st->hBWE_FD->old_wtda_swb is correct and does not need to be updated */
}
}
@@ -903,263 +915,171 @@ ivas_error ivas_compute_core_buffers_fx(
test();
if ( st->tcxonly == 0 && !( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) )
{
- st->mem_preemph_enc = new_inp_16k_fx[L_frame_tmp - 1];
+ st->mem_preemph_enc = new_inp_16k_fx[L_frame_tmp - 1]; /* Q(-1) */
move16();
}
test();
test();
- IF( Q_new )
+
+ *Q_new = 0;
+ move16();
+ set32_fx( sig_out, 0, 960 );
+ test();
+ test();
+ if ( ( ( st->bwidth == NB ) || ( st->max_bwidth == NB ) ) && ( GT_32( st->input_Fs, 8000 ) ) )
{
- *Q_new = 0;
- move16();
- set32_fx( sig_out, 0, 960 );
- test();
- test();
- if ( ( ( EQ_16( st->bwidth, NB ) ) || ( EQ_16( st->max_bwidth, NB ) ) ) && ( GT_32( st->input_Fs, 8000 ) ) )
+ headroom = add( headroom, 1 );
+ }
+ test();
+ test();
+ IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
+ {
+ IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- headroom = add( headroom, 1 );
+ Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching Q(-1) */
+
+ st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx; /* Q(-1) */
+ move16();
+ st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1]; /* Q_new - 1 */
+ move16();
+
+ IF( EQ_16( st->L_frame, L_FRAME16k ) )
+ {
+ Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); /* Q(-1) */
+ }
+ // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
+ PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
+ tmp_fx = st->mem_preemph16k_fx;
+ move16();
+
+ // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx);
+ PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx ); /* Q(-1) */
+ preemp_start_idx = new_inp_16k_fx - STEREO_DFT_OVL_16k;
+ move16();
+ preemp_len = STEREO_DFT_OVL_16k + L_FRAME16k;
+ move16();
}
- test();
- test();
- IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
+ ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
- IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
+ IF( EQ_16( last_element_mode, IVAS_CPE_DFT ) )
{
- Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching */
-
st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx;
move16();
- st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1];
+ Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* Q(-1) */
+ // PREEMPH_FX(new_inp_16k_fx - L_MEM_RECALC_16K - (STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k), PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx);
+ PREEMPH_32FX( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx ); /* Q(-1) */
+ preemp_start_idx = new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
move16();
-
- IF( EQ_16( st->L_frame, L_FRAME16k ) )
- {
- Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k );
- }
- // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
- PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) );
- tmp_fx = st->mem_preemph16k_fx;
- move16();
-
- // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx);
- PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx );
- preemp_start_idx = new_inp_16k_fx - STEREO_DFT_OVL_16k;
- move16();
- preemp_len = STEREO_DFT_OVL_16k + L_FRAME16k;
+ preemp_len = STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k;
move16();
}
- ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- IF( EQ_16( last_element_mode, IVAS_CPE_DFT ) )
- {
- st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx;
- move16();
- Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
- // PREEMPH_FX(new_inp_16k_fx - L_MEM_RECALC_16K - (STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k), PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx);
- PREEMPH_32FX( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx );
- preemp_start_idx = new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
- move16();
- preemp_len = STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k;
- move16();
- }
-
- st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1];
- move16();
- /* preemphasise past segment of input signal when switching from MDCT stereo */
- IF( EQ_16( last_element_mode, IVAS_CPE_MDCT ) )
- {
- Word16 length_16k = NS2SA( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS );
- move16();
-
- // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k - length_16k, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx);
- PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx );
- preemp_start_idx = new_inp_16k_fx - lMemRecalc_16k - length_16k;
- preemp_len = length_16k;
- move16();
- }
-
- IF( EQ_16( st->L_frame, L_FRAME16k ) )
- {
- Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) );
- }
- // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
- PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) );
- tmp_fx = st->mem_preemph16k_fx;
- move16();
- // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx);
- PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx );
- IF( preemp_start_idx && preemp_len )
- {
- preemp_len = add( preemp_len, add( L_FRAME16k + L_FILT16k, lMemRecalc_16k ) );
- move16();
- }
- ELSE
- {
- preemp_start_idx = new_inp_16k_fx - lMemRecalc_16k;
- preemp_len = add( L_FRAME16k + L_FILT16k, lMemRecalc_16k );
- move16();
- }
- }
- ELSE IF( EQ_16( element_mode, IVAS_SCE ) )
- {
- // PREEMPH_FX(new_inp_16k_fx, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
- PREEMPH_32FX( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) );
- tmp_fx = st->mem_preemph16k_fx;
- move16();
- // PREEMPH_FX(new_inp_16k_fx + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx);
- PREEMPH_32FX( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx );
- preemp_start_idx = new_inp_16k_fx;
- preemp_len = L_FRAME16k + L_FILT16k;
- move16();
- }
- maximum_abs_32_fx( sig_out, preemp_len, &max_32 );
- inp_max = s_max( extract_h( max_32 ), 1 );
-
- Word16 shift = sub( norm_s( inp_max ), headroom );
- Word16 Q_min, i;
- shift = s_max( shift, 0 );
- shift = s_min( shift, Q_MAX );
- minimum_fx( st->Q_max_16k, L_Q_MEM, &Q_min );
- *Q_new = s_min( shift, Q_min );
+ st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1]; /* Q_new - 1 */
move16();
- IF( inp_max == 0 )
- {
- IF( NE_16( st->last_coder_type, UNVOICED ) )
- {
- *Q_new = s_min( *Q_new, 1 );
- move16();
- }
- }
- FOR( i = L_Q_MEM - 1; i > 0; i-- )
+ /* preemphasise past segment of input signal when switching from MDCT stereo */
+ IF( EQ_16( last_element_mode, IVAS_CPE_MDCT ) )
{
- st->Q_max_16k[i] = st->Q_max_16k[i - 1];
+ Word16 length_16k = NS2SA( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS );
move16();
- }
- st->Q_max_16k[i] = shift;
- move16();
-
- Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new );
- Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new );
- }
- ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */
- {
- IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
- {
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1];
+ // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k - length_16k, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx);
+ PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx ); /* Q(-1) */
+ preemp_start_idx = new_inp_16k_fx - lMemRecalc_16k - length_16k;
+ preemp_len = length_16k;
move16();
}
- ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
+
+ IF( EQ_16( st->L_frame, L_FRAME16k ) )
{
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1];
- move16();
+ Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) ); /* Q_new - 1 */
}
- ELSE IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
+ PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
+ tmp_fx = st->mem_preemph16k_fx;
+ move16();
+ // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx);
+ PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx ); /* Q(-1) */
+ IF( preemp_start_idx && preemp_len )
{
- st->mem_preemph16k_fx = 0;
+ preemp_len = add( preemp_len, add( L_FRAME16k + L_FILT16k, lMemRecalc_16k ) );
move16();
}
- ELSE /* SCE */
+ ELSE
{
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - 1];
+ preemp_start_idx = new_inp_16k_fx - lMemRecalc_16k;
+ preemp_len = add( L_FRAME16k + L_FILT16k, lMemRecalc_16k );
move16();
}
- st->mem_preemph16k_DFT_fx = st->mem_preemph16k_fx;
+ }
+ ELSE IF( EQ_16( element_mode, IVAS_SCE ) )
+ {
+ // PREEMPH_FX(new_inp_16k_fx, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
+ PREEMPH_32FX( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
+ tmp_fx = st->mem_preemph16k_fx;
+ move16();
+ // PREEMPH_FX(new_inp_16k_fx + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx);
+ PREEMPH_32FX( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx ); /* Q(-1) */
+ preemp_start_idx = new_inp_16k_fx;
+ preemp_len = L_FRAME16k + L_FILT16k;
move16();
}
- }
- ELSE
- {
- test();
- test();
- IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
+ maximum_abs_32_fx( sig_out, preemp_len, &max_32 );
+ inp_max = s_max( extract_h( max_32 ), 1 );
+
+ Word16 shift = sub( norm_s( inp_max ), headroom );
+ Word16 Q_min, i;
+ shift = s_max( shift, 0 );
+ shift = s_min( shift, Q_MAX );
+ minimum_fx( st->Q_max_16k, L_Q_MEM, &Q_min );
+ *Q_new = s_min( shift, Q_min );
+ move16();
+ IF( inp_max == 0 )
{
- IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
+ IF( NE_16( st->last_coder_type, UNVOICED ) )
{
- Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching */
-
- st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx;
- move16();
- st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1];
+ *Q_new = s_min( *Q_new, 1 );
move16();
+ }
+ }
- IF( EQ_16( st->L_frame, L_FRAME16k ) )
- {
- Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k );
- }
- PREEMPH_FX( new_inp_16k_fx - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) );
- tmp_fx = st->mem_preemph16k_fx;
- move16();
+ FOR( i = L_Q_MEM - 1; i > 0; i-- )
+ {
+ st->Q_max_16k[i] = st->Q_max_16k[i - 1];
+ move16();
+ }
+ st->Q_max_16k[i] = shift;
+ move16();
- PREEMPH_FX( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx );
- }
- ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- IF( EQ_16( last_element_mode, IVAS_CPE_DFT ) )
- {
- st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx;
- move16();
- Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
- PREEMPH_FX( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx );
- }
-
- st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1];
- move16();
+ Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new );
- /* preemphasise past segment of input signal when switching from MDCT stereo */
- IF( EQ_16( last_element_mode, IVAS_CPE_MDCT ) )
- {
- Word16 length_16k = NS2SA( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS );
- move16();
-
- PREEMPH_FX( new_inp_16k_fx - add( lMemRecalc_16k, length_16k ), PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx );
- }
-
- IF( EQ_16( st->L_frame, L_FRAME16k ) )
- {
- Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) );
- }
- PREEMPH_FX( new_inp_16k_fx - lMemRecalc_16k, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) );
- tmp_fx = st->mem_preemph16k_fx;
- move16();
- PREEMPH_FX( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k, add( lMemRecalc_16k, L_FILT16k ), &tmp_fx );
- }
- ELSE IF( EQ_16( element_mode, IVAS_SCE ) )
- {
- PREEMPH_FX( new_inp_16k_fx, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) );
- tmp_fx = st->mem_preemph16k_fx;
- move16();
- PREEMPH_FX( new_inp_16k_fx + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx );
- }
+ Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new );
+ }
+ ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */
+ {
+ IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
+ {
+ st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */
+ move16();
}
- ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */
+ ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
- IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
- {
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1];
- move16();
- }
- ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
- {
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1];
- move16();
- }
- ELSE IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
- {
- st->mem_preemph16k_fx = 0;
- move16();
- }
- ELSE /* SCE */
- {
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - 1];
- move16();
- }
- st->mem_preemph16k_DFT_fx = st->mem_preemph16k_fx;
+ st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */
+ move16();
+ }
+ ELSE IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ {
+ st->mem_preemph16k_fx = 0;
move16();
}
+ ELSE /* SCE */
+ {
+ st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - 1]; /* Q_new - 1 */
+ move16();
+ }
+ st->mem_preemph16k_DFT_fx = st->mem_preemph16k_fx; /* Q_new - 1 */
+ move16();
}
/*-----------------------------------------------------------------*
@@ -1171,18 +1091,28 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
{
/* update signal buffers */
+ Word16 shift;
+ IF( downscale_buf_speech_enc_pe )
+ {
+ shift = negate( *Q_new );
+ }
+ ELSE
+ {
+ shift = 0;
+ }
+ move16();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc_pe + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k );
+ Copy_Scale_sig( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc_pe + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k, shift ); // Q-1
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
- Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc_pe + L_FRAME16k - lMemRecalc_16k - L_FILT16k, L_FRAME16k + lMemRecalc_16k + L_FILT16k );
+ Copy_Scale_sig( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc_pe + L_FRAME16k - lMemRecalc_16k - L_FILT16k, L_FRAME16k + lMemRecalc_16k + L_FILT16k, shift ); // Q-1
}
ELSE
{
Copy( new_inp_resamp16k_fx, st->buf_speech_enc + L_FRAME16k, L_FRAME16k );
- Copy( new_inp_16k_fx, st->buf_speech_enc_pe + L_FRAME16k, L_FRAME16k );
+ Copy_Scale_sig( new_inp_16k_fx, st->buf_speech_enc_pe + L_FRAME16k, L_FRAME16k, shift ); // Q-1
}
/*--------------------------------------------------------------*
@@ -1192,16 +1122,23 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( st->last_L_frame, L_FRAME ) )
{
/* this is just an approximation, but it is sufficient */
- Copy( st->lsp_old1_fx, st->lspold_enc_fx, M );
+ Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /* Q15 */
}
- 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, Q_new ? *Q_new : 0, Q_r );
+ 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 );
+ }
+ 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 );
+ }
/*--------------------------------------------------------------*
* Compute Weighted Input
*---------------------------------------------------------------*/
- ivas_find_wsp( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k );
+ ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k );
}
/*-----------------------------------------------------------------*
@@ -1215,20 +1152,29 @@ ivas_error ivas_compute_core_buffers_fx(
IF( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM );
+ st->exp_old_inp_16k = 0;
+ move16();
}
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();
+ }
}
ELSE IF( GT_32( input_Fs, 8000 ) )
{
lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 );
Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) );
+ st->exp_old_inp_16k = Q16; // Q-1
+ move16();
}
IF( inp16k_out_fx != NULL )
{
- *inp16k_out_fx = inp_16k_fx;
+ *inp16k_out_fx = inp_16k_fx; /* Q_new - 1 */
}
IF( new_inp_resamp16k_out_fx != NULL )
diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c
index 42e5778162d8ad02f446fcbb9511b6d80bf74153..20f2be0cfd5a168ea7e440c1c7d58d7e7ce4d9ab 100644
--- a/lib_enc/ivas_core_pre_proc_front.c
+++ b/lib_enc/ivas_core_pre_proc_front.c
@@ -78,64 +78,64 @@ static Word16 get_zero_flag( Word32 arr[], Word16 len )
IF( arr[j] != 0 )
{
return 1;
- BREAK;
}
}
return 0;
}
ivas_error pre_proc_front_ivas_fx(
- SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 element_brate, /* i : SCE/CPE element bitrate */
- const Word16 nb_bits_metadata, /* i : number of metadata bits */
- const Word16 input_frame, /* i : frame length */
- const Word16 n, /* i : channel number */
- Word16 old_inp_12k8_fx[], /* o : (Q-1) buffer of old input signal */
- Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q-1 */
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r */
- Word16 *relE_fx, /* o : frame relative energy Q8 */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12 */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12 */
- Word32 epsP_fx[M + 1], /* o : LP prediction errors */
+ SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
+ const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 n, /* i : channel number Q0*/
+ Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 *relE_fx, /* o : frame relative energy Q8*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
Word16 *epsP_fx_q,
- Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15 */
- Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15 */
- Word16 *vad_hover_flag, /* o : VAD hangover flag */
- Word16 *attack_flag, /* o : flag signaling attack */
- Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf) */
- Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf) */
- Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
- Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
+ Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
+ Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
+ Word16 *attack_flag, /* o : flag signaling attack Q0*/
+ Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
+ Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
+ Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
+ Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
Word16 *q_old_wsp,
- Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6 */
- Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15 */
- Word16 *loc_harm, /* o : harmonicity flag */
- Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8 */
- Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
- Word16 *enerBuffer_fx_exp, /* o : energy buffer */
- Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer */
- Word16 *fft_buff_fx_q, /* o : FFT buffer */
- const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12 */
- const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15 */
- const Word16 currFlatness_fx, /* i : flatness parameter Q7 */
- const Word16 tdm_ratio_idx, /* i : Current Ratio_L index */
- Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) */
- Word16 fr_bands_LR_fx_q,
- const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
- Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q) */
+ Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
+ Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
+ Word16 *loc_harm, /* o : harmonicity flag Q0*/
+ Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
+ Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 *enerBuffer_fx_exp, /* o : energy buffer */
+ Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
+ Word16 *fft_buff_fx_q, /* o : FFT buffer */
+ const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
+ const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
+ const Word16 currFlatness_fx, /* i : flatness parameter Q7*/
+ const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
+ Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/
+ Word16 fr_bands_LR_fx_q[CPE_CHANNELS],
+ const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
+ Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/
Word16 lf_E_LR_fx_q,
- const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q) */
+ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/
Word16 band_energies_LR_fx_q,
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
- const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */
- const Word16 force_front_vad, /* i : flag to force VAD decision */
- const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word32 ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
+ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
+ const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
+ Word16 *Q_new
#ifdef DEBUG_MODE_INFO
,
const Word16 ch_idx
@@ -153,21 +153,21 @@ ivas_error pre_proc_front_ivas_fx(
}
Word16 old_inp_12k8_e;
Word16 shift = getScaleFactor16( st->old_inp_12k8_fx, 240 );
- Scale_sig( st->old_inp_12k8_fx, 240, shift );
+ Scale_sig( st->old_inp_12k8_fx, 240, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift );
move16();
shift = getScaleFactor16( old_inp_12k8_fx, 496 );
- Scale_sig( old_inp_12k8_fx, 496, shift );
+ Scale_sig( old_inp_12k8_fx, 496, shift ); /* exp(16 - shift) */
old_inp_12k8_e = sub( Q16, shift );
IF( GT_16( old_inp_12k8_e, st->exp_old_inp_12k8 ) )
{
- Scale_sig( st->old_inp_12k8_fx, 240, sub( st->exp_old_inp_12k8, old_inp_12k8_e ) );
+ Scale_sig( st->old_inp_12k8_fx, 240, sub( st->exp_old_inp_12k8, old_inp_12k8_e ) ); /* exp(old_inp_12k8_e) */
st->exp_old_inp_12k8 = old_inp_12k8_e;
move16();
}
ELSE
{
- Scale_sig( old_inp_12k8_fx, 496, sub( old_inp_12k8_e, st->exp_old_inp_12k8 ) );
+ Scale_sig( old_inp_12k8_fx, 496, sub( old_inp_12k8_e, st->exp_old_inp_12k8 ) ); /* exp(st->exp_old_inp_12k8) */
old_inp_12k8_e = st->exp_old_inp_12k8;
move16();
}
@@ -247,7 +247,7 @@ ivas_error pre_proc_front_ivas_fx(
Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
Word16 res_cod_SNR_M_fx_e[STEREO_DFT_BAND_MAX];
- Word16 band_energies_fx_exp, Qfact_PS, q_lf_E_fx;
+ Word16 Qfact_PS, q_lf_E_fx;
#ifdef DEBUG_MODE_INFO
Word32 *in_buff_temp;
Word16 in_q_temp;
@@ -259,14 +259,14 @@ ivas_error pre_proc_front_ivas_fx(
IF( hSCE != NULL )
{
- Copy_Scale_sig_16_32( hSCE->hCoreCoder[n]->input_fx, hSCE->hCoreCoder[n]->input32_fx, input_frame, sub( Q11, hSCE->hCoreCoder[n]->q_inp ) );
- Copy_Scale_sig_16_32( hSCE->hCoreCoder[n]->input_fx - input_frame, hSCE->hCoreCoder[n]->input32_fx - input_frame, input_frame, sub( Q11, hSCE->hCoreCoder[n]->q_old_inp ) );
+ Copy_Scale_sig_16_32( hSCE->hCoreCoder[n]->input_fx, hSCE->hCoreCoder[n]->input32_fx, input_frame, sub( Q11, hSCE->hCoreCoder[n]->q_inp ) ); /* Q11 */
+ Copy_Scale_sig_16_32( hSCE->hCoreCoder[n]->input_fx - input_frame, hSCE->hCoreCoder[n]->input32_fx - input_frame, input_frame, sub( Q11, hSCE->hCoreCoder[n]->q_old_inp ) ); /* Q11 */
hSCE->hCoreCoder[n]->q_inp32 = Q11;
move16();
- Scale_sig( hSCE->hCoreCoder[n]->input_fx, input_frame, sub( -1, hSCE->hCoreCoder[n]->q_inp ) );
+ Scale_sig( hSCE->hCoreCoder[n]->input_fx, input_frame, sub( -1, hSCE->hCoreCoder[n]->q_inp ) ); /* Q(-1) */
hSCE->hCoreCoder[n]->q_inp = -1;
move16();
- Scale_sig( hSCE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hSCE->hCoreCoder[n]->q_old_inp ) );
+ Scale_sig( hSCE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hSCE->hCoreCoder[n]->q_old_inp ) ); /* Q(-1) */
hSCE->hCoreCoder[n]->q_old_inp = -1;
move16();
@@ -277,14 +277,14 @@ ivas_error pre_proc_front_ivas_fx(
}
ELSE
{
- Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->input_fx, hCPE->hCoreCoder[n]->input32_fx, input_frame, sub( Q11, hCPE->hCoreCoder[n]->q_inp ) );
- Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->input_fx - input_frame, hCPE->hCoreCoder[n]->input32_fx - input_frame, input_frame, sub( Q11, hCPE->hCoreCoder[n]->q_old_inp ) );
+ Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->input_fx, hCPE->hCoreCoder[n]->input32_fx, input_frame, sub( Q11, hCPE->hCoreCoder[n]->q_inp ) ); /* Q11 */
+ Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->input_fx - input_frame, hCPE->hCoreCoder[n]->input32_fx - input_frame, input_frame, sub( Q11, hCPE->hCoreCoder[n]->q_old_inp ) ); /* Q11 */
hCPE->hCoreCoder[n]->q_inp32 = Q11;
move16();
- Scale_sig( hCPE->hCoreCoder[n]->input_fx, input_frame, sub( -1, hCPE->hCoreCoder[n]->q_inp ) );
+ Scale_sig( hCPE->hCoreCoder[n]->input_fx, input_frame, sub( -1, hCPE->hCoreCoder[n]->q_inp ) ); /* Q(-1) */
hCPE->hCoreCoder[n]->q_inp = -1;
move16();
- Scale_sig( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hCPE->hCoreCoder[n]->q_old_inp ) );
+ Scale_sig( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hCPE->hCoreCoder[n]->q_old_inp ) ); /* Q(-1) */
hCPE->hCoreCoder[n]->q_old_inp = -1;
move16();
#ifdef DEBUG_MODE_INFO
@@ -345,7 +345,7 @@ ivas_error pre_proc_front_ivas_fx(
move16();
IF( st->cldfbAnaEnc != NULL )
{
- scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) );
+ scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) ); /* Q11 */
st->cldfbAnaEnc->Q_cldfb_state = Q11;
move16();
}
@@ -356,10 +356,10 @@ ivas_error pre_proc_front_ivas_fx(
#ifndef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
signal_in = hSCE->hCoreCoder[n]->input;
#endif
- signal_in_fx = hSCE->hCoreCoder[n]->input_fx;
- signal32_in_fx = hSCE->hCoreCoder[n]->input32_fx;
+ signal_in_fx = hSCE->hCoreCoder[n]->input_fx; /* hSCE->hCoreCoder[n]->q_inp */
+ signal32_in_fx = hSCE->hCoreCoder[n]->input32_fx; /* hSCE->hCoreCoder[n]->q_inp32 */
element_mode = IVAS_SCE;
- last_element_brate = hSCE->last_element_brate;
+ last_element_brate = hSCE->last_element_brate; /* Q0 */
hStereoClassif = NULL;
lr_vad_enabled = 0;
move16();
@@ -372,10 +372,10 @@ ivas_error pre_proc_front_ivas_fx(
#ifndef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
signal_in = hCPE->hCoreCoder[n]->input;
#endif
- signal_in_fx = hCPE->hCoreCoder[n]->input_fx;
- signal32_in_fx = hCPE->hCoreCoder[n]->input32_fx;
+ signal_in_fx = hCPE->hCoreCoder[n]->input_fx; /* hSCE->hCoreCoder[n]->q_inp */
+ signal32_in_fx = hCPE->hCoreCoder[n]->input32_fx; /* hSCE->hCoreCoder[n]->q_inp32 */
element_mode = hCPE->element_mode;
- last_element_brate = hCPE->last_element_brate;
+ last_element_brate = hCPE->last_element_brate; /* Q0 */
hStereoClassif = hCPE->hStereoClassif;
lr_vad_enabled = 0;
move16();
@@ -399,13 +399,13 @@ ivas_error pre_proc_front_ivas_fx(
IF( hCPE->hStereoTD != NULL )
{
- tdm_SM_last_clas = &hCPE->hStereoTD->tdm_SM_last_clas[n];
- Copy( hCPE->hStereoTD->tdm_SM_last_clas, hCPE->hStereoTD->tdm_SM_last2_clas, CPE_CHANNELS );
+ tdm_SM_last_clas = &hCPE->hStereoTD->tdm_SM_last_clas[n]; /* Q0 */
+ Copy( hCPE->hStereoTD->tdm_SM_last_clas, hCPE->hStereoTD->tdm_SM_last2_clas, CPE_CHANNELS ); /* Q0 */
}
IF( hCPE->hStereoDft != NULL )
{
- res_cod_SNR_M_fx = hCPE->hStereoDft->res_cod_SNR_M_fx;
+ res_cod_SNR_M_fx = hCPE->hStereoDft->res_cod_SNR_M_fx; /* Q(31 - res_cod_SNR_M_fx_e[]) */
}
}
@@ -420,7 +420,7 @@ ivas_error pre_proc_front_ivas_fx(
lMemRecalc_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_NS );
}
- input_Fs = st->input_Fs;
+ input_Fs = st->input_Fs; /* Q0 */
move32();
localVAD_HE_SAD = 0;
@@ -468,9 +468,9 @@ ivas_error pre_proc_front_ivas_fx(
L_look = L_LOOK_12k8; /* lookahead at 12.8kHz */
move16();
- Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( Q_to_be_looked_into, sub( Q15, old_inp_12k8_e ) ) );
+ Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( Q_to_be_looked_into, sub( Q15, old_inp_12k8_e ) ) ); /* Q_to_be_looked_into*/
old_inp_12k8_e = sub( Q15, Q_to_be_looked_into );
- Scale_sig( st->old_inp_12k8_fx, 240, sub( Q_to_be_looked_into, sub( Q15, st->exp_old_inp_12k8 ) ) );
+ Scale_sig( st->old_inp_12k8_fx, 240, sub( Q_to_be_looked_into, sub( Q15, st->exp_old_inp_12k8 ) ) ); /* Q_to_be_looked_into */
st->exp_old_inp_12k8 = sub( Q15, Q_to_be_looked_into );
move16();
new_inp_12k8_fx = old_inp_12k8_fx + L_INP_MEM; /* pointer to new samples of the input signal in 12.8kHz core */
@@ -483,26 +483,26 @@ ivas_error pre_proc_front_ivas_fx(
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8 );
+ Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8 ); /* exp(st->exp_old_inp_12k8) */
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
- Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, sub( L_INP_MEM - L_FILT, lMemRecalc_12k8 ) );
+ Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, sub( L_INP_MEM - L_FILT, lMemRecalc_12k8 ) ); /* exp(st->exp_old_inp_12k8) */
}
ELSE
{
- Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - L_FILT );
+ Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - L_FILT ); /* exp(st->exp_old_inp_12k8) */
}
- Copy( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM );
+ Copy( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM ); /* exp(st->exp_old_wsp) */
*q_old_wsp = sub( Q15, st->exp_old_wsp );
move16();
wsp_fx = old_wsp_fx + L_WSP_MEM; /* pointer to the current frame of weighted signal in 12.8kHz core */
- st->rf_mode = st->Opt_RF_ON;
+ st->rf_mode = st->Opt_RF_ON; /* Q0 */
move16();
- last_core_orig = st->last_core;
+ last_core_orig = st->last_core; /* Q0 */
move16();
/*--------------------------------------------------------------*
@@ -545,13 +545,13 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( EQ_16( element_mode, IVAS_SCE ) )
{
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
- Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX );
+ Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
- new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
@@ -562,30 +562,30 @@ ivas_error pre_proc_front_ivas_fx(
Word16 length_inp = NS2SA_FX2( input_Fs, L_MEM_RECALC_SCH_NS );
Word16 length_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
}
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size );
- Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX );
- Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */
+ Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
IF( lMemRecalc > 0 )
{
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx + sub( input_frame, lMemRecalc ), lMemRecalc, input_Fs, new_inp_12k8_fx + sub( L_FRAME, lMemRecalc_12k8 ), INT_FS_12k8, mem_decim_dummy_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx + sub( L_FRAME, lMemRecalc_12k8 ), new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx + sub( input_frame, lMemRecalc ), lMemRecalc, input_Fs, new_inp_12k8_fx + sub( L_FRAME, lMemRecalc_12k8 ), INT_FS_12k8, mem_decim_dummy_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx + L_FRAME - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
}
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
- new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
}
ELSE /* DFT stereo */
{
/* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */
- Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) );
+ Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* hSCE->hCoreCoder[n]->q_inp */
}
- Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( -1, sub( 15, st->exp_buf_speech_enc ) ) );
+ Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( -1, sub( 15, st->exp_buf_speech_enc ) ) ); /* Q(-1) */
st->exp_buf_speech_enc = 16;
move16();
@@ -593,166 +593,158 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8 );
+ Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8 ); /* Q_to_be_looked_into */
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
- Copy( new_inp_12k8_fx - lMemRecalc_12k8, st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, add( L_FRAME + L_FILT, lMemRecalc_12k8 ) );
+ Copy( new_inp_12k8_fx - lMemRecalc_12k8, st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, add( L_FRAME + L_FILT, lMemRecalc_12k8 ) ); /* Q_to_be_looked_into */
}
ELSE
{
- Copy( new_inp_12k8_fx, st->buf_speech_enc + L_FRAME32k, L_FRAME );
+ Copy( new_inp_12k8_fx, st->buf_speech_enc + L_FRAME32k, L_FRAME ); /* Q_to_be_looked_into */
}
/*------------------------------------------------------------------*
* Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1
*-----------------------------------------------------------------*/
- Word16 Q_new = 1;
+ *Q_new = 0;
move16();
+ set32_fx( sig_out, 0, 960 );
- IF( Q_new )
- {
- Q_new = 0;
- move16();
- set32_fx( sig_out, 0, 960 );
-
- headroom = 1;
- move16();
+ headroom = 1;
+ move16();
- test();
- test();
- IF( ( st->bwidth == NB || st->max_bwidth == NB ) && GT_32( st->input_Fs, 8000 ) )
- {
- headroom = add( headroom, 1 );
- }
+ test();
+ test();
+ if ( ( st->bwidth == NB || st->max_bwidth == NB ) && GT_32( st->input_Fs, 8000 ) )
+ {
+ headroom = add( headroom, 1 );
+ }
- test();
- IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
- {
- Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* memory for TD/DFT stereo switching */
+ test();
+ IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
+ {
+ Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* memory for TD/DFT stereo switching Q_to_be_looked_into*/
- st->mem_preemph_fx = st->mem_preemph_DFT_fx;
- move16();
- st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1];
- move16();
+ st->mem_preemph_fx = st->mem_preemph_DFT_fx; /* Q(-1) */
+ move16();
+ st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* Q_new - 1 */
+ 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;
- 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;
+ move16();
- // PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx );
- PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx );
- preemp_start_idx = new_inp_12k8_fx - STEREO_DFT_OVL_12k8;
- move16();
- preemp_len = STEREO_DFT_OVL_12k8 + L_FRAME;
- move16();
- }
- ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ // PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx );
+ PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx );
+ preemp_start_idx = new_inp_12k8_fx - STEREO_DFT_OVL_12k8;
+ move16();
+ preemp_len = STEREO_DFT_OVL_12k8 + L_FRAME;
+ move16();
+ }
+ ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ {
+ IF( st->idchan == 0 )
{
- IF( st->idchan == 0 )
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
- IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
- {
- st->mem_preemph_fx = st->mem_preemph_DFT_fx;
- move16();
- Copy( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
- // PREEMPH_FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx );
- preemp_start_idx = new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
- 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]; /* == inp_12k8[L_FRAME-1] */
+ st->mem_preemph_fx = st->mem_preemph_DFT_fx;
move16();
- }
-
- /* preemphasise past segment of the Secondary channel input signal when switching from DFT stereo */
- test();
- IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 1 ) )
- {
- Word16 length_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
+ Copy( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* Q(-1) */
+ // PREEMPH_FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx );
+ PREEMPH_32FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx );
+ preemp_start_idx = new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
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 );
- preemp_start_idx = new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8;
- preemp_len = length_12k8;
+ preemp_len = STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT;
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->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* == inp_12k8[L_FRAME-1] Q_new - 1 */
move16();
- // 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 );
-
- test();
- IF( preemp_start_idx && preemp_len )
- {
- preemp_len = add( preemp_len, add( L_FRAME + L_FILT, lMemRecalc_12k8 ) );
- move16();
- }
- ELSE
- {
- preemp_start_idx = new_inp_12k8_fx - lMemRecalc_12k8;
- preemp_len = add( L_FRAME + L_FILT, lMemRecalc_12k8 );
- move16();
- }
}
- ELSE /* IVAS_SCE or IVAS_CPE_MDCT */
+
+ /* preemphasise past segment of the Secondary channel input signal when switching from DFT stereo */
+ test();
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 1 ) )
{
- // 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;
+ Word16 length_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
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 );
- preemp_start_idx = new_inp_12k8_fx;
- preemp_len = L_FRAME + L_FILT;
+ // 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 );
+ preemp_start_idx = new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8;
+ preemp_len = length_12k8;
move16();
}
- maximum_abs_32_fx( sig_out, preemp_len, &max_32 );
- inp_max = s_max( extract_h( max_32 ), 1 );
-
- shift = sub( norm_s( inp_max ), headroom );
- Word16 Q_min;
- shift = s_max( shift, 0 );
- shift = s_min( shift, Q_MAX );
- minimum_fx( st->Q_max, L_Q_MEM, &Q_min );
- Q_new = s_min( shift, Q_min );
+ // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
+ PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
+ dummy_fx = st->mem_preemph_fx; /* Q(-1) */
move16();
- IF( inp_max == 0 )
+ // 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 );
+
+ test();
+ IF( preemp_start_idx && preemp_len )
{
- IF( NE_16( st->last_coder_type, UNVOICED ) )
- {
- Q_new = s_min( Q_new, 1 );
- move16();
- }
+ preemp_len = add( preemp_len, add( L_FRAME + L_FILT, lMemRecalc_12k8 ) ); /* Q0 */
+ move16();
}
-
- FOR( i = L_Q_MEM - 1; i > 0; i-- )
+ ELSE
{
- st->Q_max[i] = st->Q_max[i - 1];
+ preemp_start_idx = new_inp_12k8_fx - lMemRecalc_12k8;
+ preemp_len = add( L_FRAME + L_FILT, lMemRecalc_12k8 ); /* Q) */
move16();
}
- st->Q_max[i] = shift;
+ }
+ 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;
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 );
+ preemp_start_idx = new_inp_12k8_fx;
+ preemp_len = L_FRAME + L_FILT;
+ move16();
+ }
- Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, Q_new );
-
- Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), Q_new );
+ maximum_abs_32_fx( sig_out, preemp_len, &max_32 );
+ inp_max = s_max( extract_h( max_32 ), 1 );
- Q_new = add( Q_new, Q_to_be_looked_into );
+ shift = sub( norm_s( inp_max ), headroom );
+ Word16 Q_min;
+ shift = s_max( shift, 0 );
+ shift = s_min( shift, Q_MAX );
+ minimum_fx( st->Q_max, L_Q_MEM, &Q_min );
+ *Q_new = s_min( shift, Q_min );
+ move16();
+ IF( inp_max == 0 )
+ {
+ IF( NE_16( st->last_coder_type, UNVOICED ) )
+ {
+ *Q_new = s_min( *Q_new, 1 );
+ move16();
+ }
}
- ELSE
+
+ FOR( i = L_Q_MEM - 1; i > 0; i-- )
{
- // See if needed
+ st->Q_max[i] = st->Q_max[i - 1];
+ move16();
}
+ st->Q_max[i] = shift;
+ move16();
+
+ Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new ); /* Q_to_be_looked_into + Q_new */
+
+ Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), *Q_new ); /* Q(-1) */
+
+ *Q_new = add( *Q_new, Q_to_be_looked_into );
+ move16();
+
cldfbScale.hb_scale = cldfbScale.lb_scale;
move16();
@@ -763,56 +755,16 @@ ivas_error pre_proc_front_ivas_fx(
Word16 *lgBin_E_fx;
Word32 PS_fx[128];
Word32 band_energies_fx[2 * NB_BANDS];
+ Word16 q_band_energies;
lgBin_E_fx = NULL;
if ( st != NULL )
{
lgBin_E_fx = &st->lgBin_E_fx[0];
}
- Word16 Scale_fac[2] = { 0 };
- move16();
- move16();
- Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E ) );
- st->q_Bin_E = add( Q_new, Q_SCALE - 2 );
- move16();
- Word32 Le_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_new, QSCALE ) ) ), 1 ), 1 );
- ivas_analy_sp_fx_front( element_mode, hCPE, input_Fs, inp_12k8_fx /*old_inp_12k8_e*/, Q_new, fr_bands_fx, lf_E_fx, &Etot_fx, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, st->Bin_E_old_fx, PS_fx, lgBin_E_fx, band_energies_fx, fft_buff_fx /*, Q_inp_dmx*/ );
- st->q_Bin_E_old = add( Q_new, Q_SCALE - 2 );
- move16();
- fr_bands_fx_q = add( Q_new, QSCALE );
- band_energies_fx_exp = sub( 31, add( Q_new, QSCALE ) );
- Qfact_PS = add( Q_new, QSCALE - 2 );
- q_lf_E_fx = add( Q_new, QSCALE - 2 );
- IF( lgBin_E_fx != NULL )
- {
- Copy_Scale_sig_16_32( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
- }
-
- Word16 min_q = MAX_16, fft_q[2];
- Word16 i_sbfr;
- FOR( i_sbfr = 0; i_sbfr < 2; i_sbfr++ )
- {
- fft_q[i_sbfr] = add( Q_new, Scale_fac[i_sbfr] );
- move16();
- min_q = s_min( min_q, fft_q[i_sbfr] );
- }
- FOR( i_sbfr = 0; i_sbfr < 2; i_sbfr++ )
- {
- Scale_sig( fft_buff_fx + i_sbfr * L_FFT, L_FFT, sub( min_q, fft_q[i_sbfr] ) );
- }
- *fft_buff_fx_q = min_q;
- move16();
-
- Word16 Q_bands0 = 0, Q_bands1 = 0;
- move16();
- move16();
-
- Scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( add( Q_new, QSCALE ), st->hNoiseEst->q_bckr ) );
- st->hNoiseEst->q_bckr = add( Q_new, QSCALE );
- move16();
- Scale_sig32( st->hNoiseEst->enrO_fx, NB_BANDS, sub( add( Q_new, QSCALE ), st->hNoiseEst->q_enrO ) );
- st->hNoiseEst->q_enrO = add( Q_new, QSCALE );
- move16();
+ ivas_analy_sp_fx( element_mode, hCPE, input_Fs, inp_12k8_fx /*old_inp_12k8_e*/, *Q_new, fr_bands_fx, &fr_bands_fx_q, lf_E_fx, &q_lf_E_fx,
+ &Etot_fx, st->min_band, st->max_band, st->Bin_E_fx, &st->q_Bin_E, st->Bin_E_old_fx, &st->q_Bin_E_old, PS_fx, &Qfact_PS,
+ lgBin_E_fx, band_energies_fx, &q_band_energies, fft_buff_fx, fft_buff_fx_q );
IF( hStereoClassif != NULL )
{
@@ -823,10 +775,10 @@ ivas_error pre_proc_front_ivas_fx(
}
ELSE
{
- hStereoClassif->silence_flag = sub( hStereoClassif->silence_flag, 1 );
+ hStereoClassif->silence_flag = sub( hStereoClassif->silence_flag, 1 ); /* Q0 */
move16();
}
- hStereoClassif->silence_flag = s_max( 0, hStereoClassif->silence_flag );
+ hStereoClassif->silence_flag = s_max( 0, hStereoClassif->silence_flag ); /* Q0 */
move16();
}
@@ -852,15 +804,32 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
- st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), Q_new, NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float
+ Word16 scale = add( L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ), st->hNoiseEst->q_bckr );
+ scale = s_min( scale, add( L_norm_arr( st->hNoiseEst->enrO_fx, NB_BANDS ), st->hNoiseEst->q_enrO ) );
+ scale = s_min( scale, fr_bands_fx_q );
+
+ scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) );
+ st->hNoiseEst->q_bckr = scale;
+ move16();
+
+ scale_sig32( st->hNoiseEst->enrO_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_enrO ) );
+ st->hNoiseEst->q_enrO = scale;
+ move16();
+
+ scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( scale, fr_bands_fx_q ) );
+ fr_bands_fx_q = scale;
+ move16();
+
+ st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, fr_bands_fx_q, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD,
+ &( st->flag_noisy_speech_snr ), NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float
move16();
test();
IF( EQ_16( force_front_vad, 1 ) || EQ_16( front_vad_flag, 1 ) )
{
/* overwrite VAD decision with front-VAD decision if external VAD is set to 1*/
- st->vad_flag = front_vad_flag;
- st->localVAD = front_vad_flag;
+ st->vad_flag = front_vad_flag; /* Q0 */
+ st->localVAD = front_vad_flag; /* Q0 */
move16();
move16();
}
@@ -869,7 +838,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL )
{
- *vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, vad_hover_flag, NULL, NULL );
+ *vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, vad_hover_flag, NULL, NULL ); /* Q0 */
move16();
}
ELSE
@@ -877,14 +846,14 @@ ivas_error pre_proc_front_ivas_fx(
/* This only applies to st->idchan==0 now */
/* Add down mix stereo activity to LR vad_flag_dtx */
test();
- *vad_flag_dtx = *vad_flag_dtx || st->vad_flag;
+ *vad_flag_dtx = *vad_flag_dtx || st->vad_flag; /* Q0 */
move16();
/* Determine hangover flag status based on LR localVAD and downmix localVAD */
test();
test();
- *vad_hover_flag = *vad_flag_dtx && !( LR_localVAD || st->localVAD );
+ *vad_hover_flag = *vad_flag_dtx && !( LR_localVAD || st->localVAD ); /* Q0 */
move16();
}
@@ -892,7 +861,7 @@ ivas_error pre_proc_front_ivas_fx(
if ( EQ_16( force_front_vad, 1 ) || EQ_16( front_vad_dtx_flag, 1 ) )
{
/* overwrite VAD decision with front-VAD decision if external VAD is set to 1*/
- *vad_flag_dtx = front_vad_dtx_flag;
+ *vad_flag_dtx = front_vad_dtx_flag; /* Q0 */
move16();
}
@@ -928,7 +897,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
if ( EQ_16( st->idchan, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->tdm_LRTD_flag, 1 ) && GE_16( st->bits_frame_channel, IVAS_16k4 / FRAMES_PER_SEC ) )
{
- st->bwidth = hCPE->hCoreCoder[0]->bwidth;
+ st->bwidth = hCPE->hCoreCoder[0]->bwidth; /* Q0 */
move16();
}
@@ -938,43 +907,52 @@ ivas_error pre_proc_front_ivas_fx(
* Correlation correction as a function of total noise level
*----------------------------------------------------------------*/
- Le_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_new, QSCALE ) ) ), 1 ), 1 );
-
- noise_est_down_fx( fr_bands_fx, st->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band, &st->hNoiseEst->totalNoise_fx, Etot_fx, &st->hNoiseEst->Etot_last_fx, &st->hNoiseEst->Etot_v_h2_fx, Q_new, Le_min_scaled );
- st->hNoiseEst->q_bckr = add( Q_new, QSCALE );
+ noise_est_down_ivas_fx( fr_bands_fx, fr_bands_fx_q, st->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band,
+ &st->hNoiseEst->totalNoise_fx, Etot_fx, &st->hNoiseEst->Etot_last_fx, &st->hNoiseEst->Etot_v_h2_fx );
+ q_tmpN = fr_bands_fx_q;
+ q_tmpE = fr_bands_fx_q;
+ move16();
move16();
test();
IF( lr_vad_enabled && st->idchan == 0 )
{
- Scale_sig32( hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, NB_BANDS, sub( add( fr_bands_LR_fx_q, Q_SCALE ), hCPE->hFrontVad[0]->hNoiseEst->q_bckr ) );
- Scale_sig32( hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, NB_BANDS, sub( add( fr_bands_LR_fx_q, Q_SCALE ), hCPE->hFrontVad[1]->hNoiseEst->q_bckr ) );
+ scale = add( L_norm_arr( hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, NB_BANDS ), hCPE->hFrontVad[0]->hNoiseEst->q_bckr );
+ scale = s_min( scale, add( L_norm_arr( hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, NB_BANDS ), hCPE->hFrontVad[1]->hNoiseEst->q_bckr ) );
+ scale = s_min( scale, add( L_norm_arr( fr_bands_LR_fx[0], 2 * NB_BANDS ), fr_bands_LR_fx_q[0] ) );
+ scale = s_min( scale, add( L_norm_arr( fr_bands_LR_fx[1], 2 * NB_BANDS ), fr_bands_LR_fx_q[1] ) );
- Word32 Le_min_scaled0, Le_min_scaled1;
- Le_min_scaled0 = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_bands0, QSCALE ) ) ), 1 ), 1 );
- noise_est_down_fx( fr_bands_LR_fx[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, tmpN_LR_fx[0], tmpE_LR_fx[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, Etot_LR_fx[0], &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx, Q_bands0, Le_min_scaled0 );
- hCPE->hFrontVad[0]->hNoiseEst->q_bckr = add( Q_bands0, QSCALE );
+ scale_sig32( fr_bands_LR_fx[0], 2 * NB_BANDS, sub( scale, fr_bands_LR_fx_q[0] ) );
+ fr_bands_LR_fx_q[0] = scale;
move16();
- Le_min_scaled1 = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_bands1, QSCALE ) ) ), 1 ), 1 );
- noise_est_down_fx( fr_bands_LR_fx[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, tmpN_LR_fx[1], tmpE_LR_fx[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, Etot_LR_fx[1], &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx, Q_bands1, Le_min_scaled1 );
- hCPE->hFrontVad[1]->hNoiseEst->q_bckr = add( Q_bands1, QSCALE );
+ scale_sig32( fr_bands_LR_fx[1], 2 * NB_BANDS, sub( scale, fr_bands_LR_fx_q[1] ) );
+ fr_bands_LR_fx_q[1] = scale;
move16();
- corr_shiftL_fx = correlation_shift_fx( hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx );
- corr_shiftR_fx = correlation_shift_fx( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx );
- q_tmpN_LR[0] = q_tmpE_LR[0] = add( Q_bands0, QSCALE );
+ scale_sig32( hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[0]->hNoiseEst->q_bckr ) );
+ hCPE->hFrontVad[0]->hNoiseEst->q_bckr = scale;
move16();
+ scale_sig32( hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[1]->hNoiseEst->q_bckr ) );
+ hCPE->hFrontVad[1]->hNoiseEst->q_bckr = scale;
+ move16();
+
+ noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, tmpN_LR_fx[0], tmpE_LR_fx[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, Etot_LR_fx[0], &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx );
+ noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, tmpN_LR_fx[1], tmpE_LR_fx[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, Etot_LR_fx[1], &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx );
+
+ q_tmpN_LR[0] = q_tmpE_LR[0] = scale;
move16();
- q_tmpN_LR[1] = q_tmpE_LR[1] = add( Q_bands1, QSCALE );
move16();
+ q_tmpN_LR[1] = q_tmpE_LR[1] = scale;
move16();
+ move16();
+
+ corr_shiftL_fx = correlation_shift_fx( hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx ); // Q15
+ corr_shiftR_fx = correlation_shift_fx( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx ); // Q15
}
- q_tmpN = q_tmpE = add( Q_new, QSCALE );
- move16();
- *relE_fx = sub( Etot_fx, st->lp_speech_fx );
+ *relE_fx = sub( Etot_fx, st->lp_speech_fx ); // Q8
move16();
- corr_shift_fx = correlation_shift_fx( st->hNoiseEst->totalNoise_fx );
+ corr_shift_fx = correlation_shift_fx( st->hNoiseEst->totalNoise_fx ); /* Q15 */
/*----------------------------------------------------------------*
* FD-CNG Noise Estimator
@@ -1003,7 +981,7 @@ ivas_error pre_proc_front_ivas_fx(
st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( 31, normmsPeriodog_fx );
move16();
move16();
- Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx );
+ Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx ); /* exp(st->hFdCngEnc->msPeriodog_fx_exp - normmsPeriodog_fx) */
st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, normmsPeriodog_fx );
Word16 msNoiseEst_Q = Q31;
move16();
@@ -1013,7 +991,7 @@ ivas_error pre_proc_front_ivas_fx(
{
msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_fx, NPART );
}
- Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q );
+ Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */
st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q );
move16();
perform_noise_estimation_enc_ivas_fx( band_energies_LR_fx, sub( Q31, band_energies_LR_fx_q ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE );
@@ -1025,9 +1003,9 @@ ivas_error pre_proc_front_ivas_fx(
move16();
shift = getScaleFactor32( band_energies_fx, 2 * NB_BANDS );
scale_sig32( band_energies_fx, 2 * NB_BANDS, shift );
- band_energies_fx_exp = sub( band_energies_fx_exp, shift );
+ q_band_energies = add( q_band_energies, shift );
- zero_flag = get_zero_flag( st->hFdCngEnc->msPeriodog_fx, NPART );
+ zero_flag = get_zero_flag( st->hFdCngEnc->msPeriodog_fx, NPART ); /* Q0 */
IF( zero_flag )
{
normmsPeriodog_fx = getScaleFactor32( st->hFdCngEnc->msPeriodog_fx, NPART );
@@ -1036,20 +1014,20 @@ ivas_error pre_proc_front_ivas_fx(
st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( 31, normmsPeriodog_fx );
move16();
move16();
- Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx );
- st->hFdCngEnc->msPeriodog_fx_exp = st->hFdCngEnc->msPeriodog_fx_exp - normmsPeriodog_fx;
+ Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx ); /* exp(st->hFdCngEnc->msPeriodog_fx_exp - normmsPeriodog_fx)*/
+ st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, normmsPeriodog_fx );
move16();
Word16 msNoiseEst_Q = Q31;
move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_fx, NPART );
+ zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_fx, NPART ); /* Q0 */
IF( zero_flag )
{
msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_fx, NPART );
}
- Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q );
- st->hFdCngEnc->msNoiseEst_fx_exp = st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q;
+ Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */
+ st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q );
move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN );
+ zero_flag = get_zero_flag( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN ); /* Q0 */
Word16 normmsperiodog = 31;
move16();
IF( zero_flag )
@@ -1059,7 +1037,7 @@ ivas_error pre_proc_front_ivas_fx(
st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog = sub( 31, normmsperiodog );
move16();
- perform_noise_estimation_enc_ivas_fx( band_energies_fx, band_energies_fx_exp, enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE );
+ perform_noise_estimation_enc_ivas_fx( band_energies_fx, sub( Q31, q_band_energies ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE );
}
}
}
@@ -1084,14 +1062,14 @@ ivas_error pre_proc_front_ivas_fx(
st->cng_type = LP_CNG;
move16();
}
- dtx_ivas_fx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, Q_new );
+ dtx_ivas_fx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new );
test();
test();
IF( hCPE != NULL && hCPE->hStereoDft != NULL && EQ_32( st->core_brate, SID_2k40 ) )
{
/* Add another period of expected xcorr updates */
- hCPE->hStereoDft->expectedNumUpdates = add( hCPE->hStereoDft->expectedNumUpdates, st->hDtxEnc->max_SID );
+ hCPE->hStereoDft->expectedNumUpdates = add( hCPE->hStereoDft->expectedNumUpdates, st->hDtxEnc->max_SID ); /* Q0 */
move16();
}
@@ -1107,17 +1085,17 @@ ivas_error pre_proc_front_ivas_fx(
IF( EQ_16( element_mode, IVAS_SCE ) )
{
- total_brate = st->total_brate;
+ total_brate = st->total_brate; /* Q0 */
move32();
}
ELSE
{
- total_brate = imult3216( FRAMES_PER_SEC, st->bits_frame_nominal );
+ total_brate = imult3216( FRAMES_PER_SEC, st->bits_frame_nominal ); /* Q0 */
}
configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate );
IF( hCPE != NULL )
{
- st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 );
+ st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 ); /* Q0 */
move32();
}
}
@@ -1132,29 +1110,29 @@ ivas_error pre_proc_front_ivas_fx(
IF( zero_flag )
{
msPeriodog_fx_Q = getScaleFactor32( st->hFdCngEnc->msPeriodog_fx, NPART );
- scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, msPeriodog_fx_Q );
+ scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, msPeriodog_fx_Q ); /* exp(st->hFdCngEnc->msPeriodog_fx_exp - msPeriodog_fx_Q) */
st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, msPeriodog_fx_Q );
move16();
}
Word16 energy_ho_fx_Q = Q31;
move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->energy_ho_fx, NPART );
+ zero_flag = get_zero_flag( st->hFdCngEnc->energy_ho_fx, NPART ); /* Q0 */
IF( zero_flag )
{
energy_ho_fx_Q = getScaleFactor32( st->hFdCngEnc->energy_ho_fx, NPART );
- scale_sig32( st->hFdCngEnc->energy_ho_fx, NPART, energy_ho_fx_Q );
+ scale_sig32( st->hFdCngEnc->energy_ho_fx, NPART, energy_ho_fx_Q ); /* exp(st->hFdCngEnc->energy_ho_fx_exp - energy_ho_fx_Q) */
st->hFdCngEnc->energy_ho_fx_exp = sub( st->hFdCngEnc->energy_ho_fx_exp, energy_ho_fx_Q );
move16();
}
Word16 msNoiseEst_old_Q = Q31;
move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
+ zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); /* Q0 */
IF( zero_flag )
{
msNoiseEst_old_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
- scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_old_Q );
+ scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_old_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_old_Q) */
st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_old_Q );
move16();
}
@@ -1175,16 +1153,16 @@ ivas_error pre_proc_front_ivas_fx(
Word16 Q_new_loc;
Word16 Q_r[2];
set16_fx( Q_r, 0, 2 );
- Q_new_loc = Q_new;
+ Q_new_loc = *Q_new;
move16();
- alw_pitch_lag_12k8[0] = st->old_pitch_la;
+ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */
move16();
- alw_pitch_lag_12k8[1] = st->old_pitch_la;
+ alw_pitch_lag_12k8[1] = st->old_pitch_la; /* Q0 */
move16();
- alw_voicing_fx[0] = st->voicing_fx[2];
+ alw_voicing_fx[0] = st->voicing_fx[2]; /* Q15 */
move16();
- alw_voicing_fx[1] = st->voicing_fx[2];
+ alw_voicing_fx[1] = st->voicing_fx[2]; /* Q15 */
move16();
i = 0;
@@ -1211,9 +1189,9 @@ ivas_error pre_proc_front_ivas_fx(
lsp2lsf_fx( lsp_new_fx, lsf_new_fx, M, INT_FS_12k8 );
- stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old1_fx, 0, L_FRAME );
+ stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old1_fx, 0, L_FRAME ); /* Q15 */
- Copy( lsf_new_fx, st->lsf_old1_fx, M );
+ Copy( lsf_new_fx, st->lsf_old1_fx, M ); /* Q2.56 */
test();
IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
@@ -1223,8 +1201,8 @@ ivas_error pre_proc_front_ivas_fx(
* to reuse the primary channel LP coefficients in the secondary channel
*----------------------------------------------------------------*/
Word32 speech_buff[L_FRAME + M];
- Copy_Scale_sig_16_32( inp_12k8_fx - M, speech_buff, L_FRAME + M, Q12 );
- hCPE->hStereoTD->tdm_lp_reuse_flag = tdm_lp_comparison_fx( hCPE->hStereoTD, hCPE->hStereoClassif, st, &speech_buff[0], tdm_A_PCh_fx, A_fx, M, tdm_lsp_new_PCh_fx, lsp_new_fx, L_FRAME, L_sub( element_brate, imult3216( FRAMES_PER_SEC, nb_bits_metadata ) ), add( Q_new, 12 ) );
+ Copy_Scale_sig_16_32( inp_12k8_fx - M, speech_buff, L_FRAME + M, Q12 ); /* Q_new + 12 */
+ hCPE->hStereoTD->tdm_lp_reuse_flag = tdm_lp_comparison_fx( hCPE->hStereoTD, hCPE->hStereoClassif, st, &speech_buff[0], tdm_A_PCh_fx, A_fx, M, tdm_lsp_new_PCh_fx, lsp_new_fx, L_FRAME, L_sub( element_brate, imult3216( FRAMES_PER_SEC, nb_bits_metadata ) ), add( *Q_new, 12 ) ); /* Q0 */
move16();
}
@@ -1235,14 +1213,14 @@ ivas_error pre_proc_front_ivas_fx(
* 1/4 pitch precision improvement
*----------------------------------------------------------------*/
- st->mem_wsp_fx = shl( st->mem_wsp_fx, sub( Q_new, st->mem_wsp_q ) );
- st->mem_wsp_q = Q_new;
+ st->mem_wsp_fx = shl( st->mem_wsp_fx, sub( *Q_new, st->mem_wsp_q ) ); /* Q_new */
+ st->mem_wsp_q = *Q_new;
move16();
move16();
- ivas_find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
+ ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
- Word16 Q_wsp = Q_new;
+ Word16 Q_wsp = *Q_new;
move16();
IF( st->vad_flag == 0 )
{
@@ -1252,8 +1230,8 @@ ivas_error pre_proc_front_ivas_fx(
old_pitch1 = st->pitch[1];
move16();
- Word16 shift1 = getScaleFactor16( old_wsp_fx, L_WSP_MEM );
- Word16 shift2 = getScaleFactor16( wsp_fx, L_WSP - L_WSP_MEM );
+ Word16 shift1 = norm_arr( old_wsp_fx, L_WSP_MEM );
+ Word16 shift2 = norm_arr( wsp_fx, L_WSP - L_WSP_MEM );
maximum_abs_16_fx( old_wsp_fx, L_WSP_MEM, &shift );
if ( !shift )
{
@@ -1267,111 +1245,169 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
shift = s_min( add( *q_old_wsp, shift1 ), add( Q_wsp, shift2 ) );
- Scale_sig( old_wsp_fx, L_WSP_MEM, sub( shift, *q_old_wsp ) );
- Scale_sig( wsp_fx, L_WSP - L_WSP_MEM, sub( shift, Q_wsp ) );
+ shift = s_min( shift, add( norm_arr( st->mem_decim2_fx, 3 ), st->Q_old_wsp2 ) );
+ shift = s_min( shift, add( norm_arr( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ), st->Q_old_wsp2 ) );
+ scale_sig( old_wsp_fx, L_WSP_MEM, sub( shift, *q_old_wsp ) );
+ scale_sig( wsp_fx, L_WSP - L_WSP_MEM, sub( shift, Q_wsp ) );
+
*q_old_wsp = shift;
move16();
Q_wsp = shift;
move16();
- Scale_sig( st->mem_decim2_fx, 3, sub( Q_wsp, st->Q_old_wsp2 ) ); // Q( mem_decim ) = Q( old_wsp2 )
- Scale_sig( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM, sub( Q_wsp, st->Q_old_wsp2 ) );
+ scale_sig( st->mem_decim2_fx, 3, sub( Q_wsp, st->Q_old_wsp2 ) ); // Q( mem_decim ) = Q( old_wsp2 )
+ scale_sig( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM, sub( Q_wsp, st->Q_old_wsp2 ) ); // Q_wsp
+
st->Q_old_wsp2 = Q_wsp;
move16();
pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx,
- &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, *relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR );
+ &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, *relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q_wsp );
/* Updates for adaptive lag window memory */
- st->old_pitch_la = st->pitch[2];
+ st->old_pitch_la = st->pitch[2]; /* Q0 */
+ move16();
+
+ /*Scaling to avoid 0 values*/
+ shift = L_norm_arr( st->hNoiseEst->enrO_fx, NB_BANDS );
+ scale_sig32( st->hNoiseEst->enrO_fx, NB_BANDS, shift );
+ st->hNoiseEst->q_enrO = add( st->hNoiseEst->q_enrO, shift );
move16();
test();
IF( lr_vad_enabled && st->idchan == 0 )
{
- FOR( i = 0; i < 2; i++ )
+ /*Scaling to avoid 0 values*/
+ FOR( Word16 j = 0; j < 2; j++ )
{
- shift = getScaleFactor32( tmpN_LR_fx[i], NB_BANDS );
- scale_sig32( tmpN_LR_fx[i], NB_BANDS, shift );
- q_tmpN_LR[i] = add( q_tmpN_LR[i], shift );
- move16();
-
- shift = getScaleFactor32( tmpE_LR_fx[i], NB_BANDS );
- scale_sig32( tmpE_LR_fx[i], NB_BANDS, shift );
- q_tmpE_LR[i] = add( q_tmpE_LR[i], shift );
+ shift = L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->enrO_fx, NB_BANDS );
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->enrO_fx, NB_BANDS, shift );
+ hCPE->hFrontVad[j]->hNoiseEst->q_enrO = add( hCPE->hFrontVad[j]->hNoiseEst->q_enrO, shift );
move16();
}
}
- shift = getScaleFactor32( tmpN_fx, NB_BANDS );
- scale_sig32( tmpN_fx, NB_BANDS, shift );
- q_tmpN = add( q_tmpN, shift );
- shift = getScaleFactor32( tmpE_fx, NB_BANDS );
- scale_sig32( tmpE_fx, NB_BANDS, shift );
- q_tmpE = add( q_tmpE, shift );
- shift = getScaleFactor32( lf_E_fx, 2 * VOIC_BINS );
- scale_sig32( lf_E_fx, 2 * VOIC_BINS, shift );
- q_lf_E_fx = add( q_lf_E_fx, shift );
+ shift = sub( norm_arr( old_wsp_fx, L_WSP ), 3 );
+ scale_sig( old_wsp_fx, L_WSP, shift );
- shift = sub( getScaleFactor16( old_wsp_fx, L_WSP ), 3 );
- Scale_sig( old_wsp_fx, L_WSP, shift );
*q_old_wsp = add( *q_old_wsp, shift );
move16();
Q_wsp = *q_old_wsp;
move16();
+
Word16 q_fr_bands = Q30;
move16();
- q_fr_bands = s_min( q_fr_bands, q_tmpN );
- q_fr_bands = s_min( q_fr_bands, q_tmpE );
- q_fr_bands = s_min( q_fr_bands, sub( fr_bands_fx_q, 4 ) /* needs 4 gaurd bits for summation */ );
- q_fr_bands = s_min( q_fr_bands, st->hNoiseEst->q_bckr );
- q_fr_bands = s_min( q_fr_bands, st->hNoiseEst->fr_bands_fx_q );
- q_fr_bands = s_min( q_fr_bands, st->hNoiseEst->ave_enr_q );
- q_fr_bands = s_min( q_fr_bands, add( q_lf_E_fx, 2 ) );
+
+ shift = L_norm_arr( tmpN_fx, NB_BANDS );
+ q_fr_bands = s_min( q_fr_bands, add( q_tmpN, shift ) );
+ shift = L_norm_arr( tmpE_fx, NB_BANDS );
+ q_fr_bands = s_min( q_fr_bands, add( q_tmpE, shift ) );
+ shift = L_norm_arr( fr_bands_fx, 2 * NB_BANDS );
+ q_fr_bands = s_min( q_fr_bands, sub( add( fr_bands_fx_q, shift ), 4 ) /* needs 4 gaurd bits for summation */ );
+ shift = L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS );
+ q_fr_bands = s_min( q_fr_bands, add( st->hNoiseEst->q_bckr, shift ) );
+ shift = s_min( L_norm_arr( st->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->fr_bands2_fx, NB_BANDS ) );
+ q_fr_bands = s_min( q_fr_bands, add( st->hNoiseEst->fr_bands_fx_q, shift ) );
+ shift = s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) );
+ q_fr_bands = s_min( q_fr_bands, add( st->hNoiseEst->ave_enr_q, shift ) );
+ shift = L_norm_arr( lf_E_fx, 2 * VOIC_BINS );
+ q_fr_bands = s_min( q_fr_bands, add( add( q_lf_E_fx, shift ), 2 ) );
test();
IF( lr_vad_enabled && st->idchan == 0 )
{
+ shift = s_min( L_norm_arr( lf_E_LR_fx[0], 2 * VOIC_BINS ), L_norm_arr( lf_E_LR_fx[1], 2 * VOIC_BINS ) );
+ q_fr_bands = s_min( q_fr_bands, add( add( lf_E_LR_fx_q, shift ), 2 ) );
FOR( Word16 j = 0; j < 2; j++ )
{
- q_fr_bands = s_min( q_fr_bands, add( lf_E_LR_fx_q, 2 ) );
- q_fr_bands = s_min( q_fr_bands, q_tmpN_LR[j] );
- q_fr_bands = s_min( q_fr_bands, q_tmpE_LR[j] );
- q_fr_bands = s_min( q_fr_bands, fr_bands_LR_fx_q );
- q_fr_bands = s_min( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->q_bckr );
- q_fr_bands = s_min( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q );
- q_fr_bands = s_min( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q );
+ shift = L_norm_arr( fr_bands_LR_fx[j], 2 * NB_BANDS );
+ q_fr_bands = s_min( q_fr_bands, add( fr_bands_LR_fx_q[j], shift ) );
+ shift = L_norm_arr( tmpN_LR_fx[j], NB_BANDS );
+ q_fr_bands = s_min( q_fr_bands, add( q_tmpN_LR[j], shift ) );
+ shift = L_norm_arr( tmpE_LR_fx[j], NB_BANDS );
+ q_fr_bands = s_min( q_fr_bands, add( q_tmpE_LR[j], shift ) );
+ shift = L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS );
+ q_fr_bands = s_min( q_fr_bands, add( hCPE->hFrontVad[j]->hNoiseEst->q_bckr, shift ) );
+ shift = s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS ) );
+ q_fr_bands = s_min( q_fr_bands, add( hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q, shift ) );
+ shift = s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS ) );
+ q_fr_bands = s_min( q_fr_bands, add( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q, shift ) );
}
}
- Word16 q_inp_12k8 = Q_new; // inp_12k8_fx
- move16();
- scale_sig32( lf_E_fx, 2 * VOIC_BINS, sub( sub( q_fr_bands, 2 ), q_lf_E_fx ) );
- q_lf_E_fx = sub( q_fr_bands, 2 );
scale_sig32( tmpN_fx, NB_BANDS, sub( q_fr_bands, q_tmpN ) );
q_tmpN = q_fr_bands;
+ move16();
scale_sig32( tmpE_fx, NB_BANDS, sub( q_fr_bands, q_tmpE ) );
q_tmpE = q_fr_bands;
+ move16();
+
+ scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( q_fr_bands, fr_bands_fx_q ) );
+ fr_bands_fx_q = q_fr_bands;
+ move16();
+
+ scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->q_bckr ) );
+ st->hNoiseEst->q_bckr = q_fr_bands;
+ move16();
+
+ scale_sig32( st->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->fr_bands_fx_q ) );
+ scale_sig32( st->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->fr_bands_fx_q ) );
+ st->hNoiseEst->fr_bands_fx_q = q_fr_bands;
+ move16();
+
+ scale_sig32( st->hNoiseEst->ave_enr_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->ave_enr_q ) );
+ scale_sig32( st->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->ave_enr_q ) );
+ st->hNoiseEst->ave_enr_q = q_fr_bands;
+ move16();
+
+ scale_sig32( lf_E_fx, 2 * VOIC_BINS, sub( sub( q_fr_bands, 2 ), q_lf_E_fx ) );
+ q_lf_E_fx = sub( q_fr_bands, 2 );
test();
IF( lr_vad_enabled && st->idchan == 0 )
{
- FOR( i = 0; i < 2; i++ )
+ FOR( Word16 j = 0; j < 2; j++ )
{
- scale_sig32( tmpN_LR_fx[i], NB_BANDS, sub( q_fr_bands, q_tmpN_LR[i] ) );
- q_tmpN_LR[i] = q_fr_bands;
+ scale_sig32( lf_E_LR_fx[j], 2 * VOIC_BINS, sub( sub( q_fr_bands, 2 ), lf_E_LR_fx_q ) );
+ scale_sig32( fr_bands_LR_fx[j], 2 * NB_BANDS, sub( q_fr_bands, fr_bands_LR_fx_q[j] ) );
+
+ scale_sig32( tmpN_LR_fx[j], NB_BANDS, sub( q_fr_bands, q_tmpN_LR[j] ) );
+ q_tmpN_LR[j] = q_fr_bands;
move16();
- scale_sig32( tmpE_LR_fx[i], NB_BANDS, sub( q_fr_bands, q_tmpE_LR[i] ) );
- q_tmpE_LR[i] = q_fr_bands;
+ scale_sig32( tmpE_LR_fx[j], NB_BANDS, sub( q_fr_bands, q_tmpE_LR[j] ) );
+ q_tmpE_LR[j] = q_fr_bands;
+ move16();
+
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->q_bckr ) );
+ hCPE->hFrontVad[j]->hNoiseEst->q_bckr = q_fr_bands;
+ move16();
+
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q ) );
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q ) );
+ hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q = q_fr_bands;
+ move16();
+
+ FOR( Word16 k = 0; k < NB_BANDS; k++ )
+ {
+ hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx[k] = L_max( 1, hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx[k] );
+ move32();
+ hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx[k] = L_max( 1, hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx[k] );
+ move32();
+ }
+
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q ) );
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q ) );
+ hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q = q_fr_bands;
+ move16();
+ fr_bands_LR_fx_q[j] = q_fr_bands;
move16();
}
+ lf_E_LR_fx_q = q_fr_bands;
+ move16();
}
- scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( q_fr_bands, fr_bands_fx_q ) );
- fr_bands_fx_q = q_fr_bands;
- move16();
- Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) );
+ Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) ); /* Q7 */
/* Detection of very short stable pitch period */
StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx );
@@ -1409,18 +1445,6 @@ ivas_error pre_proc_front_ivas_fx(
* Update estimated noise energy and voicing cut-off frequency
*-----------------------------------------------------------------*/
- scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->q_bckr ) );
- st->hNoiseEst->q_bckr = q_fr_bands;
- move16();
- scale_sig32( st->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->fr_bands_fx_q ) );
- scale_sig32( st->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->fr_bands_fx_q ) );
- st->hNoiseEst->fr_bands_fx_q = q_fr_bands;
- move16();
- scale_sig32( st->hNoiseEst->ave_enr_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->ave_enr_q ) );
- scale_sig32( st->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->ave_enr_q ) );
- st->hNoiseEst->ave_enr_q = q_fr_bands;
- move16();
-
FOR( Word16 k = 0; k < NB_BANDS; k++ )
{
fr_bands_fx[k] = L_max( 1, fr_bands_fx[k] );
@@ -1429,83 +1453,17 @@ ivas_error pre_proc_front_ivas_fx(
noise_est_ivas_fx( st, old_pitch1, tmpN_fx, epsP_h, epsP_l, Etot_fx, *relE_fx, corr_shift_fx, tmpE_fx, fr_bands_fx, cor_map_sum_fx, &ncharX_fx, &sp_div_fx, &q_sp_div,
&non_staX_fx, loc_harm, lf_E_fx, &st->hNoiseEst->harm_cor_cnt, st->hNoiseEst->Etot_l_lp_fx, st->hNoiseEst->Etot_v_h2_fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, sub( q_fr_bands, QSCALE ), L_shl( E_MIN_IVAS_FX, sub( q_fr_bands, Q19 ) ), &dummy_fx, S_map_fx, hStereoClassif, NULL, st->ini_frame );
-
- /*Scaling to avoid 0 values*/
- shift = s_min( L_norm_arr( st->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->fr_bands2_fx, NB_BANDS ) );
- scale_sig32( st->hNoiseEst->fr_bands1_fx, NB_BANDS, shift );
- scale_sig32( st->hNoiseEst->fr_bands2_fx, NB_BANDS, shift );
- st->hNoiseEst->fr_bands_fx_q = add( st->hNoiseEst->fr_bands_fx_q, shift );
- move16();
- shift = s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) );
- scale_sig32( st->hNoiseEst->ave_enr_fx, NB_BANDS, shift );
- scale_sig32( st->hNoiseEst->ave_enr2_fx, NB_BANDS, shift );
- st->hNoiseEst->ave_enr_q = add( st->hNoiseEst->ave_enr_q, shift );
- move16();
- shift = L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS );
- scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, shift );
- st->hNoiseEst->q_bckr = add( st->hNoiseEst->q_bckr, shift );
- move16();
- shift = L_norm_arr( st->hNoiseEst->enrO_fx, NB_BANDS );
- scale_sig32( st->hNoiseEst->enrO_fx, NB_BANDS, shift );
- st->hNoiseEst->q_enrO = add( st->hNoiseEst->q_enrO, shift );
- move16();
-
test();
IF( lr_vad_enabled && st->idchan == 0 )
{
- FOR( Word16 j = 0; j < 2; j++ )
- {
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->q_bckr ) );
- hCPE->hFrontVad[j]->hNoiseEst->q_bckr = q_fr_bands;
- move16();
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q ) );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q ) );
- hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q = q_fr_bands;
- move16();
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q ) );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q ) );
- hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q = q_fr_bands;
- move16();
- shift = L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS, shift );
- hCPE->hFrontVad[j]->hNoiseEst->q_bckr = add( hCPE->hFrontVad[j]->hNoiseEst->q_bckr, shift );
- move16();
- shift = L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->enrO_fx, NB_BANDS );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->enrO_fx, NB_BANDS, shift );
- hCPE->hFrontVad[j]->hNoiseEst->q_enrO = add( hCPE->hFrontVad[j]->hNoiseEst->q_enrO, shift );
- move16();
-
- FOR( Word16 k = 0; k < NB_BANDS; k++ )
- {
- hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx[k] = L_max( 1, hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx[k] );
- move32();
- hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx[k] = L_max( 1, hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx[k] );
- move32();
- }
- }
-
/* Run noise_est for Left and Right channel */
- *loc_harmLR_fx = *loc_harm;
+ *loc_harmLR_fx = *loc_harm; /* Q0 */
noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[0], epsP_h, epsP_l, Etot_LR_fx[0], sub( Etot_LR_fx[0], hCPE->hFrontVad[0]->lp_speech_fx ), corr_shiftL_fx, tmpE_LR_fx[0], fr_bands_LR_fx[0], &cor_map_sum_LR_fx[0], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR,
&non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[0], &hCPE->hFrontVad[0]->hNoiseEst->harm_cor_cnt, hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_fx, hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt, st->lgBin_E_fx, sub( q_fr_bands, QSCALE ), L_shl( E_MIN_IVAS_FX, sub( q_fr_bands, Q19 ) ), &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[0], hCPE->hFrontVad[0]->ini_frame );
/* Note: the index [0] in the last argument is intended, the ini_frame counter is only maintained in the zero-th channel's VAD handle */
noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[1], epsP_h, epsP_l, Etot_LR_fx[1], sub( Etot_LR_fx[1], hCPE->hFrontVad[1]->lp_speech_fx ), corr_shiftR_fx, tmpE_LR_fx[1], fr_bands_LR_fx[1], &cor_map_sum_LR_fx[1], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR,
&non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[1], &hCPE->hFrontVad[1]->hNoiseEst->harm_cor_cnt, hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_fx, hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt, st->lgBin_E_fx, sub( q_fr_bands, QSCALE ), L_shl( E_MIN_IVAS_FX, sub( q_fr_bands, Q19 ) ), &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[1], hCPE->hFrontVad[0]->ini_frame );
-
-
- /*Scaling to avoid 0 values*/
- FOR( Word16 j = 0; j < 2; j++ )
- {
- shift = s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS ) );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS, shift );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS, shift );
- hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q = add( hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q, shift );
- shift = s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS ) );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS, shift );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS, shift );
- hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q = add( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q, shift );
- }
}
/*------------------------------------------------------------------*
@@ -1522,9 +1480,10 @@ ivas_error pre_proc_front_ivas_fx(
* Find spectral tilt
* UC and VC frame selection
*-----------------------------------------------------------------*/
- find_tilt_ivas_fx( fr_bands_fx, st->hNoiseEst->bckr_fx, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, q_fr_bands, &( st->bckr_tilt_lt ), st->Opt_SC_VBR );
+ find_tilt_ivas_fx( fr_bands_fx, st->hNoiseEst->bckr_fx, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, q_fr_bands,
+ &( st->bckr_tilt_lt ), st->Opt_SC_VBR );
- st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, Etot_fx, hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, q_inp_12k8, q_fr_bands );
+ st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, Etot_fx, hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, q_fr_bands ); // Q0
Copy_Scale_sig_16_32( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
@@ -1542,17 +1501,14 @@ ivas_error pre_proc_front_ivas_fx(
* TC frame selection
*-----------------------------------------------------------------*/
- Word16 oi12k8_fx[L_INP_12k8];
- Copy_Scale_sig( old_inp_12k8_fx, oi12k8_fx, L_INP_12k8, negate( Q_new ) ); // Q0
- Word16 *ni12k8_fx = oi12k8_fx + L_INP_MEM;
- inp_12k8_fx = ni12k8_fx - L_look;
- st->clas = signal_clas_fx( st, inp_12k8_fx, ee_fx, *relE_fx, L_look, tdm_SM_last_clas );
+ st->clas = signal_clas_fx( st, inp_12k8_fx, ee_fx, *relE_fx, L_look, tdm_SM_last_clas ); /* Q0 */
+ move16();
select_TC_fx( MODE1, st->tc_cnt, &st->coder_type, st->localVAD );
if ( st->Opt_SC_VBR )
{
- st->hSC_VBR->Local_VAD = st->localVAD;
+ st->hSC_VBR->Local_VAD = st->localVAD; /* Q0 */
move16();
}
@@ -1564,10 +1520,10 @@ ivas_error pre_proc_front_ivas_fx(
Word16 max_e_Etot;
max_e_Etot = s_max( hStereoClassif->e_Etot_buf_fx, s_max( hStereoClassif->Etot_up_e, hStereoClassif->Etot_dn_e ) );
- scale_sig32( hStereoClassif->Etot_buf_fx, 3, sub( hStereoClassif->e_Etot_buf_fx, max_e_Etot ) );
- hStereoClassif->Etot_up_fx = L_shr( hStereoClassif->Etot_up_fx, sub( max_e_Etot, hStereoClassif->Etot_up_e ) );
+ scale_sig32( hStereoClassif->Etot_buf_fx, 3, sub( hStereoClassif->e_Etot_buf_fx, max_e_Etot ) ); /* exp(max_e_Etot) */
+ hStereoClassif->Etot_up_fx = L_shr( hStereoClassif->Etot_up_fx, sub( max_e_Etot, hStereoClassif->Etot_up_e ) ); /* exp(max_e_Etot) */
move32();
- hStereoClassif->Etot_dn_fx = L_shr( hStereoClassif->Etot_dn_fx, sub( max_e_Etot, hStereoClassif->Etot_dn_e ) );
+ hStereoClassif->Etot_dn_fx = L_shr( hStereoClassif->Etot_dn_fx, sub( max_e_Etot, hStereoClassif->Etot_dn_e ) ); /* exp(max_e_Etot) */
move32();
hStereoClassif->Etot_up_e = hStereoClassif->Etot_dn_e = hStereoClassif->e_Etot_buf_fx = max_e_Etot;
move16();
@@ -1587,7 +1543,7 @@ ivas_error pre_proc_front_ivas_fx(
scale_sig32( PS_fx, 128, shift );
Qfact_PS = add( Qfact_PS, shift );
- smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, Etot_fx, lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q );
+ smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, Etot_fx, lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */
#ifdef DEBUGGING
if ( st->idchan == 0 )
@@ -1612,7 +1568,7 @@ ivas_error pre_proc_front_ivas_fx(
ivas_long_enr_fx( st, Etot_fx, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL );
- Copy32( fr_bands_fx + NB_BANDS, st->hNoiseEst->enrO_fx, NB_BANDS );
+ Copy32( fr_bands_fx + NB_BANDS, st->hNoiseEst->enrO_fx, NB_BANDS ); /* fr_bands_fx_q */
st->hNoiseEst->q_enrO = fr_bands_fx_q;
move16();
@@ -1621,11 +1577,11 @@ ivas_error pre_proc_front_ivas_fx(
{
ivas_long_enr_fx( st, -1, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR_fx );
- Copy32( fr_bands_LR_fx[0] + NB_BANDS, hCPE->hFrontVad[0]->hNoiseEst->enrO_fx, NB_BANDS );
- hCPE->hFrontVad[0]->hNoiseEst->q_enrO = fr_bands_LR_fx_q;
+ Copy32( fr_bands_LR_fx[0] + NB_BANDS, hCPE->hFrontVad[0]->hNoiseEst->enrO_fx, NB_BANDS ); // fr_bands_LR_fx_q
+ hCPE->hFrontVad[0]->hNoiseEst->q_enrO = fr_bands_LR_fx_q[0];
move16();
- Copy32( fr_bands_LR_fx[1] + NB_BANDS, hCPE->hFrontVad[1]->hNoiseEst->enrO_fx, NB_BANDS );
- hCPE->hFrontVad[1]->hNoiseEst->q_enrO = fr_bands_LR_fx_q;
+ Copy32( fr_bands_LR_fx[1] + NB_BANDS, hCPE->hFrontVad[1]->hNoiseEst->enrO_fx, NB_BANDS ); // fr_bands_LR_fx_q
+ hCPE->hFrontVad[1]->hNoiseEst->q_enrO = fr_bands_LR_fx_q[1];
move16();
}
@@ -1671,14 +1627,14 @@ ivas_error pre_proc_front_ivas_fx(
test();
test();
test();
- IF( EQ_32( ivas_format, SBA_FORMAT ) && NE_32( st->core_brate, FRAME_NO_DATA ) && EQ_32( st->last_core_brate, FRAME_NO_DATA ) && st->sba_br_sw_while_no_data )
+ IF( EQ_32( ivas_format, SBA_FORMAT ) && st->core_brate != FRAME_NO_DATA && st->last_core_brate == FRAME_NO_DATA && st->sba_br_sw_while_no_data )
{
SetModeIndex_ivas_fx( st, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), element_mode, MCT_flag );
st->sba_br_sw_while_no_data = 0;
move16();
}
- ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) && EQ_32( st->core_brate, FRAME_NO_DATA ) && NE_32( element_brate, last_element_brate ) )
+ ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) && st->core_brate == FRAME_NO_DATA && NE_32( element_brate, last_element_brate ) )
{
st->sba_br_sw_while_no_data = 1;
move16();
@@ -1686,12 +1642,12 @@ ivas_error pre_proc_front_ivas_fx(
IF( flag_16k_smc )
{
- Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) );
+ Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) ); /* Q(-1) */
st->q_inp = -1;
move16();
}
/* these are for ivas_acelp_tcx20_switching_fx */
- Scale_sig32( st->hTcxEnc->spectrum_long_fx, N_MAX, sub( st->hTcxEnc->spectrum_long_e, 16 ) );
+ Scale_sig32( st->hTcxEnc->spectrum_long_fx, N_MAX, sub( st->hTcxEnc->spectrum_long_e, 16 ) ); /* Q(-1) */
st->hTcxEnc->spectrum_long_e = 16;
move16();
st->hTcxEnc->spectrum_e[0] = 16;
@@ -1703,51 +1659,64 @@ ivas_error pre_proc_front_ivas_fx(
Word16 Q_old_inp_16k = -1;
move16();
- Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( Q_old_inp_16k, sub( Q15, Q_old_inp_16k ) ) );
+ Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_old_inp_16k = sub( Q15, Q_old_inp_16k );
+ move16();
IF( st->hBWE_FD != NULL )
{
- Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) );
- st->Q_old_wtda = -1; // This reset needs to be looked into
+ Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) ); /* Q(-1) */
+ st->Q_old_wtda = -1; // This reset needs to be looked into
move16();
}
- st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_mem_preemph_enc ) ) );
+ st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_mem_preemph_enc ) ) ); /* Q15 - Q_old_inp_16k */
move16();
st->exp_mem_preemph_enc = sub( Q15, Q_old_inp_16k );
move16();
- Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) );
+ Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k );
move16();
- Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc_pe ) ) );
+ Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_buf_speech_enc_pe = sub( Q15, Q_old_inp_16k );
move16();
- Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ) );
+ Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_buf_speech_enc = sub( Q15, Q_old_inp_16k );
move16();
+
+ Word16 Q_old_inp_12k8 = *Q_new;
+ move16();
/* Compute core-coder buffers at internal sampling rate */
error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx,
A_fx, Aw_fx,
epsP_fx,
- lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, NULL );
- IF( error != IVAS_ERR_OK )
+ lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new, 1 );
+ IF( NE_32( error, IVAS_ERR_OK ) )
{
return error;
}
*epsP_fx_q = add( Q_r[0], 1 );
move16();
- Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q15, st->exp_buf_speech_enc ) );
- smc_dec = ivas_acelp_tcx20_switching_fx( st, st->speech_enc, 0, st->wspeech_enc, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc );
+ st->mem_wsp_enc = shr_r( st->mem_wsp_enc, *Q_new ); // Q_new - 1 -> Q-1
+ move16();
+
+ *Q_new = add( *Q_new, Q_to_be_looked_into ); // actual Q_new
+ move16();
+ Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_12k8 ) ); /* Q_new */
+
+ Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( 0, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q0 */
+ st->exp_buf_speech_enc = Q15;
+ move16();
+ smc_dec = ivas_acelp_tcx20_switching_fx( st, st->speech_enc, 0, st->wspeech_enc, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc ); /* Q0 */
}
ELSE
{
- Scale_sig( old_wsp_fx, L_WSP, sub( Q_new, *q_old_wsp ) );
- *q_old_wsp = Q_new;
+ Scale_sig( old_wsp_fx, L_WSP, sub( *Q_new, *q_old_wsp ) ); /* Q_new */
+ *q_old_wsp = *Q_new;
move16();
- Q_wsp = Q_new;
+ Q_wsp = *Q_new;
move16();
- smc_dec = ivas_acelp_tcx20_switching_fx( st, inp_12k8_fx, Q_new, wsp_fx, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc );
+ smc_dec = ivas_acelp_tcx20_switching_fx( st, inp_12k8_fx, *Q_new, wsp_fx, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc ); /* Q0 */
}
}
/* Switch to ACELP for non-harmonic transient signals */
@@ -1775,11 +1744,11 @@ ivas_error pre_proc_front_ivas_fx(
}
}
- Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E ) );
- st->q_Bin_E = add( Q_new, Q_SCALE - 2 );
+ Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( *Q_new, Q_SCALE - 2 ), st->q_Bin_E ) ); /* Q_new + Q_SCALE - 2 */
+ st->q_Bin_E = add( *Q_new, Q_SCALE - 2 );
move16();
/* 2nd stage speech/music classification (ACELP/GSC/TCX core selection) */
- 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, Etot_fx, attack_flag, inp_12k8_fx, *Q_new, S_map_fx, flag_spitch );
}
/*----------------------------------------------------------------*
@@ -1790,7 +1759,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
if ( st->Opt_DTX_ON && NE_16( element_mode, IVAS_CPE_DFT ) )
{
- st->vad_flag = *vad_flag_dtx;
+ st->vad_flag = *vad_flag_dtx; /* Q0 */
move16();
}
@@ -1798,11 +1767,14 @@ ivas_error pre_proc_front_ivas_fx(
* Update old input signal buffer
*-----------------------------------------------------------------*/
shift = getScaleFactor16( &old_inp_12k8_fx[L_FRAME], L_INP_MEM );
- Copy_Scale_sig( &old_inp_12k8_fx[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM, shift );
- st->exp_old_inp_12k8 = sub( Q15, add( Q_new, shift ) );
+ Copy_Scale_sig( &old_inp_12k8_fx[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM, shift ); /* Q_new + shift */
+ st->exp_old_inp_12k8 = sub( Q15, add( *Q_new, shift ) );
move16();
- Scale_sig( old_inp_12k8_fx, L_INP_12k8, negate( add( Q_new, 1 ) ) );
+ // Scale_sig( old_inp_12k8_fx, L_INP_12k8, negate( add( *Q_new, 1 ) ) );
+
+ *Q_new = sub( *Q_new, Q_to_be_looked_into ); // ivas_core_enc will assume inp signal (12k8 and 16k) in Q_new - 1
+ move16();
free( mem_decim_dummy_fx );
free( temp1F_icatdmResampBuf_fx );
@@ -1880,9 +1852,9 @@ static void calculate_energy_buffer_fx(
*--------------------------------------------------------------------*/
static void calculate_energy_buffer_ivas_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- Word32 enerBuffer_dft_fx[], /* o : energy buffer() */
- const Word16 no_channels, /* i : no. of used CLDFB channels */
- const Word32 input_Fs, /* i : input sampling rate */
+ Word32 enerBuffer_dft_fx[], /* o : energy buffer() exp(enerBuffer_dft_e)*/
+ const Word16 no_channels, /* i : no. of used CLDFB channels Q0*/
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
Word16 *enerBuffer_dft_e )
{
Word16 i, j;
@@ -1894,13 +1866,14 @@ static void calculate_energy_buffer_ivas_fx(
Word16 norm_nrg_DMX_fx;
Word64 max_abs_nrg_DMX_fx;
Flag overflow = 0;
+ move32();
max_abs_nrg_DMX_fx = 0;
move64();
Word16 temp_q1 = sub( norm_l( input_Fs ), 1 );
Word16 temp_q2 = norm_s( hCPE->hStereoDft->NFFT );
- band_res_dft_fx = div_l( L_shl( input_Fs, temp_q1 ), shl( hCPE->hStereoDft->NFFT, temp_q2 ) );
+ band_res_dft_fx = div_l( L_shl( input_Fs, temp_q1 ), shl( hCPE->hStereoDft->NFFT, temp_q2 ) ); /* Q0 */
/* chan_width_f = 24000.f / CLDFB_NO_CHANNELS_MAX; */
chan_width_f_fx = 24000 / CLDFB_NO_CHANNELS_MAX;
move16();
diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c
index 46e708dfe20b028b3dc1c684eb9570472713c374..887dc12139735af0647c28cebd5c7ea8df8be0cc 100644
--- a/lib_enc/ivas_corecoder_enc_reconfig.c
+++ b/lib_enc/ivas_corecoder_enc_reconfig.c
@@ -48,11 +48,11 @@
/* Some float operations are still pending */
ivas_error ivas_corecoder_enc_reconfig_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 nSCE_old, /* i : number of SCEs in previous frame */
- const Word16 nCPE_old, /* i : number of CPEs in previous frame */
- const Word16 nchan_transport_old, /* i : number of TCs in previous frame */
- const Word32 brate_SCE, /* i : bitrate to be set for the SCEs */
- const Word32 brate_CPE, /* i : bitrate to be set for the CPEs */
+ const Word16 nSCE_old, /* i : number of SCEs in previous frame Q0*/
+ const Word16 nCPE_old, /* i : number of CPEs in previous frame Q0*/
+ const Word16 nchan_transport_old, /* i : number of TCs in previous frame Q0*/
+ const Word32 brate_SCE, /* i : bitrate to be set for the SCEs Q0*/
+ const Word32 brate_CPE, /* i : bitrate to be set for the CPEs Q0*/
const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */
)
{
@@ -67,7 +67,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
BSTR_ENC_HANDLE hBstr;
Word16 i, nb_bits;
Indice temp_ind_list[MAX_NUM_IND_TEMP_LIST];
- Word16 nb_bits_tot, input_frame;
+ Word16 nb_bits_tot, input_frame, q_input_buff[MCT_MAX_BLOCKS];
Word16 nchan_transport_real, nchan_transport_old_real;
ENCODER_CONFIG_HANDLE hEncoderConfig;
ivas_error error;
@@ -80,22 +80,23 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
error = IVAS_ERR_OK;
move32();
- input_frame = idiv1616U( extract_l( L_shr( hEncoderConfig->input_Fs, 1 ) ), FRAMES_PER_SEC / 2 );
- len_inp_memory = input_frame;
+ set16_fx( q_input_buff, Q31, MCT_MAX_BLOCKS );
+ input_frame = idiv1616U( extract_l( L_shr( hEncoderConfig->input_Fs, 1 ) ), FRAMES_PER_SEC / 2 ); /* Q0 */
+ len_inp_memory = input_frame; /* Q0 */
move16();
IF( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) )
{
- len_inp_memory = add( len_inp_memory, NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) );
+ len_inp_memory = add( len_inp_memory, NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); /* Q0 */
}
- nchan_transport_old_real = nchan_transport_old;
+ nchan_transport_old_real = nchan_transport_old; /* Q0 */
move16();
- nchan_transport_real = st_ivas->nchan_transport;
+ nchan_transport_real = st_ivas->nchan_transport; /* Q0 */
move16();
IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
- nchan_transport_real = add( nchan_transport_real, st_ivas->hEncoderConfig->nchan_ism );
+ nchan_transport_real = add( nchan_transport_real, st_ivas->hEncoderConfig->nchan_ism ); /* Q0 */
}
/*-----------------------------------------------------------------*
@@ -109,15 +110,15 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
copy_encoder_config_fx( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 );
- st_ivas->hSCE[sce_id]->element_brate = brate_SCE;
+ st_ivas->hSCE[sce_id]->element_brate = brate_SCE; /* Q0 */
move32();
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
}
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- st_ivas->hCPE[cpe_id]->element_brate = brate_CPE;
+ st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; /* Q0 */
move32();
/* prepare bitstream buffers */
@@ -132,14 +133,14 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
tmp = 0;
move16();
}
- st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = L_shr( st_ivas->hCPE[cpe_id]->element_brate, tmp ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = L_shr( st_ivas->hCPE[cpe_id]->element_brate, tmp ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
}
}
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = mct_enc_reconfigure_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = mct_enc_reconfigure_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -152,13 +153,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
test();
IF( EQ_16( hEncoderConfig->ivas_format, MC_FORMAT ) && EQ_16( last_mc_mode, MC_MODE_MCMASA ) )
{
- nchan_transport_old_real = add( nSCE_old, i_mult( CPE_CHANNELS, nCPE_old ) );
+ nchan_transport_old_real = add( nSCE_old, i_mult( CPE_CHANNELS, nCPE_old ) ); /* Q0 */
}
test();
IF( EQ_16( hEncoderConfig->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
- nchan_transport_real = add( st_ivas->nSCE, i_mult( CPE_CHANNELS, st_ivas->nCPE ) );
+ nchan_transport_real = add( st_ivas->nSCE, i_mult( CPE_CHANNELS, st_ivas->nCPE ) ); /* Q0 */
}
/* something in transport changes */
@@ -175,7 +176,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
}
/* save bitstream information */
- nb_bits_tot = hBstr->nb_bits_tot;
+ nb_bits_tot = hBstr->nb_bits_tot; /* Q0 */
move16();
i = 0;
move16();
@@ -187,13 +188,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( hBstr->ind_list[i].nb_bits > 0 )
{
- temp_ind_list[i].id = hBstr->ind_list[i].id;
+ temp_ind_list[i].id = hBstr->ind_list[i].id; /* Q0 */
move16();
- temp_ind_list[i].value = hBstr->ind_list[i].value;
+ temp_ind_list[i].value = hBstr->ind_list[i].value; /* Q0 */
move16();
- temp_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits;
+ temp_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits; /* Q0 */
move16();
- hBstr->ind_list[i].nb_bits = -1;
+ hBstr->ind_list[i].nb_bits = -1; /* Q0 */
move16();
}
@@ -202,7 +203,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
hBstr->nb_ind_tot = 0;
move16();
- nb_bits = add( nb_bits, temp_ind_list[i].nb_bits );
+ nb_bits = add( nb_bits, temp_ind_list[i].nb_bits ); /* Q0 */
i = add( i, 1 );
test();
}
@@ -223,12 +224,12 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( k = 0; k < nSCE_old; k++ )
{
shift = getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame );
- Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp + shift */
st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp, shift );
move16();
q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp );
shift = getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) );
- Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift );
+ Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp, shift );
move16();
q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp );
@@ -243,12 +244,12 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
shift = getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame );
- Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp + shift */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp, shift );
move16();
q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp );
shift = getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) );
- Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift );
+ Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp, shift );
move16();
q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp );
@@ -260,13 +261,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
FOR( k = 0; k < nSCE_old; k++ )
{
- Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) );
+ Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) ); /* q_com */
st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = q_com;
move16();
- Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) );
+ Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */
st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = q_com;
move16();
- Copy_Scale_sig_16_32( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 );
+ Copy_Scale_sig_16_32( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */
st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( Q6, q_com );
move16();
}
@@ -278,13 +279,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) );
+ Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) ); /* q_com */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = q_com;
move16();
- Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) );
+ Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = q_com;
move16();
- Copy_Scale_sig_16_32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 );
+ Copy_Scale_sig_16_32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( Q6, q_com );
move16();
}
@@ -301,7 +302,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
IF( nSCE_old > 0 )
{
set32_fx( input_buff_fx[0], 0, len_inp_memory );
- Copy32( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[0], len_inp_memory );
+ Copy32( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[0], len_inp_memory ); /* st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 */
+ q_input_buff[0] = st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32;
+ move16();
}
FOR( n = 0; n < CPE_CHANNELS; n++ )
@@ -309,18 +312,21 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
set32_fx( input_buff_fx[n + 1], 0, len_inp_memory );
IF( nCPE_old > 0 )
{
- Copy32( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[n + 1], len_inp_memory );
+ Copy32( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[n + 1], len_inp_memory ); /* st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 */
+ q_input_buff[n + 1] = st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32;
+ move16();
}
}
- ivas_mcmasa_dmx_modify_fx( len_inp_memory, input_buff_fx, nSCE_old + CPE_CHANNELS * nCPE_old, st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE );
+ ivas_mcmasa_dmx_modify_fx( len_inp_memory, input_buff_fx, q_input_buff, nSCE_old + CPE_CHANNELS * nCPE_old, st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE );
+
n_CoreCoder_existing = 0;
move16();
}
ELSE
{
- n_CoreCoder_existing = s_min( nchan_transport_real, nchan_transport_old_real );
+ n_CoreCoder_existing = s_min( nchan_transport_real, nchan_transport_old_real ); /* Q0 */
}
/* destroy superfluous core-coder elements */
@@ -329,7 +335,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
/* save input audio buffers */
IF( GT_16( n_CoreCoder_existing, sce_id ) )
{
- Copy32( st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[sce_id], len_inp_memory );
+ Copy32( st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[sce_id], len_inp_memory ); /* st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32 */
+ q_input_buff[sce_id] = st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32;
+ move16();
}
destroy_sce_enc( st_ivas->hSCE[sce_id], ( EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) && !st_ivas->hEncoderConfig->stereo_dmx_evs ) );
st_ivas->hSCE[sce_id] = NULL;
@@ -342,7 +350,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n )
{
- Copy32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory );
+ Copy32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 */
+ q_input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n] = st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32;
+ move16();
}
}
destroy_cpe_enc( st_ivas->hCPE[cpe_id] );
@@ -351,7 +361,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
test();
IF( LE_16( st_ivas->nCPE, 1 ) && st_ivas->hMCT != NULL )
{
- ivas_mct_enc_close( &( st_ivas->hMCT ) );
+ ivas_mct_enc_close_fx( &( st_ivas->hMCT ) );
}
/* special case, if we have MCT now and had a single CPE before, remove the MDCT Stereo handles */
@@ -370,17 +380,17 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( sce_id = 0; sce_id < nSCE_existing; sce_id++ )
{
copy_encoder_config_fx( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 );
- st_ivas->hSCE[sce_id]->element_brate = brate_SCE;
+ st_ivas->hSCE[sce_id]->element_brate = brate_SCE; /* Q0 */
move32();
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
- ivas_destroy_MD_bstr_enc( &( st_ivas->hSCE[sce_id]->hMetaData ) );
+ ivas_destroy_MD_bstr_enc_fx( &( st_ivas->hSCE[sce_id]->hMetaData ) );
}
FOR( sce_id = nSCE_existing; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_SCE ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -389,7 +399,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
test();
IF( GT_16( n_CoreCoder_existing, sce_id ) && NE_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
- Copy32( input_buff_fx[sce_id], st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, len_inp_memory );
+ Copy32( input_buff_fx[sce_id], st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, len_inp_memory ); /* q_input_buff[sce_id] */
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32 = q_input_buff[sce_id];
+ move16();
}
test();
/* only reset indices if it is not the first index list, this already contains the IVAS format bits */
@@ -401,7 +413,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
IF( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData == NULL )
{
- IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_initialize_MD_bstr_enc_fx( &( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -414,7 +426,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ )
{
- st_ivas->hCPE[cpe_id]->element_brate = brate_CPE;
+ st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; /* Q0 */
move32();
/* allocate buffer of indices */
@@ -423,7 +435,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
copy_encoder_config_fx( st_ivas, st_ivas->hCPE[cpe_id]->hCoreCoder[n], 0 );
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate;
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate; /* Q0 */
}
ELSE
{
@@ -447,13 +459,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( cpe_id = nCPE_existing; cpe_id < st_ivas->nCPE; cpe_id++ )
{
test();
- IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hMcMasa->separateChannelEnabled )
+ if ( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hMcMasa->separateChannelEnabled )
{
st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
move16();
}
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_CPE ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -464,7 +476,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
IF( GT_16( n_CoreCoder_existing, add( i_mult( cpe_id, CPE_CHANNELS ), n ) ) )
{
- Copy32( input_buff_fx[n], st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, len_inp_memory );
+ Copy32( input_buff_fx[n], st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, len_inp_memory ); /* q_input_buff */
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = q_input_buff[n];
+ move16();
}
}
@@ -499,21 +513,21 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( temp_ind_list[i].nb_bits > 0 )
{
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id; /* Q0 */
move16();
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value; /* Q0 */
move16();
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */
move16();
}
- nb_bits = add( nb_bits, temp_ind_list[i].nb_bits );
+ nb_bits = add( nb_bits, temp_ind_list[i].nb_bits ); /* Q0 */
i = add( i, 1 );
test();
}
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot = i;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot = i; /* Q0 */
move16();
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot; /* Q0 */
move16();
}
ELSE IF( st_ivas->nCPE > 0 )
@@ -523,21 +537,21 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( temp_ind_list[i].nb_bits > 0 )
{
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id; /* Q0 */
move16();
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value; /* Q0 */
move16();
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */
move16();
}
- nb_bits = add( nb_bits, temp_ind_list[i].nb_bits );
+ nb_bits = add( nb_bits, temp_ind_list[i].nb_bits ); /* Q0 */
i = add( i, 1 );
test();
}
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_ind_tot = i;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_ind_tot = i; /* Q0 */
move16();
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot; /* Q0 */
move16();
}
@@ -547,14 +561,18 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
/* restore modified transport signal */
IF( st_ivas->nSCE )
{
- Copy32( input_buff_fx[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, len_inp_memory );
+ Copy32( input_buff_fx[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, len_inp_memory ); /* q_input_buff */
+ st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 = q_input_buff[0];
+ move16();
}
IF( st_ivas->nCPE )
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Copy32( input_buff_fx[n + 1], st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, len_inp_memory );
+ Copy32( input_buff_fx[n + 1], st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, len_inp_memory ); /* q_input_buff */
+ st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 = q_input_buff[n + 1];
+ move16();
}
}
}
@@ -610,31 +628,31 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
/* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handles for MCT */
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate;
+ st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; /* Q0 */
move32();
- st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = extract_l( Mpy_32_32( st_ivas->hCPE[0]->element_brate, 42949673 ) /* 1/50 in Q31*/ );
+ st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = extract_l( Mpy_32_32( st_ivas->hCPE[0]->element_brate, 42949673 ) /* 1/50 in Q31*/ ); /* Q0 */
move16();
st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent_fx( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode,
st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal * FRAMES_PER_SEC,
st_ivas->hCPE[0]->hCoreCoder[n]->bwidth,
- st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode );
+ st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); /* Q0 */
move16();
- IF( NE_32( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ), IVAS_ERR_OK ) )
+ IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( st_ivas->hMCT != NULL && GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = mct_enc_reconfigure_fx( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ), IVAS_ERR_OK ) )
+ IF( ( error = mct_enc_reconfigure_fx( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -645,7 +663,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData == NULL )
{
- IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_initialize_MD_bstr_enc_fx( &( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -655,7 +673,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ )
{
- ivas_destroy_MD_bstr_enc( &( st_ivas->hCPE[cpe_id]->hMetaData ) );
+ ivas_destroy_MD_bstr_enc_fx( &( st_ivas->hCPE[cpe_id]->hMetaData ) );
}
}
@@ -671,7 +689,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
/* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handle */
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate;
+ st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; /* Q0 */
move32();
st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = extract_l( Mpy_32_32( st_ivas->hCPE[0]->element_brate, 42949673 ) ) /* 1/50 in Q31*/; // ( st_ivas->hCPE[0]->element_brate / FRAMES_PER_SEC );
move16();
@@ -679,11 +697,11 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent_fx( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode,
L_mult0( st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal, FRAMES_PER_SEC ),
st_ivas->hCPE[0]->hCoreCoder[n]->bwidth,
- st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode );
+ st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); /* Q0 */
move16();
- IF( NE_32( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ), IVAS_ERR_OK ) )
+ IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c
index f66d766d2773dfe0962f03f04f14d1defc30be91..11dde0745d1362dfcaa0a2272b793b8ebeb71e3e 100644
--- a/lib_enc/ivas_cpe_enc.c
+++ b/lib_enc/ivas_cpe_enc.c
@@ -61,25 +61,27 @@ static void stereo_mode_combined_format_enc_fx( const Encoder_Struct *st_ivas, C
* Channel Pair Element (CPE) encoding routine
*-------------------------------------------------------------------*/
ivas_error ivas_cpe_enc_fx(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 cpe_id, /* i : CPE # identifier */
- Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx) */
- Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx) */
- Word16 q_data_fx, /* i : Q-factor of input signal for both channels */
- const Word16 input_frame, /* i : input frame length per channel */
- const Word16 nb_bits_metadata /* i : number of metadata bits */
-)
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const Word16 cpe_id, /* i : CPE # identifier Q0*/
+ Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx)*/
+ Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx)*/
+ Word16 q_data_fx, /* i : Q-factor of input signal for both channels */
+ const Word16 input_frame, /* i : input frame length per channel Q0*/
+ const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
+ Word16 Q_new_out[] )
{
CPE_ENC_HANDLE hCPE;
Encoder_State **sts;
Word16 n, n_CoreChannels;
- Word32 old_inp_12k8_fx[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 Q16 */
- Word16 old_inp_12k8_16fx[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 Q-1 */
- Word32 old_inp_16k_fx[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz Q16 */
- Word16 old_inp_16k_16fx[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz Q-1 */
- Word16 fft_buff_fx[CPE_CHANNELS][2 * L_FFT]; /* FFT buffer */
- Word16 fft_buff_fx_q[CPE_CHANNELS]; /* FFT buffer */
+ Word32 old_inp_12k8_fx[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 Q15 */
+ Word16 old_inp_12k8_16fx[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 Q_new-1 */
+ Word32 old_inp_16k_fx[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz Q15 */
+ Word16 old_inp_16k_16fx[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz Q_new-1 */
+ Word16 Q_new[CPE_CHANNELS] = { 0 };
+ Word16 fft_buff_fx[CPE_CHANNELS][2 * L_FFT]; /* FFT buffer */
+ Word16 fft_buff_fx_q[CPE_CHANNELS]; /* FFT buffer */
Word16 fft_buff_fx_final_q = MAX_16;
+ move16();
Word32 ener_fx[CPE_CHANNELS]; /* residual energy from Levinson-Durbin Q6 */
Word16 relE_fx[CPE_CHANNELS]; /* frame relative energy Q8 */
Word16 A_fx[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* A(z) unquantized for subframes Q12 */
@@ -112,6 +114,7 @@ ivas_error ivas_cpe_enc_fx(
Word32 band_energies_LR_fx[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor E_MIN (Q_buffer + QSCALE - band_ener_guardbits) */
Word16 Q_buffer[2];
Word16 orig_input_fx[CPE_CHANNELS][L_FRAME48k];
+ Word16 Q_orig_inp[CPE_CHANNELS];
Word16 Etot_last_fx[CPE_CHANNELS];
Word32 tmp, input_Fs;
Word16 max_bwidth, ivas_format;
@@ -123,6 +126,8 @@ ivas_error ivas_cpe_enc_fx(
Word16 last_bits_frame_nominal; /* last_bits_frame_nominal for M or PCh channel */
Word16 old_wsp_fx[CPE_CHANNELS][L_WSP];
Word16 e_old_wsp[CPE_CHANNELS], q_old_wsp;
+ move16(); // Q_new
+ move16(); // Q_new
error = IVAS_ERR_OK;
move32();
@@ -185,16 +190,24 @@ ivas_error ivas_cpe_enc_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- sts[n]->idchan = n;
- sts[n]->core = -1;
- sts[n]->core_brate = -1; /* updated in dtx() */
- sts[n]->max_bwidth = max_bwidth;
+ sts[n]->idchan = n; /* Q0 */
+ sts[n]->core = -1; /* Q0 */
+ sts[n]->core_brate = -1; /* updated in dtx() Q0*/
+ sts[n]->max_bwidth = max_bwidth; /* Q0 */
+ move32();
+ move16();
+ move16();
+ move16();
+
IF( st_ivas->hMCT == NULL ) /*already updated before CPE call*/
{
- sts[n]->input_bwidth = sts[n]->last_input_bwidth; /* updated in BWD */
- sts[n]->bwidth = sts[n]->last_bwidth; /* updated in BWD */
+ sts[n]->input_bwidth = sts[n]->last_input_bwidth; /* updated in BWD Q0*/
+ sts[n]->bwidth = sts[n]->last_bwidth; /* updated in BWD Q0*/
+ move16();
+ move16();
}
sts[n]->rate_switching_reset = 0;
+ move16();
#ifdef DEBUGGING
sts[n]->force = hEncoderConfig->force;
@@ -202,15 +215,30 @@ ivas_error ivas_cpe_enc_fx(
#endif
}
- Copy32( data_fx_ch0, sts[0]->input32_fx, input_frame ); // Q(q_data_fx)
- Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, sub( Q16, q_data_fx ) ); // Q(q_data_fx) -> Q0
- sts[0]->q_inp = 0;
+ Copy32( data_fx_ch0, sts[0]->input32_fx, input_frame ); // Q(q_data_fx)
+ sts[0]->q_inp32 = q_data_fx;
+ move16();
+ Word16 norm = L_norm_arr( sts[0]->input32_fx, input_frame );
+ scale_sig32( sts[0]->input32_fx, input_frame, norm );
+ sts[0]->q_inp32 = add( sts[0]->q_inp32, norm );
+ move16();
+
+ Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, 0 );
+ sts[0]->q_inp = sub( sts[0]->q_inp32, Q16 );
move16();
IF( data_fx_ch1 != NULL ) /*this may happen for cases with odd number of channels*/
{
- Copy32( data_fx_ch1, sts[1]->input32_fx, input_frame ); // Q(q_data_fx)
- Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, sub( Q16, q_data_fx ) ); // Q(q_data_fx) -> Q0
- sts[1]->q_inp = 0;
+ Copy32( data_fx_ch1, sts[1]->input32_fx, input_frame ); // Q(q_data_fx)
+ sts[1]->q_inp32 = q_data_fx;
+ move16();
+
+ norm = L_norm_arr( sts[1]->input32_fx, input_frame );
+ scale_sig32( sts[1]->input32_fx, input_frame, norm );
+ sts[1]->q_inp32 = add( sts[1]->q_inp32, norm );
+ move16();
+
+ Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, 0 );
+ sts[1]->q_inp = sub( sts[1]->q_inp32, Q16 );
move16();
}
@@ -230,14 +258,14 @@ ivas_error ivas_cpe_enc_fx(
test();
IF( sts[0]->ini_frame > 0 && st_ivas->hMCT == NULL )
{
- hCPE->element_mode = select_stereo_mode( hCPE, ivas_format );
+ hCPE->element_mode = select_stereo_mode( hCPE, ivas_format ); /* Q0 */
}
stereo_mode_combined_format_enc_fx( st_ivas, hCPE );
Word16 Q_inp = 0;
move16();
- Word16 band_ener_guardbits = find_guarded_bits_fx( 2 * NB_BANDS );
+
Word16 Q_add = 2;
move16();
Word16 front_create_flag = 0;
@@ -245,64 +273,60 @@ ivas_error ivas_cpe_enc_fx(
#ifdef MSAN_FIX
set32_fx( band_energies_LR_fx, 0, 2 * NB_BANDS );
#endif
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
Q_buffer[n] = 15;
move16();
}
-#endif
test();
IF( hCPE->hFrontVad[0] != NULL && NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
- Word16 Qband = -1;
- move16();
- Word16 Q_new_old = add( add( sub( Q_inp, Qband ), Q_add ), QSCALE );
-
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
Q_buffer[n] = hCPE->hFrontVad[n]->q_buffer_12k8;
move16();
- Scale_sig32( hCPE->hFrontVad[n]->hNoiseEst->bckr_fx, 20, sub( Q_new_old, hCPE->hFrontVad[n]->hNoiseEst->q_bckr ) );
- hCPE->hFrontVad[n]->hNoiseEst->q_bckr = Q_new_old;
- move16();
- Scale_sig32( hCPE->hFrontVad[n]->hNoiseEst->enrO_fx, 20, sub( Q_new_old, hCPE->hFrontVad[n]->hNoiseEst->q_enrO ) );
- hCPE->hFrontVad[n]->hNoiseEst->q_enrO = Q_new_old;
- move16();
}
}
-
- IF( NE_32( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands_fx, Etot_LR_fx, lf_E_fx, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ), IVAS_ERR_OK ) )
+ Word16 q_band_energies_LR;
+ Word16 q_fr_bands[2], q_lf_E[2];
+ IF( NE_32( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx,
+ fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx,
+ &q_band_energies_LR, NULL, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ),
+ IVAS_ERR_OK ) )
{
return error;
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- if ( hCPE->hFrontVad[0] != NULL && hCPE->element_mode != IVAS_CPE_MDCT )
+ IF( hCPE->hFrontVad[0] != NULL && NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
// Scale_sig( hCPE->hFrontVad[n]->buffer_12k8_fx + 384, 3 * L_FRAME / 2 - 384, sub( Q_buffer[n], hCPE->hFrontVad[n]->q_buffer_12k8 ) );
hCPE->hFrontVad[n]->q_buffer_12k8 = Q_buffer[n];
+ move16();
}
}
-#endif
sts[0]->element_mode = hCPE->element_mode;
sts[1]->element_mode = hCPE->element_mode;
+ move16();
+ move16();
n_CoreChannels = 2;
- if ( hCPE->element_mode == IVAS_CPE_DFT )
+ move16();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
n_CoreChannels = 1; /* in DFT stereo, only M channel is coded */
+ move16();
sts[1]->vad_flag = 0;
+ move16();
}
/*----------------------------------------------------------------*
* dynamically allocate data structures depending on the actual stereo mode
*----------------------------------------------------------------*/
- IF( NE_32( ( error = stereo_memory_enc_fx( hCPE, input_Fs, max_bwidth, ivas_format, st_ivas->nchan_transport ) ), IVAS_ERR_OK ) )
+ IF( ( error = stereo_memory_enc_fx( hCPE, input_Fs, max_bwidth, ivas_format, st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -312,27 +336,27 @@ ivas_error ivas_cpe_enc_fx(
* Set TD stereo parameters
*----------------------------------------------------------------*/
- Copy_Scale_sig_16_32( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( Q11, sts[1]->q_inp ) );
- Copy_Scale_sig_16_32( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) );
+ Copy_Scale_sig_16_32( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( Q11, sts[1]->q_inp ) ); /* Q11 */
+ Copy_Scale_sig_16_32( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) ); /* Q11 */
Word16 shift = getScaleFactor32( sts[1]->input32_fx, input_frame );
- scale_sig32( sts[1]->input32_fx, input_frame, shift );
+ scale_sig32( sts[1]->input32_fx, input_frame, shift ); /* Q11 + shift */
sts[1]->q_inp32 = add( Q11, shift );
move16();
shift = getScaleFactor32( sts[0]->input32_fx, input_frame );
- scale_sig32( sts[0]->input32_fx, input_frame, shift );
+ scale_sig32( sts[0]->input32_fx, input_frame, shift ); /* Q11 + shift */
sts[0]->q_inp32 = add( Q11, shift );
move16();
Q_inp = s_min( Q_inp, s_min( sts[0]->q_inp32, sts[1]->q_inp32 ) );
- scale_sig32( sts[0]->input32_fx, input_frame, sub( Q_inp, sts[0]->q_inp32 ) );
- scale_sig32( sts[1]->input32_fx, input_frame, sub( Q_inp, sts[1]->q_inp32 ) );
+ scale_sig32( sts[0]->input32_fx, input_frame, sub( Q_inp, sts[0]->q_inp32 ) ); /* Q_inp */
+ scale_sig32( sts[1]->input32_fx, input_frame, sub( Q_inp, sts[1]->q_inp32 ) ); /* Q_inp */
sts[1]->q_inp32 = sts[0]->q_inp32 = Q_inp;
move16();
move16();
- IF( NE_32( ( error = stereo_set_tdm_fx( hCPE, input_frame, Q_inp ) ), IVAS_ERR_OK ) )
+ IF( ( error = stereo_set_tdm_fx( hCPE, input_frame, Q_inp ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -342,56 +366,62 @@ ivas_error ivas_cpe_enc_fx(
* Resets/updates in case of stereo switching
*----------------------------------------------------------------*/
shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
move16();
shift = getScaleFactor16( sts[1]->input_fx, input_frame );
- Scale_sig( sts[1]->input_fx, input_frame, shift );
+ Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */
sts[1]->q_inp = add( sts[1]->q_inp, shift );
move16();
shift = getScaleFactor16( sts[0]->old_input_signal_fx, input_frame );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift );
move16();
shift = getScaleFactor16( sts[0]->input_fx, input_frame );
- Scale_sig( sts[0]->input_fx, input_frame, shift );
+ Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[1]->q_inp, shift */
sts[0]->q_inp = add( sts[0]->q_inp, shift );
move16();
Word16 q_inp = s_min( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), s_min( sts[1]->q_inp, sts[1]->q_old_inp ) );
- Scale_sig( sts[1]->input_fx, input_frame, sub( q_inp, sts[1]->q_inp ) );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_inp, sts[1]->q_old_inp ) );
+ Scale_sig( sts[1]->input_fx, input_frame, sub( q_inp, sts[1]->q_inp ) ); /* q_inp */
+ Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_inp, sts[1]->q_old_inp ) ); /* q_inp */
sts[1]->q_inp = q_inp;
sts[1]->q_old_inp = q_inp;
- Scale_sig( sts[0]->input_fx, input_frame, sub( q_inp, sts[0]->q_inp ) );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_inp, sts[0]->q_old_inp ) );
+ move16();
+ move16();
+
+ Scale_sig( sts[0]->input_fx, input_frame, sub( q_inp, sts[0]->q_inp ) ); /* q_inp */
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_inp, sts[0]->q_old_inp ) ); /* q_inp */
sts[0]->q_inp = q_inp;
move16();
sts[0]->q_old_inp = q_inp;
move16();
- Scale_sig( sts[0]->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( q_inp, sub( Q15, sts[0]->exp_buf_speech_enc ) ) );
-
+ Scale_sig( sts[0]->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( q_inp, sub( Q15, sts[0]->exp_buf_speech_enc ) ) ); // q_inp
+ sts[0]->exp_buf_speech_enc = sub( Q15, q_inp );
+ move16();
stereo_switching_enc_fx( hCPE, sts[0]->old_input_signal_fx, input_frame, q_inp );
/*----------------------------------------------------------------*
* Temporal inter-channel alignment, stereo adjustment
*----------------------------------------------------------------*/
- Copy_Scale_sig_16_32( sts[0]->input_buff_fx, sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 );
+ Copy_Scale_sig_16_32( sts[0]->input_buff_fx, sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 ); /* Q6 + sts[0]->q_inp */
sts[0]->q_inp32 = add( Q6, sts[0]->q_inp );
move16();
- Copy_Scale_sig_16_32( sts[1]->input_buff_fx, sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 );
+ Copy_Scale_sig_16_32( sts[1]->input_buff_fx, sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 ); /* Q6 + sts[0]->q_inp */
sts[1]->q_inp32 = add( Q6, sts[1]->q_inp );
move16();
stereo_tca_enc_fx( hCPE, input_frame );
- Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, 0 ), sts[0]->q_inp32 ) );
- Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, 0 ), sts[1]->q_inp32 ) );
+ shift = s_min( 0, sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ) );
+ shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ) );
+ Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift
+ Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift
- sts[0]->q_inp = sts[1]->q_inp = sts[0]->q_old_inp = sts[1]->q_old_inp = 0;
+ sts[0]->q_inp = sts[1]->q_inp = sts[0]->q_old_inp = sts[1]->q_old_inp = shift;
move16();
move16();
move16();
@@ -402,14 +432,15 @@ ivas_error ivas_cpe_enc_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Scale_sig( sts[n]->input_fx, input_frame, sub( -1, sts[n]->q_inp ) );
- sts[n]->q_inp = -1;
- Copy( sts[n]->input_fx, orig_input_fx[n], input_frame );
+ Copy( sts[n]->input_fx, orig_input_fx[n], input_frame ); /* sts->q_inp */
+ Scale_sig( orig_input_fx[n], input_frame, sub( -1, sts[n]->q_inp ) ); // Q(-1)
+ Q_orig_inp[n] = -1;
+ move16();
IF( hCPE->hStereoICBWE != NULL )
{
- hCPE->hStereoICBWE->dataChan_fx[n] = &orig_input_fx[n][0];
- hCPE->hStereoICBWE->q_dataChan_fx = sts[n]->q_inp;
+ hCPE->hStereoICBWE->dataChan_fx[n] = &orig_input_fx[n][0]; // Q_orig_inp
+ hCPE->hStereoICBWE->q_dataChan_fx = Q_orig_inp[n];
move16();
}
}
@@ -467,23 +498,32 @@ ivas_error ivas_cpe_enc_fx(
IF( NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) && ( NE_32( hCPE->element_brate, hCPE->last_element_brate ) || NE_16( hCPE->last_element_mode, hCPE->element_mode ) || sts[0]->ini_frame == 0 ||
( NE_32( ivas_total_brate, st_ivas->hEncoderConfig->last_ivas_total_brate ) ) || LE_32( sts[0]->last_core_brate, SID_2k40 ) ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */
{
+ STEREO_DFT_CONFIG_DATA_HANDLE hConfig;
+ IF( hCPE->hStereoDft == NULL )
+ {
+ hConfig = NULL;
+ }
+ ELSE
+ {
+ hConfig = hCPE->hStereoDft->hConfig;
+ }
IF( st_ivas->hQMetaData != NULL )
{
test();
/* No Basop - st_ivas->ism_mode != ISM_MODE_NONE as comparison with 0 */
IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) && st_ivas->ism_mode != ISM_MODE_NONE )
{
- stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, L_mult0( st_ivas->hQMetaData->bits_frame_nominal, 35 /* 0.70f * FRAMES_PER_SEC */ ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ stereo_dft_config_fx( hConfig, L_mult0( st_ivas->hQMetaData->bits_frame_nominal, 35 /* 0.70f * FRAMES_PER_SEC */ ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
}
ELSE
{
- stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, L_mult0( st_ivas->hQMetaData->bits_frame_nominal, FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ stereo_dft_config_fx( hConfig, L_mult0( st_ivas->hQMetaData->bits_frame_nominal, FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
}
}
ELSE
{
/* note; "bits_frame_nominal" needed in TD stereo as well */
- stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ stereo_dft_config_fx( hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
}
}
@@ -491,8 +531,8 @@ ivas_error ivas_cpe_enc_fx(
{
IF( hCPE->hStereoTD->tdm_LRTD_flag )
{
- sts[0]->bits_frame_nominal = (int16_t) ( ( hCPE->element_brate >> 1 ) / FRAMES_PER_SEC );
- sts[1]->bits_frame_nominal = (int16_t) ( ( hCPE->element_brate >> 1 ) / FRAMES_PER_SEC );
+ sts[0]->bits_frame_nominal = extract_l( Mult_32_32( L_shr( hCPE->element_brate, 1 ), ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
+ sts[1]->bits_frame_nominal = extract_l( Mult_32_32( L_shr( hCPE->element_brate, 1 ), ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
}
ELSE
{
@@ -500,50 +540,75 @@ ivas_error ivas_cpe_enc_fx(
}
}
- if ( hCPE->element_mode == IVAS_CPE_MDCT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
/* compute bit-rate surplus per channel in combined format coding */
- int32_t brate_surplus[CPE_CHANNELS];
- if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+ Word32 brate_surplus[CPE_CHANNELS];
+ test();
+ test();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- brate_surplus[0] = ( ( hCPE->brate_surplus / FRAMES_PER_SEC ) >> 1 ) * FRAMES_PER_SEC;
- brate_surplus[1] = hCPE->brate_surplus - brate_surplus[0];
+ brate_surplus[0] = imult3216( L_shr( Mpy_32_32_r( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ), 1 ), FRAMES_PER_SEC ); /* Q0 */
+ brate_surplus[1] = L_sub( hCPE->brate_surplus, brate_surplus[0] ); /* Q0 */
+ move32();
+ move32();
}
/* this is just for initialization, the true values of "total_brate" and "bits_frame_channel" are set later */
- for ( n = 0; n < n_CoreChannels; n++ )
+ FOR( n = 0; n < n_CoreChannels; n++ )
{
- if ( st_ivas->hMCT )
+ IF( st_ivas->hMCT )
{
- int16_t lfe_bits;
- lfe_bits = ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ? st_ivas->hLFE->lfe_bits : 0 );
- sts[n]->total_brate = hCPE->element_brate;
- sts[n]->bits_frame_nominal = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC );
- sts[n]->bits_frame_channel = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC - lfe_bits - nb_bits_metadata ) / st_ivas->hMCT->nchan_out_woLFE );
+ Word16 lfe_bits;
+ test();
+ IF( EQ_16( ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) )
+ {
+ lfe_bits = st_ivas->hLFE->lfe_bits;
+ move16();
+ }
+ ELSE
+ {
+ lfe_bits = 0;
+ move16();
+ }
+ sts[n]->total_brate = hCPE->element_brate; /* Q0 */
+ sts[n]->bits_frame_nominal = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
+ sts[n]->bits_frame_channel = ( idiv1616( sub( sub( extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), lfe_bits ), nb_bits_metadata ), st_ivas->hMCT->nchan_out_woLFE ) ); /* Q0 */
+ move32();
+ move16();
+ move16();
}
- else
+ ELSE
{
- sts[n]->bits_frame_nominal = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC );
- sts[n]->bits_frame_channel = (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) / n_CoreChannels );
- sts[n]->total_brate = hCPE->element_brate / n_CoreChannels;
+ sts[n]->bits_frame_nominal = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
+ sts[n]->bits_frame_channel = idiv1616( extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), n_CoreChannels ); /* Q0 */
+ sts[n]->total_brate = L_shl( div_l( hCPE->element_brate, n_CoreChannels ), 1 ); /* Q0 */
+ move32();
+ move16();
+ move16();
/* subtract bit-rate for combined format coding */
- if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- sts[n]->bits_frame_channel += (int16_t) ( brate_surplus[n] / FRAMES_PER_SEC );
- sts[n]->total_brate += brate_surplus[n];
+ sts[n]->bits_frame_channel = add( sts[n]->bits_frame_channel, extract_l( Mpy_32_32_r( brate_surplus[n], ONE_BY_FRAMES_PER_SEC_Q31 ) ) ); /* Q0 */
+ sts[n]->total_brate = L_add( sts[n]->total_brate, brate_surplus[n] ); /* Q0 */
+ move32();
+ move16();
}
}
}
/* reconfiguration in case of bitrate switching */
- if ( hCPE->element_brate != hCPE->last_element_brate && st_ivas->hMCT == NULL )
+ IF( NE_32( hCPE->element_brate, hCPE->last_element_brate ) && st_ivas->hMCT == NULL )
{
#ifdef DEBUGGING
hCPE->hStereoMdct->mdct_stereo_mode_cmdl = hEncoderConfig->mdct_stereo_mode_cmdl;
#endif
initMdctStereoEncData_fx( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 0 );
- hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+ test();
+ test();
+ hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) && ( EQ_16( st_ivas->nchan_transport, 2 ) ) ); /* Q0 */
+ move16();
}
}
@@ -552,54 +617,53 @@ ivas_error ivas_cpe_enc_fx(
* Stereo down-mix
*----------------------------------------------------------------*/
// printf("\n%f %f ", hCPE->hStereoClassif->is_speech, hCPE->hCoreCoder[0]->hSpMusClas->past_dlp[0]);
- if ( hCPE->element_mode == IVAS_CPE_DFT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- /* flt2fix: to be removed */
#ifndef MSAN_FIX
hCPE->hStereoClassif->xtalk_score_fx = floatToFixed( hCPE->hStereoClassif->xtalk_score, 31 );
#endif // !MSAN_FIX
/*flt2fix: dft_synthesize*/
- if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
+ test();
+ if ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
{
sts[1]->exp_old_inp_12k8 = Q15;
move16();
}
- /*flt2fix end*/
-#endif
Word16 temp = getScaleFactor32( hCPE->hStereoDft->Spd_L_smooth_fx, STEREO_DFT_N_32k_ENC / 2 );
- scale_sig32( hCPE->hStereoDft->Spd_L_smooth_fx, STEREO_DFT_N_32k_ENC / 2, temp );
+ scale_sig32( hCPE->hStereoDft->Spd_L_smooth_fx, STEREO_DFT_N_32k_ENC / 2, temp ); /* exp(hCPE->hStereoDft->Spd_L_smooth_fx_e - temp)*/
hCPE->hStereoDft->Spd_L_smooth_fx_e = sub( hCPE->hStereoDft->Spd_L_smooth_fx_e, temp );
+ move16();
temp = getScaleFactor32( hCPE->hStereoDft->Spd_R_smooth_fx, STEREO_DFT_N_32k_ENC / 2 );
- scale_sig32( hCPE->hStereoDft->Spd_R_smooth_fx, STEREO_DFT_N_32k_ENC / 2, temp );
+ scale_sig32( hCPE->hStereoDft->Spd_R_smooth_fx, STEREO_DFT_N_32k_ENC / 2, temp ); /* exp(hCPE->hStereoDft->Spd_R_smooth_fx_e - temp) */
hCPE->hStereoDft->Spd_R_smooth_fx_e = sub( hCPE->hStereoDft->Spd_R_smooth_fx_e, temp );
+ move16();
shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
move16();
shift = getScaleFactor16( sts[1]->input_fx, input_frame );
- Scale_sig( sts[1]->input_fx, input_frame, shift );
+ Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */
sts[1]->q_inp = add( sts[1]->q_inp, shift );
move16();
- Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[1]->q_inp, sts[1]->q_old_inp ), sts[1]->q_inp ) );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( s_min( sts[1]->q_old_inp, sts[1]->q_inp ), sts[1]->q_old_inp ) );
+ Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[1]->q_inp, sts[1]->q_old_inp ), sts[1]->q_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp) */
+ Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( s_min( sts[1]->q_old_inp, sts[1]->q_inp ), sts[1]->q_old_inp ) ); /* min( sts[1]->q_old_inp, sts[1]->q_inp) */
sts[1]->q_inp = s_min( sts[1]->q_inp, sts[1]->q_old_inp );
move16();
sts[1]->q_old_inp = sts[1]->q_inp;
move16();
shift = getScaleFactor16( sts[0]->old_input_signal_fx, input_frame );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[0]->q_old_inp + shift */
sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift );
move16();
shift = getScaleFactor16( sts[0]->input_fx, input_frame );
- Scale_sig( sts[0]->input_fx, input_frame, shift );
+ Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[0]->q_inp + shift */
sts[0]->q_inp = add( sts[0]->q_inp, shift );
move16();
- Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), sts[0]->q_inp ) );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( s_min( sts[0]->q_old_inp, sts[0]->q_inp ), sts[0]->q_old_inp ) );
+ Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), sts[0]->q_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp) */
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( s_min( sts[0]->q_old_inp, sts[0]->q_inp ), sts[0]->q_old_inp ) ); /* min( sts[1]->q_old_inp, sts[1]->q_inp) */
sts[0]->q_inp = s_min( sts[0]->q_inp, sts[0]->q_old_inp );
move16();
sts[0]->q_old_inp = sts[0]->q_inp;
@@ -612,7 +676,7 @@ ivas_error ivas_cpe_enc_fx(
stereo_dft_enc_analyze_fx( sts, CPE_CHANNELS, input_frame, hCPE->hStereoDft, NULL, hCPE->hStereoDft->DFT_fx, hCPE->hStereoDft->DFT_fx_e, hCPE->input_mem_fx, hCPE->q_input_mem );
- sts[0]->total_brate = L_mult0( add( sts[0]->bits_frame_nominal, 10 ), FRAMES_PER_SEC ); /* add small overhead; st[0]->total_brate used in coder_type_modif() */
+ sts[0]->total_brate = L_mult0( add( sts[0]->bits_frame_nominal, 10 ), FRAMES_PER_SEC ); /* add small overhead; st[0]->total_brate used in coder_type_modif() Q0*/
/* Update DFT Stereo memories */
stereo_dft_enc_update_fx( hCPE->hStereoDft, sts[0]->max_bwidth );
@@ -620,26 +684,26 @@ ivas_error ivas_cpe_enc_fx(
/* DFT stereo processing */
stereo_dft_enc_process_fx( hCPE, vad_flag_dtx, vad_hover_flag, input_frame );
}
- else if ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
+ ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
- Scale_sig( sts[0]->input_fx, input_frame, negate( sts[0]->q_inp ) );
+ Scale_sig( sts[0]->input_fx, input_frame, negate( sts[0]->q_inp ) ); /* Q0 */
sts[0]->q_inp = 0;
move16();
- Scale_sig( sts[1]->input_fx, input_frame, negate( sts[1]->q_inp ) );
+ Scale_sig( sts[1]->input_fx, input_frame, negate( sts[1]->q_inp ) ); /* Q0 */
sts[1]->q_inp = 0;
move16();
/* Determine the energy ratio between the 2 channels */
tdm_ratio_idx = stereo_tdm_ener_analysis_fx(
ivas_format,
- hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM );
+ hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */
/* Compute the downmix signal based on the ratio index */
Word16 tdm_SM_flag;
IF( hCPE->hStereoTD->tdm_LRTD_flag == 0 )
{
- tdm_SM_flag = tdm_SM_or_LRTD_Pri;
+ tdm_SM_flag = tdm_SM_or_LRTD_Pri; /* Q0 */
move16();
}
ELSE
@@ -651,64 +715,64 @@ ivas_error ivas_cpe_enc_fx(
/* signal the bitrate for BW selection in the SCh */
sts[0]->bits_frame_channel = 0;
- sts[1]->bits_frame_channel = extract_l( Mpy_32_32( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
- sts[1]->bits_frame_channel = add( sts[1]->bits_frame_channel, extract_l( Mpy_32_32( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ) ) );
+ sts[1]->bits_frame_channel = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
+ sts[1]->bits_frame_channel = add( sts[1]->bits_frame_channel, extract_l( Mpy_32_32_r( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ) ) ); /* Q0 */
move16();
move16();
move16();
- IF( st_ivas->hQMetaData != NULL )
+ if ( st_ivas->hQMetaData != NULL )
{
- sts[1]->bits_frame_channel = sub( sts[1]->bits_frame_channel, st_ivas->hQMetaData->metadata_max_bits );
+ sts[1]->bits_frame_channel = sub( sts[1]->bits_frame_channel, st_ivas->hQMetaData->metadata_max_bits ); /* Q0 */
move16();
}
- Etot_last_fx[0] = sts[0]->hNoiseEst->Etot_last_fx;
- Etot_last_fx[1] = sts[1]->hNoiseEst->Etot_last_fx;
+ Etot_last_fx[0] = sts[0]->hNoiseEst->Etot_last_fx; /* Q8 */
+ Etot_last_fx[1] = sts[1]->hNoiseEst->Etot_last_fx; /* Q8 */
move16();
move16();
}
- else if ( hCPE->element_mode == IVAS_CPE_MDCT )
+ ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- if ( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
+ test();
+ IF( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
{
- if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
+ test();
+ if ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
{
sts[1]->exp_old_inp_12k8 = Q15;
move16();
}
}
-#endif
test();
IF( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
{
shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
move16();
shift = getScaleFactor16( sts[1]->input_fx, input_frame );
- Scale_sig( sts[1]->input_fx, input_frame, shift );
+ Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */
sts[1]->q_inp = add( sts[1]->q_inp, shift );
move16();
- Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[1]->q_inp, sts[1]->q_old_inp ), sts[1]->q_inp ) );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( s_min( sts[1]->q_old_inp, sts[1]->q_inp ), sts[1]->q_old_inp ) );
+ Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[1]->q_inp, sts[1]->q_old_inp ), sts[1]->q_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp ) */
+ Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( s_min( sts[1]->q_old_inp, sts[1]->q_inp ), sts[1]->q_old_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp ) */
sts[1]->q_inp = s_min( sts[1]->q_inp, sts[1]->q_old_inp );
move16();
sts[1]->q_old_inp = sts[1]->q_inp;
move16();
shift = getScaleFactor16( sts[0]->old_input_signal_fx, input_frame );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[0]->q_old_inp + shift*/
sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift );
move16();
shift = getScaleFactor16( sts[0]->input_fx, input_frame );
- Scale_sig( sts[0]->input_fx, input_frame, shift );
+ Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[0]->q_inp + shift */
sts[0]->q_inp = add( sts[0]->q_inp, shift );
move16();
move16();
- Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), sts[0]->q_inp ) );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( s_min( sts[0]->q_old_inp, sts[0]->q_inp ), sts[0]->q_old_inp ) );
+ Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), sts[0]->q_inp ) ); /* min( sts[0]->q_inp, sts[0]->q_old_inp ) */
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( s_min( sts[0]->q_old_inp, sts[0]->q_inp ), sts[0]->q_old_inp ) ); /* min( sts[0]->q_inp, sts[0]->q_old_inp ) */
sts[0]->q_inp = s_min( sts[0]->q_inp, sts[0]->q_old_inp );
move16();
sts[0]->q_old_inp = sts[0]->q_inp;
@@ -722,11 +786,19 @@ ivas_error ivas_cpe_enc_fx(
* DFT stereo: iDFT and resampling on both channels
*----------------------------------------------------------------*/
- if ( hCPE->element_mode == IVAS_CPE_DFT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- int32_t internal_Fs;
+ Word32 internal_Fs;
- internal_Fs = getTcxonly_ivas_fx( IVAS_CPE_MDCT, sts[0]->bits_frame_nominal * FRAMES_PER_SEC, 0, sts[0]->is_ism_format ) == 0 ? INT_FS_16k : max( INT_FS_16k, sts[0]->sr_core );
+ IF( getTcxonly_ivas_fx( IVAS_CPE_MDCT, imult1616( sts[0]->bits_frame_nominal, FRAMES_PER_SEC ), 0, sts[0]->is_ism_format ) == 0 )
+ {
+ internal_Fs = INT_FS_16k;
+ move32();
+ }
+ ELSE
+ {
+ internal_Fs = max( INT_FS_16k, sts[0]->sr_core );
+ }
/* iDFT at input sampling rate */
Word16 out_start_ind, out_end_ind;
@@ -742,9 +814,11 @@ 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, input_frame + STEREO_DFT_OVL_16k );
+ Copy32( sts[0]->input32_fx - STEREO_DFT_OVL_16k, old_inp_16k_fx[0] + L_INP_MEM - STEREO_DFT_OVL_16k, add( input_frame, STEREO_DFT_OVL_16k ) ); /* Q_inp */
out_16k_start_ind = -STEREO_DFT_OVL_16k;
- out_16k_end_ind = out_16k_start_ind + input_frame + STEREO_DFT_OVL_16k;
+ out_16k_end_ind = add( out_16k_start_ind, add( input_frame, STEREO_DFT_OVL_16k ) );
+ move16();
+ move16();
}
ELSE
{
@@ -755,27 +829,25 @@ ivas_error ivas_cpe_enc_fx(
test();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
{
- Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 16 - 0 );
+ Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 15 - 0 ); // Q15
stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM, &out_12k8_start_ind[1], &out_12k8_end_ind[1], 1, input_Fs, 8000, 0, NULL );
/* update old input signal buffer */
- Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 16 );
+ Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 15 ); // Q0
}
- Copy_Scale_sig32_16( sts[0]->input32_fx + out_start_ind, sts[0]->input_fx + out_start_ind, sub( out_end_ind, out_start_ind ), sub( add( Q16, sts[0]->q_inp ), Q16 ) );
+ Copy_Scale_sig32_16( sts[0]->input32_fx + out_start_ind, sts[0]->input_fx + out_start_ind, sub( out_end_ind, out_start_ind ), sub( add( Q16, sts[0]->q_inp ), Q15 ) ); // Q15
- Copy_Scale_sig32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, -1 ); // Q16->Q-1
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
+ Copy_Scale_sig32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, 0 ); // Q15->Q-1
/*local fix2flt*/
/*fix2flt: dft_synthesize*/
- Copy_Scale_sig_32_16( old_inp_12k8_fx[0] + L_INP_MEM + out_12k8_start_ind[0], old_inp_12k8_16fx[0] + L_INP_MEM + out_12k8_start_ind[0], out_12k8_end_ind[0] - out_12k8_start_ind[0], -Q17 );
+ Copy_Scale_sig_32_16( old_inp_12k8_fx[0] + L_INP_MEM + out_12k8_start_ind[0], old_inp_12k8_16fx[0] + L_INP_MEM + out_12k8_start_ind[0], out_12k8_end_ind[0] - out_12k8_start_ind[0], -Q16 ); // Q-1
if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
{
sts[1]->exp_old_inp_12k8 = Q15;
move16();
- Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_INP_MEM + out_12k8_start_ind[1], old_inp_12k8_16fx[1] + L_INP_MEM + out_12k8_start_ind[1], out_12k8_end_ind[1] - out_12k8_start_ind[1], -Q17 ); // Q-1
+ Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_INP_MEM + out_12k8_start_ind[1], old_inp_12k8_16fx[1] + L_INP_MEM + out_12k8_start_ind[1], out_12k8_end_ind[1] - out_12k8_start_ind[1], -Q16 ); // Q-1
}
- /*fix2flt end*/
-#endif
+
/* no iDFT at input sampling rate for Side channel -> reset the buffer */
set16_fx( sts[1]->input_fx, 0, input_frame );
sts[1]->q_inp = Q15;
@@ -799,11 +871,20 @@ ivas_error ivas_cpe_enc_fx(
set16_fx( old_wsp_fx[n], 0, L_WSP );
q_old_wsp = Q15;
move16();
+ Word16 front_vad_flag;
+ IF( st_ivas->hSpar != NULL )
+ {
+ front_vad_flag = st_ivas->hSpar->front_vad_flag;
+ }
+ ELSE
+ {
+ front_vad_flag = 0;
+ }
error = pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n],
&ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n],
realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n],
- fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, add( Q_buffer[n], QSCALE ), Etot_LR_fx, lf_E_fx, add( Q_buffer[n], QSCALE - 2 ), localVAD_HE_SAD,
- band_energies_LR_fx, sub( add( Q_buffer[n], QSCALE ), band_ener_guardbits ), 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate
+ fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD,
+ band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate, &Q_new[n]
#ifdef DEBUG_MODE_INFO
,
( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n )
@@ -811,7 +892,7 @@ ivas_error ivas_cpe_enc_fx(
);
e_old_wsp[n] = sub( Q15, q_old_wsp );
move16();
- if ( error != IVAS_ERR_OK )
+ IF( error != IVAS_ERR_OK )
{
return error;
}
@@ -825,33 +906,39 @@ ivas_error ivas_cpe_enc_fx(
fft_buff_fx_final_q = sub( fft_buff_fx_final_q, 2 ); // headroom
FOR( n = 0; n < n_CoreChannels; n++ )
{
- Scale_sig( fft_buff_fx[n], 2 * L_FFT, sub( fft_buff_fx_final_q, fft_buff_fx_q[n] ) );
+ Scale_sig( fft_buff_fx[n], 2 * L_FFT, sub( fft_buff_fx_final_q, fft_buff_fx_q[n] ) ); /* fft_buff_fx_final_q */
}
/* sanity check -> DTX not supported for more than one SCEs/CPEs */
- if ( st_ivas->nSCE + st_ivas->nCPE > 1 )
+ IF( GT_16( add( st_ivas->nSCE, st_ivas->nCPE ), 1 ) )
{
- if ( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA )
+ test();
+ IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA )
{
- sts[0]->core_brate = -1;
- sts[0]->total_brate = hCPE->element_brate;
+ sts[0]->core_brate = -1; /* Q0 */
+ sts[0]->total_brate = hCPE->element_brate; /* Q0 */
+ move32();
+ move32();
}
}
/*----------------------------------------------------------------*
* Stereo DTX updates
*----------------------------------------------------------------*/
-
- if ( ivas_format == MASA_FORMAT && nb_bits_metadata > 0 && hCPE->hCoreCoder[0]->Opt_DTX_ON )
+ test();
+ test();
+ IF( EQ_16( ivas_format, MASA_FORMAT ) && nb_bits_metadata > 0 && hCPE->hCoreCoder[0]->Opt_DTX_ON )
{
- if ( hCPE->element_mode == IVAS_CPE_DFT || hCPE->element_mode == IVAS_CPE_TD )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) || EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
reset_metadata_spatial_fx( ivas_format, hCPE->hMetaData, hCPE->element_brate, &tmp, sts[0]->core_brate, nb_bits_metadata );
}
}
/* MDCT stereo DTX: active/inactive frame decision; compute FD CNG coherence */
- if ( hCPE->element_mode == IVAS_CPE_MDCT && hEncoderConfig->Opt_DTX_ON )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && hEncoderConfig->Opt_DTX_ON )
{
stereoFdCngCoherence_fx( sts, hCPE->last_element_mode, fft_buff_fx, sub( 15, fft_buff_fx_final_q ) /*fft exp*/ );
@@ -878,27 +965,36 @@ ivas_error ivas_cpe_enc_fx(
IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) ) && ( n == 0 || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) )
{
Word16 igf;
- igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->rf_mode );
- IF( NE_32( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ), IVAS_ERR_OK ) )
+ igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->rf_mode ); /* Q0 */
+ IF( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- if ( hCPE->element_mode == IVAS_CPE_MDCT && st_ivas->hMCT == NULL )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && st_ivas->hMCT == NULL )
{
/* set coded BW for MDCT stereo */
set_bw_stereo_fx( hCPE );
/* reconfiguration of MDCT stereo */
- if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) )
+ test();
+ test();
+ test();
+ IF( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) )
{
initMdctStereoEncData_fx( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 );
- hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
- if ( hCPE->element_brate <= MAX_MDCT_ITD_BRATE && ivas_format == STEREO_FORMAT )
+ test();
+ test();
+ test();
+ hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) && ( EQ_16( st_ivas->nchan_transport, 2 ) ) ); /* Q0 */
+
+ test();
+ IF( LE_32( hCPE->element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) )
{
- IF( NE_32( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -907,20 +1003,24 @@ ivas_error ivas_cpe_enc_fx(
}
/* set ACELP@12k8 / ACELP@16k flag for flexible ACELP core */
- for ( n = 0; n < n_CoreChannels; n++ )
+ FOR( n = 0; n < n_CoreChannels; n++ )
{
- if ( ( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA ) && hCPE->element_mode == IVAS_CPE_DFT )
+ test();
+ test();
+ IF( ( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- sts[n]->flag_ACELP16k = set_ACELP_flag_IVAS( hCPE->element_mode, hCPE->element_brate, sts[n]->core_brate, n, sts[0]->tdm_LRTD_flag, sts[n]->bwidth, sts[n]->cng_type );
+ sts[n]->flag_ACELP16k = set_ACELP_flag_IVAS( hCPE->element_mode, hCPE->element_brate, sts[n]->core_brate, n, sts[0]->tdm_LRTD_flag, sts[n]->bwidth, sts[n]->cng_type ); /* Q0 */
+ move16();
}
- else
+ ELSE
{
- sts[n]->flag_ACELP16k = set_ACELP_flag_IVAS( hCPE->element_mode, hCPE->element_brate, sts[n]->total_brate, n, sts[0]->tdm_LRTD_flag, sts[n]->bwidth, sts[n]->cng_type );
+ sts[n]->flag_ACELP16k = set_ACELP_flag_IVAS( hCPE->element_mode, hCPE->element_brate, sts[n]->total_brate, n, sts[0]->tdm_LRTD_flag, sts[n]->bwidth, sts[n]->cng_type ); /* Q0 */
+ move16();
}
}
/* configure TD stereo encoder */
- if ( hCPE->element_mode == IVAS_CPE_TD )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
tdm_ol_pitch_comparison_fx( hCPE, pitch_fr_fx, voicing_fr_fx );
tdm_configure_enc_fx( ivas_format, st_ivas->ism_mode, hCPE, Etot_last_fx, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata );
@@ -964,7 +1064,7 @@ ivas_error ivas_cpe_enc_fx(
IF( hEncoderConfig->Opt_DTX_ON )
{
test();
- IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || EQ_32( sts[0]->core_brate, FRAME_NO_DATA ) )
+ IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA )
{
/* Reconfigure DFT Stereo for inactive frames */
IF( EQ_32( sts[0]->core_brate, SID_2k40 ) )
@@ -985,7 +1085,7 @@ ivas_error ivas_cpe_enc_fx(
}
/* Write stereo bitstream */
- cpe_brate = st_ivas->hCPE[0]->element_brate;
+ cpe_brate = st_ivas->hCPE[0]->element_brate; /* Q0 */
move16();
/* DFT stereo side bits */
@@ -996,14 +1096,14 @@ ivas_error ivas_cpe_enc_fx(
test();
test();
test();
- IF( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && LT_32( cpe_brate, MASA_STEREO_MIN_BITRATE ) && NE_32( sts[0]->core_brate, SID_2k40 ) && NE_32( sts[0]->core_brate, FRAME_NO_DATA ) )
+ IF( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && LT_32( cpe_brate, MASA_STEREO_MIN_BITRATE ) && NE_32( sts[0]->core_brate, SID_2k40 ) && sts[0]->core_brate != FRAME_NO_DATA )
{
nb_bits = 0; /* Only mono downmix is transmitted in this case */
move16();
}
- ELSE IF( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && ( EQ_32( sts[0]->core_brate, SID_2k40 ) || EQ_32( sts[0]->core_brate, FRAME_NO_DATA ) ) )
+ ELSE IF( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && ( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA ) )
{
- nb_bits = hCPE->hMetaData->nb_bits_tot;
+ nb_bits = hCPE->hMetaData->nb_bits_tot; /* Q0 */
move16();
}
ELSE
@@ -1012,44 +1112,51 @@ ivas_error ivas_cpe_enc_fx(
}
/* Residual coding in MDCT domain */
- if ( !( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && ( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA ) ) )
+ test();
+ test();
+ IF( !( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && ( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA ) ) )
{
- int16_t max_bits = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC - 0.8f * sts[0]->bits_frame_nominal );
- if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT )
+ Word16 max_bits = extract_l( L_sub( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ), Mult_32_16( sts[0]->bits_frame_nominal, 26214 /* 0.8f in Q15 */ ) ) );
+ test();
+ IF( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) )
{
- max_bits -= nb_bits_metadata;
- if ( hCPE->brate_surplus < 0 )
+ max_bits = sub( max_bits, nb_bits_metadata );
+ IF( hCPE->brate_surplus < 0 )
{
- max_bits += (int16_t) ( hCPE->brate_surplus / FRAMES_PER_SEC );
+ max_bits = add( max_bits, extract_l( Mpy_32_32_r( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ) ) );
}
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- FOR( int i = 0; i < CPE_CHANNELS; i++ )
+ FOR( Word16 i = 0; i < CPE_CHANNELS; i++ )
{
- Copy_Scale_sig_16_32( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], Q16 + Q1, L_INP_12k8 );
+ Copy_Scale_sig_16_32( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 + Q1 );
}
-#endif
stereo_dft_enc_res_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM - STEREO_DFT_OVL_8k, hCPE->hMetaData, &nb_bits, max_bits );
}
- if ( sts[0]->core_brate == FRAME_NO_DATA || sts[0]->core_brate == SID_2k40 )
+ IF( sts[0]->core_brate == FRAME_NO_DATA || EQ_32( sts[0]->core_brate, SID_2k40 ) )
{
assert( ( nb_bits <= ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS ) ) && "Stereo DFT CNG: bit budget is violated" );
}
- else
+ ELSE
{
/* Flexible total bitrate in M channel */
- sts[0]->total_brate = hCPE->element_brate - ( nb_bits * FRAMES_PER_SEC );
+ sts[0]->total_brate = L_sub( hCPE->element_brate, L_deposit_l( imult1616( nb_bits, FRAMES_PER_SEC ) ) );
+ move32();
}
/* subtract metadata bitbudget */
- sts[0]->total_brate -= ( nb_bits_metadata * FRAMES_PER_SEC );
+ sts[0]->total_brate = L_sub( sts[0]->total_brate, L_deposit_l( imult1616( nb_bits_metadata, FRAMES_PER_SEC ) ) );
+ move32();
/* subtract bit-rate for combined format coding */
- if ( ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )
+ test();
+ test();
+ test();
+ if ( EQ_16( ivas_format, MASA_ISM_FORMAT ) && ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) )
{
- sts[0]->total_brate += hCPE->brate_surplus;
+ sts[0]->total_brate = L_add( sts[0]->total_brate, hCPE->brate_surplus );
+ move32();
}
}
@@ -1060,11 +1167,11 @@ ivas_error ivas_cpe_enc_fx(
FOR( n = 0; n < n_CoreChannels; n++ )
{
- Scale_sig( old_wsp_fx[n], L_WSP, sub( e_old_wsp[n], Q16 ) );
+ Scale_sig( old_wsp_fx[n], L_WSP, sub( e_old_wsp[n], Q16 ) ); /* exp(16) */
e_old_wsp[n] = 16;
move16();
}
- IF( NE_32( ( error = ivas_core_enc( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8_16fx, old_inp_16k_16fx, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_core_enc_fx( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8_16fx, old_inp_16k_16fx, Q_new, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1073,50 +1180,65 @@ ivas_error ivas_cpe_enc_fx(
* Common updates
*----------------------------------------------------------------*/
- hCPE->last_element_brate = hCPE->element_brate;
- hCPE->last_element_mode = hCPE->element_mode;
+ hCPE->last_element_brate = hCPE->element_brate; /* Q0 */
+ move32();
+ hCPE->last_element_mode = hCPE->element_mode; /* Q0 */
+ move16();
- if ( ivas_format == MASA_ISM_FORMAT )
+ if ( EQ_16( ivas_format, MASA_ISM_FORMAT ) )
{
- hCPE->element_brate = element_brate_ref;
+ hCPE->element_brate = element_brate_ref; /* Q0 */
+ move32();
}
- if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
{
/* update input samples buffer */
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Copy( orig_input_fx[n], sts[n]->old_input_signal_fx, input_frame );
- sts[n]->q_old_inp = sts[n]->q_inp;
+ Copy( orig_input_fx[n], sts[n]->old_input_signal_fx, input_frame ); /* Q_orig_inp */
+ sts[n]->q_old_inp = Q_orig_inp[n];
+ move16();
}
}
- else if ( hCPE->element_mode == IVAS_CPE_DFT )
+ ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- Copy( sts[0]->input_fx, sts[0]->old_input_signal_fx, input_frame );
+ Copy( sts[0]->input_fx, sts[0]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */
sts[0]->q_old_inp = sts[0]->q_inp;
+ move16();
}
- else if ( st_ivas->hMCT == NULL ) /* note: in MCT, input buffers are updated later in ivas_mct_enc() */
+ ELSE IF( st_ivas->hMCT == NULL ) /* note: in MCT, input buffers are updated later in ivas_mct_enc() */
{
/* update input samples buffer */
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Copy( sts[n]->input_fx, sts[n]->old_input_signal_fx, input_frame );
+ Copy( sts[n]->input_fx, sts[n]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */
sts[n]->q_old_inp = sts[n]->q_inp;
+ move16();
}
}
- if ( hCPE->hFrontVad[0] != NULL )
+ IF( hCPE->hFrontVad[0] != NULL )
{
- hCPE->hFrontVad[0]->ini_frame++;
- hCPE->hFrontVad[0]->ini_frame = min( hCPE->hFrontVad[0]->ini_frame, MAX_FRAME_COUNTER );
+ hCPE->hFrontVad[0]->ini_frame = add( hCPE->hFrontVad[0]->ini_frame, 1 );
+ hCPE->hFrontVad[0]->ini_frame = s_min( hCPE->hFrontVad[0]->ini_frame, MAX_FRAME_COUNTER );
+ move16();
+ move16();
}
/* Store previous attack detection flag */
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ sts[n]->hTranDet->transientDetector.prev_bIsAttackPresent = sts[n]->hTranDet->transientDetector.bIsAttackPresent; /* Q0 */
+ move16();
+ }
+
+ IF( Q_new_out )
{
- sts[n]->hTranDet->transientDetector.prev_bIsAttackPresent = sts[n]->hTranDet->transientDetector.bIsAttackPresent;
+ Copy( Q_new, Q_new_out, CPE_CHANNELS );
}
+
#ifdef DEBUG_MODE_INFO
{
float tmpF = ivas_total_brate / 1000.0f;
@@ -1135,8 +1257,8 @@ ivas_error ivas_cpe_enc_fx(
*-------------------------------------------------------------------------*/
ivas_error create_cpe_enc_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 cpe_id, /* i : CPE # identifier */
- const Word32 element_brate /* i : element bitrate */
+ const Word16 cpe_id, /* i : CPE # identifier Q0*/
+ const Word32 element_brate /* i : element bitrate Q0*/
)
{
Word16 n;
@@ -1153,11 +1275,11 @@ ivas_error create_cpe_enc_fx(
ivas_format = hEncoderConfig->ivas_format;
move16();
- element_mode_init = hEncoderConfig->element_mode_init;
+ element_mode_init = hEncoderConfig->element_mode_init; /* Q0 */
move16();
- input_Fs = hEncoderConfig->input_Fs;
+ input_Fs = hEncoderConfig->input_Fs; /* Q0 */
move16();
- max_bwidth = hEncoderConfig->max_bwidth;
+ max_bwidth = hEncoderConfig->max_bwidth; /* Q0 */
move16();
/*-----------------------------------------------------------------*
@@ -1173,15 +1295,15 @@ ivas_error create_cpe_enc_fx(
* Initialization - general parameters
*-----------------------------------------------------------------*/
- hCPE->cpe_id = cpe_id;
+ hCPE->cpe_id = cpe_id; /* Q0 */
move16();
- hCPE->element_brate = element_brate;
+ hCPE->element_brate = element_brate; /* Q0 */
move16();
- hCPE->last_element_brate = hCPE->element_brate;
+ hCPE->last_element_brate = hCPE->element_brate; /* Q0 */
move16();
- hCPE->element_mode = element_mode_init;
+ hCPE->element_mode = element_mode_init; /* Q0 */
move16();
- hCPE->last_element_mode = element_mode_init;
+ hCPE->last_element_mode = element_mode_init; /* Q0 */
move16();
hCPE->hStereoDft = NULL;
@@ -1242,7 +1364,7 @@ ivas_error create_cpe_enc_fx(
IF( EQ_16( cpe_id, sub( st_ivas->nCPE, 1 ) ) )
{
- IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( hCPE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_initialize_MD_bstr_enc_fx( &( hCPE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1263,12 +1385,12 @@ ivas_error create_cpe_enc_fx(
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- st->total_brate = hCPE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st->total_brate = hCPE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
}
ELSE
{
- st->total_brate = L_shr( hCPE->element_brate, 1 ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st->total_brate = L_shr( hCPE->element_brate, 1 ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
}
st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
@@ -1280,7 +1402,8 @@ ivas_error create_cpe_enc_fx(
IF( st->hFdCngEnc != NULL )
{
- st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 );
+ st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 ); /* Q0 */
+ move32();
}
hCPE->hCoreCoder[n] = st;
@@ -1316,7 +1439,7 @@ ivas_error create_cpe_enc_fx(
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- IF( NE_32( ( error = front_vad_create_fx( &( hCPE->hFrontVad[n] ), hEncoderConfig ) ), IVAS_ERR_OK ) )
+ IF( ( error = front_vad_create_fx( &( hCPE->hFrontVad[n] ), hEncoderConfig ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1336,7 +1459,7 @@ ivas_error create_cpe_enc_fx(
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- IF( NE_32( ( error = stereo_dft_enc_create_fx( &( hCPE->hStereoDft ), input_Fs, max_bwidth ) ), IVAS_ERR_OK ) )
+ IF( ( error = stereo_dft_enc_create_fx( &( hCPE->hStereoDft ), input_Fs, max_bwidth ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1376,7 +1499,7 @@ ivas_error create_cpe_enc_fx(
IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
- if ( ( hCPE->hStereoTD = (STEREO_TD_ENC_DATA_HANDLE) malloc( sizeof( STEREO_TD_ENC_DATA ) ) ) == NULL )
+ IF( ( hCPE->hStereoTD = (STEREO_TD_ENC_DATA_HANDLE) malloc( sizeof( STEREO_TD_ENC_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD Stereo\n" ) );
}
@@ -1387,6 +1510,7 @@ ivas_error create_cpe_enc_fx(
* MDCT stereo initialization
*-----------------------------------------------------------------*/
+ test();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_ivas->nCPE, 1 ) )
{
IF( ( hCPE->hStereoMdct = (STEREO_MDCT_ENC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL )
@@ -1396,15 +1520,34 @@ ivas_error create_cpe_enc_fx(
#ifdef DEBUGGING
hCPE->hStereoMdct->mdct_stereo_mode_cmdl = st_ivas->hEncoderConfig->mdct_stereo_mode_cmdl;
+#ifdef DEBUG_FORCE_MDCT_STEREO_MODE
+ /*set all other members to defined states */
+ hCPE->hStereoMdct->fDualMono = 0;
+ hCPE->hStereoMdct->fMSstereo = 0;
+
+ if ( hCPE->hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_LR )
+ {
+ hCPE->hStereoMdct->fDualMono = 1;
+ }
+ else if ( hCPE->hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_MS )
+ {
+ hCPE->hStereoMdct->fMSstereo = 1;
+ }
+#endif
#endif
initMdctStereoEncData_fx( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 1 );
+
+ test();
+ test();
hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) && EQ_16( st_ivas->nchan_transport, 2 ) );
+ move16();
+
test();
test();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && LE_32( element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) )
{
- IF( NE_32( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1443,7 +1586,7 @@ void destroy_cpe_enc(
}
}
- ivas_destroy_MD_bstr_enc( &( hCPE->hMetaData ) );
+ ivas_destroy_MD_bstr_enc_fx( &( hCPE->hMetaData ) );
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -1525,7 +1668,7 @@ static void stereo_mode_combined_format_enc_fx(
IF( EQ_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
- element_brate_ref = hCPE->element_brate;
+ element_brate_ref = hCPE->element_brate; /* Q0 */
move32();
test();
@@ -1543,9 +1686,9 @@ static void stereo_mode_combined_format_enc_fx(
}
ELSE
{
- st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt = add( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, 1 );
+ st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt = add( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, 1 ); /* Q0 */
move16();
- st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt = s_min( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX );
+ st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt = s_min( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX ); /* Q0 */
move16();
}
@@ -1555,7 +1698,7 @@ static void stereo_mode_combined_format_enc_fx(
move16();
hCPE->element_brate = IVAS_64k;
move32();
- hCPE->brate_surplus = L_sub( hCPE->brate_surplus, L_sub( hCPE->element_brate, element_brate_ref ) );
+ hCPE->brate_surplus = L_sub( hCPE->brate_surplus, L_sub( hCPE->element_brate, element_brate_ref ) ); /* Q0 */
move32();
}
@@ -1570,6 +1713,5 @@ static void stereo_mode_combined_format_enc_fx(
}
}
}
-
return;
}
diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c
index 84939b6024d105b136501dddd94932b742ef7c7d..0ecafc6c3fdb42a50ac19a840dff857d14def364 100644
--- a/lib_enc/ivas_decision_matrix_enc.c
+++ b/lib_enc/ivas_decision_matrix_enc.c
@@ -74,11 +74,11 @@
void ivas_decision_matrix_enc_fx(
Encoder_State *st, /* i : encoder state structure */
- const Word32 element_brate, /* i : element bitrate */
- const Word16 fft_buff[], /* i : FFT buffer */
- const Word32 enerBuffer[], /* i : energy buffer */
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word16 fft_buff[], /* i : FFT buffer Qx*/
+ const Word32 enerBuffer[], /* i : energy buffer enerBuffer_exp*/
Word16 enerBuffer_exp,
- const Word16 last_element_mode /* i : last element mode */
+ const Word16 last_element_mode /* i : last element mode Q0*/
)
{
Word32 icbwe_brate;
@@ -96,7 +96,7 @@ void ivas_decision_matrix_enc_fx(
st->extl_brate = 0;
move16();
- IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
+ if ( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
st->igf = 0;
move16();
@@ -106,13 +106,13 @@ void ivas_decision_matrix_enc_fx(
test();
/* SID and FRAME_NO_DATA frames */
- IF( st->Opt_DTX_ON && ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) )
+ IF( st->Opt_DTX_ON && ( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) )
{
st->core = ACELP_CORE;
move16();
test();
- IF( GE_32( st->input_Fs, 32000 ) || GE_16( st->bwidth, SWB ) )
+ if ( GE_32( st->input_Fs, 32000 ) || GE_16( st->bwidth, SWB ) )
{
st->extl = SWB_CNG;
move16();
@@ -195,7 +195,7 @@ void ivas_decision_matrix_enc_fx(
ELSE
{
/* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */
- st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, enerBuffer_exp, ( st->bits_frame_nominal * FRAMES_PER_SEC ) );
+ st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, enerBuffer_exp, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */
move16();
}
}
@@ -208,14 +208,14 @@ void ivas_decision_matrix_enc_fx(
test();
/* do not allow TD stereo ACELP core -> DFT stereo TCX core switching as it is on the WC complexity path */
- IF( ( ( EQ_16( st->last_core, ACELP_CORE ) && EQ_16( last_element_mode, IVAS_CPE_TD ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || ( EQ_16( st->tdm_LRTD_flag, 1 ) && LE_32( st->total_brate, IVAS_16k4 ) ) ) && EQ_16( st->core, TCX_20_CORE ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) /* Override TCX in case of LRTD && primary channel has low bitrate*/
+ if ( ( ( st->last_core == ACELP_CORE && EQ_16( last_element_mode, IVAS_CPE_TD ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || ( EQ_16( st->tdm_LRTD_flag, 1 ) && LE_32( st->total_brate, IVAS_16k4 ) ) ) && EQ_16( st->core, TCX_20_CORE ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) /* Override TCX in case of LRTD && primary channel has low bitrate*/
{
st->core = ACELP_CORE;
move16();
}
test();
- IF( st->is_ism_format && st->tcxonly )
+ if ( st->is_ism_format && st->tcxonly )
{
st->core = TCX_20_CORE;
move16();
@@ -276,7 +276,7 @@ void ivas_decision_matrix_enc_fx(
move16();
move16();
- IF( st->low_rate_mode )
+ if ( st->low_rate_mode )
{
st->coder_type = INACTIVE;
move16();
@@ -288,7 +288,7 @@ void ivas_decision_matrix_enc_fx(
test();
test();
test();
- IF( st->is_ism_format && st->flag_ACELP16k && !st->low_rate_mode && EQ_16( st->core, ACELP_CORE ) && LT_32( st->total_brate, add( ACELP_16k_LOW_LIMIT, FB_TBE_1k8 ) ) )
+ if ( st->is_ism_format && st->flag_ACELP16k && !st->low_rate_mode && st->core == ACELP_CORE && LT_32( st->total_brate, add( ACELP_16k_LOW_LIMIT, FB_TBE_1k8 ) ) )
{
st->core = TCX_20_CORE;
move16();
@@ -298,15 +298,15 @@ void ivas_decision_matrix_enc_fx(
* Select ACELP and GSC extension layer
*---------------------------------------------------------------------*/
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
/* WB */
+ test();
IF( EQ_16( st->bwidth, WB ) )
{
test();
test();
test();
- test();
IF( LT_32( st->total_brate, MIN_BRATE_WB_BWE ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) )
{
st->extl = WB_BWE;
@@ -316,7 +316,7 @@ void ivas_decision_matrix_enc_fx(
{
test();
test();
- IF( ( EQ_16( st->sp_aud_decision1, 1 ) && st->sp_aud_decision2 == 0 ) || EQ_16( st->coder_type, INACTIVE ) )
+ IF( ( EQ_16( st->sp_aud_decision1, 1 ) && st->sp_aud_decision2 == 0 ) || st->coder_type == INACTIVE )
{
st->extl = WB_BWE;
move16();
@@ -361,7 +361,7 @@ void ivas_decision_matrix_enc_fx(
test();
test();
test();
- IF( ( ( ( EQ_16( st->sp_aud_decision1, 1 ) && st->sp_aud_decision2 == 0 ) || EQ_16( st->coder_type, INACTIVE ) ) && !st->GSC_noisy_speech ) /* Note: SWB BWE is not used for GSC noisy speech */ )
+ IF( ( ( ( EQ_16( st->sp_aud_decision1, 1 ) && st->sp_aud_decision2 == 0 ) || st->coder_type == INACTIVE ) && !st->GSC_noisy_speech ) /* Note: SWB BWE is not used for GSC noisy speech */ )
{
st->extl = SWB_BWE;
move16();
@@ -423,7 +423,7 @@ void ivas_decision_matrix_enc_fx(
test();
test();
- IF( GE_32( st->total_brate, MIN_BRATE_SWB_TBE_2k80 ) && st->flag_ACELP16k && EQ_16( st->element_mode, IVAS_SCE ) )
+ if ( GE_32( st->total_brate, MIN_BRATE_SWB_TBE_2k80 ) && st->flag_ACELP16k && EQ_16( st->element_mode, IVAS_SCE ) )
{
st->extl_brate = FB_TBE_3k0;
move32();
@@ -448,7 +448,7 @@ void ivas_decision_matrix_enc_fx(
icbwe_brate = STEREO_BITS_ICBWE * FRAMES_PER_SEC;
move32();
- IF( st->flag_ACELP16k == 0 )
+ if ( st->flag_ACELP16k == 0 )
{
icbwe_brate = ( STEREO_BITS_ICBWE - STEREO_ICBWE_SPBITS ) * FRAMES_PER_SEC;
move32();
@@ -459,7 +459,7 @@ void ivas_decision_matrix_enc_fx(
icbwe_brate = STEREO_BITS_ICBWE_DFT * FRAMES_PER_SEC;
move32();
- IF( st->flag_ACELP16k == 0 )
+ if ( st->flag_ACELP16k == 0 )
{
icbwe_brate = ( STEREO_BITS_ICBWE_DFT - STEREO_ICBWE_SPBITS ) * FRAMES_PER_SEC;
move32();
@@ -471,9 +471,9 @@ void ivas_decision_matrix_enc_fx(
test();
test();
test();
- if ( GE_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) )
+ if ( GE_16( st->element_mode, IVAS_CPE_DFT ) && st->core == ACELP_CORE && ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) )
{
- icbwe_brate = L_add( icbwe_brate, STEREO_ICBWE_MSFLAG_BITS * FRAMES_PER_SEC );
+ icbwe_brate = L_add( icbwe_brate, STEREO_ICBWE_MSFLAG_BITS * FRAMES_PER_SEC ); /* Q0 */
move32();
}
}
@@ -481,19 +481,19 @@ void ivas_decision_matrix_enc_fx(
/* set core bitrate */
- st->core_brate = L_sub( L_sub( st->total_brate, st->extl_brate ), icbwe_brate );
+ st->core_brate = L_sub( L_sub( st->total_brate, st->extl_brate ), icbwe_brate ); /* Q0 */
move32();
IF( st->ini_frame == 0 )
{
/* avoid core switching in the very first frame */
- st->last_core = st->core;
+ st->last_core = st->core; /* Q0 */
move16();
- st->last_core_brate = st->core_brate;
+ st->last_core_brate = st->core_brate; /* Q0 */
move32();
- st->last_extl = st->extl;
+ st->last_extl = st->extl; /* Q0 */
move16();
}
@@ -504,7 +504,7 @@ void ivas_decision_matrix_enc_fx(
st->inactive_coder_type_flag = 0; /* AVQ by default */
move16();
- IF( LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) )
+ if ( LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) )
{
st->inactive_coder_type_flag = 1; /* GSC */
move16();
@@ -520,11 +520,11 @@ void ivas_decision_matrix_enc_fx(
*---------------------------------------------------------------------*/
void ivas_signaling_enc_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word32 element_brate, /* i : element bitrate */
- const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */
- const Word16 tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag in TD stereo */
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel Q0*/
+ const Word16 tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag in TD stereo Q0*/
)
{
Word16 ind;
@@ -559,7 +559,7 @@ void ivas_signaling_enc_fx(
test();
IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && !MCT_flag ) /* note: in MCT, the MDCT stereo is used exclusively */
{
- ind = sub( st->element_mode, IVAS_CPE_DFT );
+ ind = sub( st->element_mode, IVAS_CPE_DFT ); /* Q0 */
push_indice( hBstr, IND_SMODE, ind, NBITS_ELEMENT_MODE );
}
@@ -579,7 +579,7 @@ void ivas_signaling_enc_fx(
( LT_32( element_brate, MIN_BRATE_FB_ISM ) && st->is_ism_format ) )
{
/* WB and SWB are supported */
- ind = sub( st->bwidth, WB );
+ ind = sub( st->bwidth, WB ); /* Q0 */
push_indice( hBstr, IND_BWIDTH, ind, 1 );
}
ELSE
@@ -597,7 +597,7 @@ void ivas_signaling_enc_fx(
test();
IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || GE_32( st->total_brate, STEREO_TCX_MIN_RATE ) )
{
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
push_indice( hBstr, IND_CORE, 0, 1 );
}
@@ -611,7 +611,7 @@ void ivas_signaling_enc_fx(
* Write core dependent signaling
*--------------------------------------------------------------------------*/
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
/* write coder type */
push_indice( hBstr, IND_ACELP_SIGNALLING, st->coder_type, 3 );
diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c
index 51a446d383139b0704527c62aaa3ca7bbc170f4a..58a916858f789a241ff886158dd6951e3e79d27b 100644
--- a/lib_enc/ivas_dirac_enc.c
+++ b/lib_enc/ivas_dirac_enc.c
@@ -53,7 +53,13 @@ static void computeIntensityVector_enc_fx(
Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],
const Word16 enc_param_start_band, /* i : first band to process */
const Word16 num_frequency_bands,
- Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS] );
+ Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS]
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ Word16 q_cldfb,
+ Word16 q_intensity_real[DIRAC_MAX_NBANDS]
+#endif
+);
/*-------------------------------------------------------------------------
* ivas_dirac_enc_open()
@@ -82,7 +88,7 @@ ivas_error ivas_dirac_enc_open_fx(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC Config\n" ) );
}
- hDirAC->firstrun_sector_params = 1;
+ hDirAC->firstrun_sector_params = 1; /* Q0 */
move16();
set32_fx( hDirAC->sec_I_vec_smth_x_fx[0], 0, NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS );
@@ -101,7 +107,7 @@ ivas_error ivas_dirac_enc_open_fx(
st_ivas->hDirAC = hDirAC;
- IF( NE_32( ( error = ivas_dirac_config_fx( (void *) st_ivas, ENC ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_dirac_config_fx( (void *) st_ivas, ENC ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -112,7 +118,7 @@ ivas_error ivas_dirac_enc_open_fx(
FOR( i = 0; i < DIRAC_MAX_NBANDS + 1; i++ )
{
/* adapt band grouping to from CLDFB to MDFT bands */
- hDirAC->band_grouping[i] = imult1616( hDirAC->band_grouping[i], CLDFB_TO_MDFT_FAC );
+ hDirAC->band_grouping[i] = imult1616( hDirAC->band_grouping[i], CLDFB_TO_MDFT_FAC ); /* Q0 */
move16();
}
dirac_slot_ns = DIRAC_SLOT_ENC_NS;
@@ -139,7 +145,7 @@ ivas_error ivas_dirac_enc_open_fx(
Word16 tmp_e = 0;
move16();
- Word16 tmp = BASOP_Util_Divide3232_Scale( (Word32) DIRAC_NO_COL_AVG_DIFF_NS, dirac_slot_ns, &tmp_e );
+ Word16 tmp = BASOP_Util_Divide3232_Scale( (Word32) DIRAC_NO_COL_AVG_DIFF_NS, dirac_slot_ns, &tmp_e ); /* exp(tmp_e) */
hDirAC->no_col_avg_diff = shr( tmp, sub( 15, tmp_e ) );
move16();
@@ -188,7 +194,7 @@ ivas_error ivas_dirac_enc_open_fx(
move16();
st_ivas->hDirAC = hDirAC;
- st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
+ st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; /* Q0 */
move16();
return error;
@@ -245,7 +251,7 @@ ivas_error ivas_dirac_enc_reconfigure(
*------------------------------------------------------------------------*/
void ivas_dirac_enc_close_fx(
DIRAC_ENC_HANDLE *hDirAC_out, /* i/o: encoder DirAC handle */
- const Word32 input_Fs /* i : input sampling rate */
+ const Word32 input_Fs /* i : input sampling rate Q0*/
)
{
Word16 i, j;
@@ -314,14 +320,14 @@ ivas_error ivas_dirac_enc_fx(
DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */
IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */
- Word32 *data_f_fx[], /* i/o: SBA channels Qx */
- Word32 **pp_fr_real_fx, /* o : real freq domain values pp_fr_q */
- Word32 **pp_fr_imag_fx, /* o : imag freq domain values pp_fr_q */
+ Word32 *data_f_fx[], /* i/o: SBA channels Qx*/
+ Word32 **pp_fr_real_fx, /* o : real freq domain values pp_fr_q*/
+ Word32 **pp_fr_imag_fx, /* o : imag freq domain values pp_fr_q*/
Word16 pp_fr_q,
- const Word16 input_frame, /* i : input frame length Q0 */
- const Word16 dtx_vad, /* i : DTX vad flag Q0 */
- const IVAS_FORMAT ivas_format, /* i : ivas format */
- const Word16 hodirac_flag /* i : hodirac flag Q0 */
+ const Word16 input_frame, /* i : input frame length Q0*/
+ const Word16 dtx_vad, /* i : DTX vad flag Q0*/
+ const IVAS_FORMAT ivas_format, /* i : ivas format */
+ const Word16 hodirac_flag /* i : hodirac flag Q0*/
)
{
Word16 orig_dirac_bands;
@@ -330,14 +336,24 @@ ivas_error ivas_dirac_enc_fx(
ivas_error error;
push_wmops( "ivas_dirac_enc" );
- Word16 nchan_fb_in = hodirac_flag ? HOA2_CHANNELS : FOA_CHANNELS;
- move16();
+ Word16 nchan_fb_in;
+
+ if ( hodirac_flag )
+ {
+ nchan_fb_in = HOA2_CHANNELS;
+ move16();
+ }
+ else
+ {
+ nchan_fb_in = FOA_CHANNELS;
+ move16();
+ }
ivas_dirac_param_est_enc_fx( hDirAC, hQMetaData->q_direction, hQMetaData->useLowerRes, data_f_fx, pp_fr_real_fx, pp_fr_imag_fx, pp_fr_q, input_frame, ivas_format, hodirac_flag, nchan_fb_in, &( hDirAC->mono_frame_count ), &( hQMetaData->dirac_mono_flag ) );
IF( hQMetaData->q_direction->cfg.nbands > 0 )
{
- orig_dirac_bands = hQMetaData->q_direction[0].cfg.nbands;
+ orig_dirac_bands = hQMetaData->q_direction[0].cfg.nbands; /* Q0 */
move16();
IF( EQ_16( dtx_vad, 1 ) )
@@ -380,7 +396,7 @@ ivas_error ivas_dirac_enc_fx(
}
}
- IF( NE_32( ( error = ivas_qmetadata_enc_encode_fx( hMetaData, hQMetaData, hodirac_flag ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_enc_encode_fx( hMetaData, hQMetaData, hodirac_flag ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -405,15 +421,15 @@ ivas_error ivas_dirac_enc_fx(
{
ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( hQMetaData->q_direction[0].band_data[j].azimuth_fx[i], hQMetaData->q_direction[0].band_data[j].elevation_fx[i], &dir_fx[0] );
- Word32 vecLen_fx = Mpy_32_32( hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[i] /*Q30*/, hDirAC->buffer_energy_fx[i * orig_dirac_bands + j] );
- avg_dir_fx[0] = L_add( avg_dir_fx[0], Mpy_32_32( dir_fx[0], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
- avg_dir_fx[1] = L_add( avg_dir_fx[1], Mpy_32_32( dir_fx[1], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
- avg_dir_fx[2] = L_add( avg_dir_fx[2], Mpy_32_32( dir_fx[2], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
+ Word32 vecLen_fx = Mpy_32_32( hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[i] /*Q30*/, hDirAC->buffer_energy_fx[i * orig_dirac_bands + j] ); /* hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 */
+ avg_dir_fx[0] = L_add( avg_dir_fx[0], Mpy_32_32( dir_fx[0], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
+ avg_dir_fx[1] = L_add( avg_dir_fx[1], Mpy_32_32( dir_fx[1], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
+ avg_dir_fx[2] = L_add( avg_dir_fx[2], Mpy_32_32( dir_fx[2], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
move32();
move32();
move32();
avg_dir_e = sub( 31, ( sub( add( Q30, hDirAC->buffer_energy_q[i * orig_dirac_bands + j] ), 1 - 31 ) ) );
- energySum_fx = BASOP_Util_Add_Mant32Exp( energySum_fx, energySum_e, hDirAC->buffer_energy_fx[i * orig_dirac_bands + j], sub( 31, hDirAC->buffer_energy_q[i * orig_dirac_bands + j] ), &energySum_e );
+ energySum_fx = BASOP_Util_Add_Mant32Exp( energySum_fx, energySum_e, hDirAC->buffer_energy_fx[i * orig_dirac_bands + j], sub( 31, hDirAC->buffer_energy_q[i * orig_dirac_bands + j] ), &energySum_e ); /* exp(energySum_e) */
}
Word16 x = getScaleFactor32( avg_dir_fx, 3 );
@@ -431,16 +447,16 @@ ivas_error ivas_dirac_enc_fx(
move16();
Word16 denom_e = 0;
move16();
- Word32 denom = BASOP_Util_Add_Mant32Exp( energySum_fx, energySum_e, EPSILON_FX_M, EPSILON_FX_E, &denom_e );
+ Word32 denom = BASOP_Util_Add_Mant32Exp( energySum_fx, energySum_e, EPSILON_FX_M, EPSILON_FX_E, &denom_e ); /* exp(denom_e) */
- er_tmp = BASOP_Util_Divide3232_Scale( tmp, denom, &er_tmp_e );
+ er_tmp = BASOP_Util_Divide3232_Scale( tmp, denom, &er_tmp_e ); /* exp(er_tmp_e) */
er_tmp_e = add( er_tmp_e, sub( tmp_e, denom_e ) );
er_tmp = shr( er_tmp, sub( 1, ( er_tmp_e ) ) ); // Q14
- hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[i] = L_deposit_h( er_tmp ); // Q30
- hQMetaData->q_direction[0].band_data[1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i];
- hQMetaData->q_direction[0].band_data[1].elevation_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].elevation_fx[i];
- hQMetaData->q_direction[0].band_data[1].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].energy_ratio_fx[i];
+ hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[i] = L_deposit_h( er_tmp ); // Q30
+ hQMetaData->q_direction[0].band_data[1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i]; // Q22
+ hQMetaData->q_direction[0].band_data[1].elevation_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].elevation_fx[i]; // Q22
+ hQMetaData->q_direction[0].band_data[1].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].energy_ratio_fx[i]; // Q30
move32();
move32();
move32();
@@ -459,19 +475,20 @@ ivas_error ivas_dirac_enc_fx(
IF( EQ_16( dtx_vad, 1 ) )
{
len = hQMetaData->q_direction[0].cfg.nblocks;
+ move16();
}
ELSE
{
len = 1;
+ move16();
}
- move16();
FOR( b = hQMetaData->q_direction->cfg.start_band; b < hQMetaData->q_direction->cfg.nbands; b++ )
{
FOR( i_ts = 0; i_ts < len; i_ts++ )
{
- hQMetaData->q_direction->band_data[b].azimuth_fx[i_ts] = hQMetaData->q_direction->band_data[b].q_azimuth_fx[i_ts];
- hQMetaData->q_direction->band_data[b].elevation_fx[i_ts] = hQMetaData->q_direction->band_data[b].q_elevation_fx[i_ts];
- hQMetaData->q_direction[0].band_data[b].energy_ratio_fx[0] = L_sub( ONE_IN_Q30, diffuseness_reconstructions_fx[hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0]] );
+ hQMetaData->q_direction->band_data[b].azimuth_fx[i_ts] = hQMetaData->q_direction->band_data[b].q_azimuth_fx[i_ts]; // Q22
+ hQMetaData->q_direction->band_data[b].elevation_fx[i_ts] = hQMetaData->q_direction->band_data[b].q_elevation_fx[i_ts]; // Q22
+ hQMetaData->q_direction[0].band_data[b].energy_ratio_fx[0] = L_sub( ONE_IN_Q30, diffuseness_reconstructions_fx[hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0]] ); // Q30
move32();
move32();
move32();
@@ -482,9 +499,9 @@ ivas_error ivas_dirac_enc_fx(
{
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[1].azimuth_fx[0];
- hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].elevation_fx[i] = hQMetaData->q_direction[0].band_data[1].elevation_fx[0];
- hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[1].energy_ratio_fx[0];
+ hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[1].azimuth_fx[0]; // Q22
+ hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].elevation_fx[i] = hQMetaData->q_direction[0].band_data[1].elevation_fx[0]; // Q22
+ hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[1].energy_ratio_fx[0]; // Q30
move32();
move32();
move32();
@@ -494,16 +511,16 @@ ivas_error ivas_dirac_enc_fx(
{
FOR( j = sub( orig_dirac_bands, 2 ); j >= 0; j-- )
{
- hQMetaData->q_direction[0].band_data[j].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[0].azimuth_fx[0];
- hQMetaData->q_direction[0].band_data[j].elevation_fx[i] = hQMetaData->q_direction[0].band_data[0].elevation_fx[0];
- hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[0];
+ hQMetaData->q_direction[0].band_data[j].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[0].azimuth_fx[0]; // Q22
+ hQMetaData->q_direction[0].band_data[j].elevation_fx[i] = hQMetaData->q_direction[0].band_data[0].elevation_fx[0]; // Q22
+ hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[0]; // Q30
move32();
move32();
move32();
}
}
- hQMetaData->q_direction->cfg.nbands = orig_dirac_bands;
+ hQMetaData->q_direction->cfg.nbands = orig_dirac_bands; /* Q0 */
move16();
}
}
@@ -521,12 +538,12 @@ ivas_error ivas_dirac_enc_fx(
*-------------------------------------------------------------------------*/
static Word16 ivas_dirac_get_mono_flag_fx(
- const Word16 *band_grouping, /* i : Band grouping for estimation */
- Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */
- Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */
- Word16 e_Cldfb, /* i : Exponent of cldfb buffer */
- const Word16 nchan_ana, /* i : number of analysis channels */
- Word16 *mono_frame_count ) /* i/o: current number of mono frames count */
+ const Word16 *band_grouping, /* i : Band grouping for estimation Q0*/
+ Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal e_Cldfb*/
+ Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal e_Cldfb*/
+ Word16 e_Cldfb, /* i : Exponent of cldfb buffer */
+ const Word16 nchan_ana, /* i : number of analysis channels Q0*/
+ Word16 *mono_frame_count ) /* i/o: current number of mono frames count Q0*/
{
Word16 brange[2];
Word16 i, j, ch_idx;
@@ -554,8 +571,8 @@ static Word16 ivas_dirac_get_mono_flag_fx(
move32();
move32();
- brange[0] = band_grouping[i];
- brange[1] = band_grouping[i + 1];
+ brange[0] = band_grouping[i]; /* Q0 */
+ brange[1] = band_grouping[i + 1]; /* Q0 */
move16();
move16();
@@ -571,10 +588,10 @@ static Word16 ivas_dirac_get_mono_flag_fx(
/* Loop over the W channel bins to calculate the power in the band */
FOR( j = brange[0]; j < brange[1]; j++ )
{
- acc = W_mac_32_32( acc, Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] );
- acc = W_mac_32_32( acc, Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] );
+ acc = W_mac_32_32( acc, Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ); /* exp(2 * e_Cldfb) */
+ acc = W_mac_32_32( acc, Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ); /* exp(2 * e_Cldfb) */
shift1 = W_norm( acc );
- W_band_power = W_extract_h( W_shl( acc, shift1 ) );
+ W_band_power = W_extract_h( W_shl( acc, shift1 ) ); /* exp(2 * e_Cldfb - shift1) */
W_band_power_e = sub( imult1616( (Word16) 2, e_Cldfb ), shift1 );
}
@@ -584,10 +601,10 @@ static Word16 ivas_dirac_get_mono_flag_fx(
/* abs()^2 */
FOR( j = brange[0]; j < brange[1]; j++ )
{
- acc1 = W_mac_32_32( acc1, Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] );
- acc1 = W_mac_32_32( acc1, Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] );
+ acc1 = W_mac_32_32( acc1, Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ); /* exp(2 * e_Cldfb) */
+ acc1 = W_mac_32_32( acc1, Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ); /* exp(2 * e_Cldfb) */
shift2 = W_norm( acc1 );
- other_ch_band_power = W_extract_h( W_shl( acc1, shift2 ) );
+ other_ch_band_power = W_extract_h( W_shl( acc1, shift2 ) ); /* exp(2 * e_Cldfb - shift2) */
other_ch_band_power_e = sub( imult1616( (Word16) 2, e_Cldfb ), shift2 );
}
}
@@ -606,7 +623,7 @@ static Word16 ivas_dirac_get_mono_flag_fx(
{
Word16 tmp_div_e = 0;
move16();
- Word16 tmp_div = BASOP_Util_Divide3232_Scale( W_band_power, DIRAC_MONO_NORM_FACTOR_M, &tmp_div_e );
+ Word16 tmp_div = BASOP_Util_Divide3232_Scale( W_band_power, DIRAC_MONO_NORM_FACTOR_M, &tmp_div_e ); /* exp(tmp_div_e) */
tmp_div_e = add( tmp_div_e, sub( W_band_power_e, DIRAC_MONO_NORM_FACTOR_E ) );
Word16 W_band_power_norm_e = 0;
move16();
@@ -681,7 +698,7 @@ static Word16 ivas_dirac_get_mono_flag_fx(
{
IF( LT_16( *mono_frame_count, DIRAC_MONO_FRAME_THRESH ) )
{
- *mono_frame_count = add( *mono_frame_count, 1 );
+ *mono_frame_count = add( *mono_frame_count, 1 ); /* Q0 */
move16();
}
}
@@ -714,18 +731,18 @@ static Word16 ivas_dirac_get_mono_flag_fx(
void computeReferencePower_enc_fx_dirac(
const Word16 *band_grouping, /* i : Band grouping for estimation */
- Word32 Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */
- Word32 Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */
+ Word32 Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal e_Cldfb*/
+ Word32 Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal e_Cldfb*/
Word16 e_Cldfb, /* i : exponent of Cldfb buffer */
- Word32 *reference_power, /* o : Estimated power */
+ Word32 *reference_power, /* o : Estimated power e_reference*/
Word16 *e_reference, /* o : exponent of reference_power */
- const Word16 enc_param_start_band, /* i : first band to process */
- const Word16 num_freq_bands, /* i : Number of frequency bands */
+ const Word16 enc_param_start_band, /* i : first band to process Q0*/
+ const Word16 num_freq_bands, /* i : Number of frequency bands Q0*/
const IVAS_FORMAT ivas_format, /* i : ivas_format */
- Word16 ref_power_w, /* i : use 0 if hodirac is enabled */
- const Word16 nchan_ana, /* i : number of analysis channels */
- Word16 *mono_frame_count, /* i/o: Mono Frame Count */
- Word16 *dirac_mono_flag /* i/o: Mono Flag */
+ Word16 ref_power_w, /* i : use 0 if hodirac is enabled Q0*/
+ const Word16 nchan_ana, /* i : number of analysis channels Q0*/
+ Word16 *mono_frame_count, /* i/o: Mono Frame Count Q0*/
+ Word16 *dirac_mono_flag /* i/o: Mono Flag Q0*/
)
{
Word16 brange[2];
@@ -739,10 +756,24 @@ void computeReferencePower_enc_fx_dirac(
IF( dirac_mono_flag != NULL )
{
- *dirac_mono_flag = ivas_dirac_get_mono_flag_fx( band_grouping, Cldfb_RealBuffer, Cldfb_ImagBuffer, e_Cldfb, nchan_ana, mono_frame_count );
+ *dirac_mono_flag = ivas_dirac_get_mono_flag_fx( band_grouping, Cldfb_RealBuffer, Cldfb_ImagBuffer, e_Cldfb, nchan_ana, mono_frame_count ); /* Q0 */
move16();
}
-
+#ifdef FIX_1127_IMPROVE_SBA_MLD
+ Word16 gb = 0;
+ move16();
+ FOR( i = 0; i < num_freq_bands; i++ )
+ {
+ brange[0] = band_grouping[i + enc_param_start_band];
+ brange[1] = band_grouping[i + enc_param_start_band + 1];
+ move16();
+ move16();
+ gb = s_max( gb, find_guarded_bits_fx( sub( brange[1], brange[0] ) ) );
+ }
+ e_reference_W = sub( 31, sub( add( shl( sub( 31, e_Cldfb ), 1 ), 1 ), gb ) );
+ e_reference_temp = e_reference_W;
+#endif
+ move16();
FOR( i = 0; i < num_freq_bands; i++ )
{
brange[0] = band_grouping[i + enc_param_start_band];
@@ -758,14 +789,18 @@ void computeReferencePower_enc_fx_dirac(
FOR( j = brange[0]; j < brange[1]; j++ )
{
+#ifdef FIX_1127_IMPROVE_SBA_MLD
+ reference_power_W[i] = W_add( reference_power_W[i], W_shr( W_mult_32_32( Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ), gb ) ); /* exp(2 * e_Cldfb) */
+ reference_power_W[i] = W_add( reference_power_W[i], W_shr( W_mult_32_32( Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ), gb ) ); /* exp(2 * e_Cldfb) */
+#else
reference_power_W[i] = W_mac_32_32( reference_power_W[i], Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] );
reference_power_W[i] = W_mac_32_32( reference_power_W[i], Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] );
+ e_reference_W = imult1616( (Word16) 2, e_Cldfb );
+#endif
move64();
move64();
-
- e_reference_W = imult1616( (Word16) 2, e_Cldfb );
}
- reference_power_temp[i] = W_add( reference_power_temp[i], reference_power_W[i] );
+ reference_power_temp[i] = W_add( reference_power_temp[i], reference_power_W[i] ); /* exp(2 * e_Cldfb) */
move64();
FOR( ch_idx = 1; ch_idx < nchan_ana; ch_idx++ )
@@ -773,19 +808,23 @@ void computeReferencePower_enc_fx_dirac(
/* abs()^2 */
FOR( j = brange[0]; j < brange[1]; j++ )
{
+#ifdef FIX_1127_IMPROVE_SBA_MLD
+ reference_power_temp[i] = W_add( reference_power_temp[i], W_shr( W_mult_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), gb ) ); /* exp(2 * e_Cldfb) */
+ reference_power_temp[i] = W_add( reference_power_temp[i], W_shr( W_mult_32_32( Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ), gb ) ); /* exp(2 * e_Cldfb) */
+#else
reference_power_temp[i] = W_mac_32_32( reference_power_temp[i], Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] );
reference_power_temp[i] = W_mac_32_32( reference_power_temp[i], Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] );
+ e_reference_temp = imult1616( (Word16) 2, e_Cldfb );
+#endif
move64();
move64();
-
- e_reference_temp = imult1616( (Word16) 2, e_Cldfb );
}
}
}
FOR( i = 0; i < num_freq_bands; i++ )
{
- reference_power_temp[i] = W_shr( reference_power_temp[i], 1 );
+ reference_power_temp[i] = W_shr( reference_power_temp[i], 1 ); /* exp(2 * e_Cldfb + 1) */
move64();
}
@@ -796,7 +835,7 @@ void computeReferencePower_enc_fx_dirac(
{
IF( BASOP_Util_Cmp_Mant32Exp( W_extract_h( reference_power_temp[i] ), e_reference_temp, W_extract_h( reference_power_W[i] ), e_reference_W ) < 0 )
{
- reference_power_temp[i] = reference_power_W[i];
+ reference_power_temp[i] = reference_power_W[i]; /* exp(2 * e_Cldfb + 1 ) */
move64();
}
}
@@ -813,22 +852,26 @@ void computeReferencePower_enc_fx_dirac(
reference_power[i] = W_extract_h( W_shl( reference_power_temp[i], min_norm ) ); // Right shift with min_norm and extract high bits
move32();
}
+#ifdef FIX_1127_IMPROVE_SBA_MLD
+ *e_reference = sub( 31, sub( add( sub( 31, e_reference_temp ), min_norm ), 32 ) );
+#else
*e_reference = sub( e_reference_temp, min_norm );
+#endif
move16();
return;
}
void computeReferencePower_enc_fx(
- const Word16 *band_grouping, /* i : Band grouping for estimation */
- Word32 Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */
- Word32 Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */
- Word32 *reference_power, /* o : Estimated power */
- const Word16 enc_param_start_band, /* i : first band to process */
- const Word16 num_freq_bands, /* i : Number of frequency bands */
+ const Word16 *band_grouping, /* i : Band grouping for estimation Q0*/
+ Word32 Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal inp_q*/
+ Word32 Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal inp_q*/
+ Word32 *reference_power, /* o : Estimated power ref_exp*/
+ const Word16 enc_param_start_band, /* i : first band to process Q0*/
+ const Word16 num_freq_bands, /* i : Number of frequency bands Q0*/
const IVAS_FORMAT ivas_format, /* i : ivas_format */
- Word16 ref_power_w, /* i : use 0 if hodirac is enabled */
- const Word16 nchan_ana, /* i : number of analysis channels */
+ Word16 ref_power_w, /* i : use 0 if hodirac is enabled Q0*/
+ const Word16 nchan_ana, /* i : number of analysis channels Q0*/
Word16 inp_q, /* i : q of cld buffers */
Word16 *ref_exp /* i : output q */
)
@@ -842,9 +885,9 @@ void computeReferencePower_enc_fx(
Word64 reference_power_W[DIRAC_MAX_NBANDS];
FOR( i = 0; i < num_freq_bands; i++ )
{
- brange[0] = band_grouping[i + enc_param_start_band];
+ brange[0] = band_grouping[i + enc_param_start_band]; /* Q0 */
move16();
- brange[1] = band_grouping[i + enc_param_start_band + 1];
+ brange[1] = band_grouping[i + enc_param_start_band + 1]; /* Q0 */
move16();
reference_power[i] = 0;
move32();
@@ -884,7 +927,7 @@ void computeReferencePower_enc_fx(
{
IF( LT_64( reference_power_tmp[i], reference_power_W[i] ) )
{
- reference_power_tmp[i] = reference_power_W[i];
+ reference_power_tmp[i] = reference_power_W[i]; // 2*inp_q + 1
move64();
}
}
@@ -914,17 +957,18 @@ void computeReferencePower_enc_fx(
void ivas_dirac_param_est_enc_fx(
DIRAC_ENC_HANDLE hDirAC,
IVAS_QDIRECTION *q_direction,
- const UWord8 useLowerRes,
- Word32 *data_f_fx[],
- Word32 **pp_fr_real_fx,
- Word32 **pp_fr_imag_fx,
+ const UWord8 useLowerRes, /* Q0 */
+ Word32 *data_f_fx[], /* Qx */
+ Word32 **pp_fr_real_fx, /* pp_fr_q */
+ Word32 **pp_fr_imag_fx, /* pp_fr_q */
Word16 pp_fr_q,
- const Word16 input_frame,
+ const Word16 input_frame, /* Q0 */
const IVAS_FORMAT ivas_format,
- const Word16 hodirac_flag,
- const Word16 nchan_fb_in,
- Word16 *mono_frame_count,
- Word16 *dirac_mono_flag )
+ const Word16 hodirac_flag, /* Q0 */
+ const Word16 nchan_fb_in, /* Q0 */
+ Word16 *mono_frame_count, /* Q0 */
+ Word16 *dirac_mono_flag /* Q0 */
+)
{
Word16 i, j, k, d, ts, index, l_ts, num_freq_bands;
Word16 band_m_idx, block_m_idx;
@@ -936,7 +980,11 @@ void ivas_dirac_param_est_enc_fx(
Word32 *p_Cldfb_ImagBuffer_fx[DIRAC_MAX_ANA_CHANS];
Word16 cldfb_q;
Word32 intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS];
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Word16 intensity_real_q[DIRAC_MAX_NBANDS];
+#else
Word16 intensity_real_q;
+#endif
Word32 direction_vector_fx[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS];
Word16 direction_vector_q;
Word32 diffuseness_vector_fx[DIRAC_MAX_NBANDS];
@@ -959,20 +1007,24 @@ void ivas_dirac_param_est_enc_fx(
Word16 ene_secs_exp[2 * DIRAC_MAX_ANA_CHANS * DIRAC_MAX_NBANDS];
push_wmops( "dirac_enc_param_est" );
- num_freq_bands = hDirAC->hConfig->nbands;
+ num_freq_bands = hDirAC->hConfig->nbands; /* Q0 */
move16();
/* Initialization */
cldfb_q = 0;
move16();
+
+#ifndef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
intensity_real_q = 0;
move16();
+#endif
+
direction_vector_q = 0;
move16();
diffuseness_vector_q = 0;
move16();
- l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES );
+ l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); /* Q0 */
IF( useLowerRes )
{
q_direction->cfg.nblocks = 1;
@@ -1014,9 +1066,9 @@ void ivas_dirac_param_est_enc_fx(
/* do processing over all CLDFB time slots */
FOR( block_m_idx = 0; block_m_idx < num_blocks; block_m_idx++ )
{
- mrange[0] = hDirAC->block_grouping[block_m_idx];
+ mrange[0] = hDirAC->block_grouping[block_m_idx]; /* Q0 */
move16();
- mrange[1] = hDirAC->block_grouping[add( block_m_idx, 1 )];
+ mrange[1] = hDirAC->block_grouping[block_m_idx + 1];
move16();
set32_fx( renormalization_factor_fx, EPSILON_FX, hDirAC->hConfig->nbands );
@@ -1045,8 +1097,8 @@ void ivas_dirac_param_est_enc_fx(
{
FOR( i = 0; i < nchan_fb_in; i++ )
{
- Copy32( &pp_fr_real_fx[i][imult1616( ts, l_ts )], Cldfb_RealBuffer_fx[i], l_ts );
- Copy32( &pp_fr_imag_fx[i][imult1616( ts, l_ts )], Cldfb_ImagBuffer_fx[i], l_ts );
+ Copy32( &pp_fr_real_fx[i][ts * l_ts], Cldfb_RealBuffer_fx[i], l_ts ); /* pp_fr_q */
+ Copy32( &pp_fr_imag_fx[i][ts * l_ts], Cldfb_ImagBuffer_fx[i], l_ts ); /* pp_fr_q */
}
cldfb_q = pp_fr_q;
move16();
@@ -1054,7 +1106,7 @@ void ivas_dirac_param_est_enc_fx(
Word16 ref_power_w = 1;
move16();
- IF( hodirac_flag )
+ if ( hodirac_flag )
{
ref_power_w = 0;
move16();
@@ -1081,10 +1133,16 @@ void ivas_dirac_param_est_enc_fx(
Cldfb_ImagBuffer_fx,
hDirAC->hConfig->enc_param_start_band,
num_freq_bands,
- intensity_real_fx );
-
+ intensity_real_fx
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ cldfb_q,
+ intensity_real_q
+#endif
+ );
+#ifndef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
intensity_real_q = sub( shl( cldfb_q, 1 ), 31 ); // 2 * Q_Cldfb + 1 - 32;
-
+#endif
IF( !hodirac_flag )
{
computeDirectionVectors_fixed(
@@ -1095,25 +1153,36 @@ void ivas_dirac_param_est_enc_fx(
num_freq_bands,
direction_vector_fx[0],
direction_vector_fx[1],
- direction_vector_fx[2],
- sub( 31, intensity_real_q ) );
+ direction_vector_fx[2]
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ 31, intensity_real_q
+#else
+ ,
+ sub( 31, intensity_real_q )
+#endif
+ );
direction_vector_q = Q30;
move16();
}
/* fill buffers of length "averaging_length" time slots for intensity and energy */
- hDirAC->index_buffer_intensity = add( ( hDirAC->index_buffer_intensity % hDirAC->no_col_avg_diff ), 1 ); /* averaging_length = 32 */
+ hDirAC->index_buffer_intensity = add( ( hDirAC->index_buffer_intensity % hDirAC->no_col_avg_diff ), 1 ); /* averaging_length = 32 Q0*/
move16();
- index = hDirAC->index_buffer_intensity;
+ index = hDirAC->index_buffer_intensity; /* Q0 */
move16();
FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
{
/* only real part needed */
- Copy32( intensity_real_fx[i], &( hDirAC->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands );
+ Copy32( intensity_real_fx[i], &( hDirAC->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands ); /* intensity_real_q */
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Copy( intensity_real_q, &hDirAC->buffer_intensity_real_q[i][index - 1][0], num_freq_bands );
+#else
set16_fx( &hDirAC->buffer_intensity_real_q[i][index - 1][0], intensity_real_q, num_freq_bands );
+#endif
}
- Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands );
+ Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); /* exp(reference_power_exp) */
set16_fx( &hDirAC->buffer_energy_q[( index - 1 ) * num_freq_bands], sub( 31, reference_power_exp ), num_freq_bands );
Word16 buffer_intensity_real_single_q;
@@ -1135,7 +1204,7 @@ void ivas_dirac_param_est_enc_fx(
{
FOR( k = 0; k < num_freq_bands; k++ )
{
- hDirAC->buffer_intensity_real_fx[i][j][k] = L_shl( hDirAC->buffer_intensity_real_fx[i][j][k], sub( buffer_intensity_real_single_q, hDirAC->buffer_intensity_real_q[i][j][k] ) );
+ hDirAC->buffer_intensity_real_fx[i][j][k] = L_shl( hDirAC->buffer_intensity_real_fx[i][j][k], sub( buffer_intensity_real_single_q, hDirAC->buffer_intensity_real_q[i][j][k] ) ); /* buffer_intensity_real_single_q */
move32();
hDirAC->buffer_intensity_real_q[i][j][k] = buffer_intensity_real_single_q;
move16();
@@ -1149,7 +1218,7 @@ void ivas_dirac_param_est_enc_fx(
minimum_fx( hDirAC->buffer_energy_q, buffer_len, &buffer_energy_single_q );
FOR( i = 0; i < buffer_len; i++ )
{
- hDirAC->buffer_energy_fx[i] = L_shl( hDirAC->buffer_energy_fx[i], sub( buffer_energy_single_q, hDirAC->buffer_energy_q[i] ) );
+ hDirAC->buffer_energy_fx[i] = L_shl( hDirAC->buffer_energy_fx[i], sub( buffer_energy_single_q, hDirAC->buffer_energy_q[i] ) ); /* buffer_energy_single_q */
move32();
hDirAC->buffer_energy_q[i] = buffer_energy_single_q;
move16();
@@ -1190,9 +1259,9 @@ void ivas_dirac_param_est_enc_fx(
{
Word32 tmp_diff = L_shr( diffuseness_vector_fx[band_m_idx], sub( diffuseness_vector_q, 30 ) ); // diffueseness_vector_q -> Q30
hDirAC->diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->diffuseness_m_fx[band_m_idx], hDirAC->diffuseness_m_exp[band_m_idx],
- Mpy_32_32( reference_power_fx[ts][band_m_idx], tmp_diff ), add( reference_power_exp, 1 ), &hDirAC->diffuseness_m_exp[band_m_idx] );
+ Mpy_32_32( reference_power_fx[ts][band_m_idx], tmp_diff ), add( reference_power_exp, 1 ), &hDirAC->diffuseness_m_exp[band_m_idx] ); /* exp(hDirAC->diffuseness_m_exp) */
move32();
- renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_exp[band_m_idx], reference_power_fx[ts][band_m_idx], reference_power_exp, &renormalization_factor_diff_exp[band_m_idx] );
+ renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_exp[band_m_idx], reference_power_fx[ts][band_m_idx], reference_power_exp, &renormalization_factor_diff_exp[band_m_idx] ); /* exp(renormalization_factor_diff_exp) */
move32();
}
}
@@ -1203,19 +1272,19 @@ void ivas_dirac_param_est_enc_fx(
Word32 tmp_diff = L_shr( diffuseness_vector_fx[band_m_idx], sub( diffuseness_vector_q, 30 ) ); // diffueseness_vector_q -> Q30
norm_tmp_fx = Mpy_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, tmp_diff ) );
- hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = L_add( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], L_shr( Mpy_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), gbits ) );
+ hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = L_add( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], L_shr( Mpy_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), gbits ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */
move32();
- hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_add( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], L_shr( Mpy_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), gbits ) );
+ hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_add( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], L_shr( Mpy_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), gbits ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */
move32();
- hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_add( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], L_shr( Mpy_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), gbits ) );
+ hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_add( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], L_shr( Mpy_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), gbits ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */
move32();
- renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], L_shr( norm_tmp_fx, gbits ) );
+ renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], L_shr( norm_tmp_fx, gbits ) ); /* exp(norm_tmp_exp + gbits) */
move32();
hDirAC->diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->diffuseness_m_fx[band_m_idx], hDirAC->diffuseness_m_exp[band_m_idx],
- Mpy_32_32( reference_power_fx[ts][band_m_idx], tmp_diff ), add( reference_power_exp, 1 ), &hDirAC->diffuseness_m_exp[band_m_idx] );
+ Mpy_32_32( reference_power_fx[ts][band_m_idx], tmp_diff ), add( reference_power_exp, 1 ), &hDirAC->diffuseness_m_exp[band_m_idx] ); /* exp(hDirAC->diffuseness_m_exp) */
move32();
renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_exp[band_m_idx],
- reference_power_fx[ts][band_m_idx], reference_power_exp, &renormalization_factor_diff_exp[band_m_idx] );
+ reference_power_fx[ts][band_m_idx], reference_power_exp, &renormalization_factor_diff_exp[band_m_idx] ); /* exp(renormalization_factor_diff_exp) */
move32();
}
norm_tmp_exp = add( reference_power_exp, 1 );
@@ -1231,11 +1300,11 @@ void ivas_dirac_param_est_enc_fx(
{
renormalization_factor_fx[band_m_idx] = EPSILON_FX;
move32();
- renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] ) );
+ renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */
move32();
- renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] ) );
+ renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */
move32();
- renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] ) );
+ renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */
move32();
renormalization_factor_exp = shl( hDirAC->direction_vector_m_exp[block_m_idx], 1 ); // 2 * direction_vector_m_exp
renormalization_factor_fx[band_m_idx] = Sqrt32( renormalization_factor_fx[band_m_idx], &renormalization_factor_exp );
@@ -1248,21 +1317,21 @@ void ivas_dirac_param_est_enc_fx(
tmp32 = hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx];
move32();
- tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp32, renormalization_factor_fx[band_m_idx], &tmp_e ) );
+ tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp32, renormalization_factor_fx[band_m_idx], &tmp_e ) ); /* exp(tmp_e + ( hDirAC->direction_vector_m_exp[block_m_idx] - renormalization_factor_exp)) */
tmp_e = add( tmp_e, sub( hDirAC->direction_vector_m_exp[block_m_idx], renormalization_factor_exp ) );
hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = L_shr( tmp32, sub( 1, tmp_e ) ); // Q30
move32();
- tmp32 = hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx];
+ tmp32 = hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx]; // Q30
move32();
- tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp32, renormalization_factor_fx[band_m_idx], &tmp_e ) );
+ tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp32, renormalization_factor_fx[band_m_idx], &tmp_e ) ); /* exp(tmp_e + ( hDirAC->direction_vector_m_exp[block_m_idx] - renormalization_factor_exp)) */
tmp_e = add( tmp_e, sub( hDirAC->direction_vector_m_exp[block_m_idx], renormalization_factor_exp ) );
hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_shr( tmp32, sub( 1, tmp_e ) ); // Q30
move32();
- tmp32 = hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx];
+ tmp32 = hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx]; // Q30
move32();
- tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp32, renormalization_factor_fx[band_m_idx], &tmp_e ) );
+ tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp32, renormalization_factor_fx[band_m_idx], &tmp_e ) ); /* exp(tmp_e + ( hDirAC->direction_vector_m_exp[block_m_idx] - renormalization_factor_exp)) */
tmp_e = add( tmp_e, sub( hDirAC->direction_vector_m_exp[block_m_idx], renormalization_factor_exp ) );
hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_shr( tmp32, sub( 1, tmp_e ) ); // Q30
move32();
@@ -1289,7 +1358,12 @@ void ivas_dirac_param_est_enc_fx(
Scale_sig32( dir_v_fx, 3, -1 );
ivas_qmetadata_direction_vector_to_azimuth_elevation_fx(
dir_v_fx,
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Q29,
+#else
+
Q30,
+#endif
&q_direction->band_data[band_m_idx].azimuth_fx[block_m_idx],
&q_direction->band_data[band_m_idx].elevation_fx[block_m_idx] );
}
@@ -1312,9 +1386,9 @@ void ivas_dirac_param_est_enc_fx(
q_direction[1].band_data[band_m_idx].elevation_fx[block_m_idx] = L_shr( ele_secs_fx[num_freq_bands + band_m_idx], 1 ); // Q23 -> Q22
move32();
- L_tmp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, Q1, L_negate( diff_secs_fx[band_m_idx] ), diff_secs_exp[band_m_idx], &e_tmp );
- L_tmp1 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, Q1, L_negate( diff_secs_fx[num_freq_bands + band_m_idx] ), diff_secs_exp[num_freq_bands + band_m_idx], &e_tmp1 );
- L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp, e_tmp, L_tmp1, e_tmp1, &e_tmp1 );
+ L_tmp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, Q1, L_negate( diff_secs_fx[band_m_idx] ), diff_secs_exp[band_m_idx], &e_tmp ); /* exp(e_tmp) */
+ L_tmp1 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, Q1, L_negate( diff_secs_fx[num_freq_bands + band_m_idx] ), diff_secs_exp[num_freq_bands + band_m_idx], &e_tmp1 ); /* exp(e_tmp1) */
+ L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp, e_tmp, L_tmp1, e_tmp1, &e_tmp1 ); /* exp(e_tmp1) */
IF( L_tmp1 == 0 )
{
q_direction[1].band_data[band_m_idx].energy_ratio_fx[block_m_idx] = L_shl( div_l( L_tmp, EPSILON_FX ), Q30 - Q15 ); // Q30
@@ -1322,7 +1396,7 @@ void ivas_dirac_param_est_enc_fx(
}
ELSE
{
- L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( L_tmp, L_add( L_tmp1, EPSILON_FX ), &exp_diff ) );
+ L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( L_tmp, L_add( L_tmp1, EPSILON_FX ), &exp_diff ) ); /* exp(exp_diff) */
exp_diff = add( exp_diff, sub( e_tmp, e_tmp1 ) );
q_direction[1].band_data[band_m_idx].energy_ratio_fx[block_m_idx] = L_shl( L_tmp, sub( exp_diff, Q1 ) ); // Q30
move32();
@@ -1337,7 +1411,7 @@ void ivas_dirac_param_est_enc_fx(
IF( GT_32( renormalization_factor_diff_fx[band_m_idx], EPSILON_FX ) )
{
Word16 tmp_e;
- hDirAC->diffuseness_m_fx[band_m_idx] = L_deposit_h( BASOP_Util_Divide3232_Scale( hDirAC->diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &tmp_e ) );
+ hDirAC->diffuseness_m_fx[band_m_idx] = L_deposit_h( BASOP_Util_Divide3232_Scale( hDirAC->diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &tmp_e ) ); /* exp(tmp_e) */
move32();
tmp_e = add( tmp_e, sub( hDirAC->diffuseness_m_exp[band_m_idx], renormalization_factor_diff_exp[band_m_idx] ) );
hDirAC->diffuseness_m_fx[band_m_idx] = L_shr( hDirAC->diffuseness_m_fx[band_m_idx], sub( 1, tmp_e ) ); // to Q30
@@ -1377,11 +1451,17 @@ void ivas_dirac_param_est_enc_fx(
*------------------------------------------------------------------------*/
static void computeIntensityVector_enc_fx(
const DIRAC_ENC_HANDLE hDirAC,
- Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],
- Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],
- const Word16 enc_param_start_band, /* i : first band to process */
- const Word16 num_frequency_bands,
- Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS] )
+ Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* q_cldfb */
+ Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* q_cldfb */
+ const Word16 enc_param_start_band, /* i : first band to process Q0*/
+ const Word16 num_frequency_bands, /* Q0 */
+ Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS] /* q_intensity_real */
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ Word16 q_cldfb,
+ Word16 q_intensity_real[DIRAC_MAX_NBANDS]
+#endif
+)
{
/* Reminder
* X = a + ib; Y = c + id
@@ -1390,14 +1470,20 @@ static void computeIntensityVector_enc_fx(
Word16 i, j;
Word32 real, img;
Word16 brange[2];
-
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Word16 shift_value = sub( shl( q_cldfb, 1 ), 31 );
+#endif
FOR( i = 0; i < num_frequency_bands; i++ )
{
- brange[0] = hDirAC->band_grouping[i + enc_param_start_band];
+ brange[0] = hDirAC->band_grouping[i + enc_param_start_band]; /* Q0 */
move16();
- brange[1] = hDirAC->band_grouping[i + enc_param_start_band + 1];
+ brange[1] = hDirAC->band_grouping[i + enc_param_start_band + 1]; /* Q0 */
move16();
-
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Word16 num_bins = sub( brange[1], brange[0] );
+ Word16 gb = find_guarded_bits_fx( num_bins );
+ Word16 norm;
+#endif
intensity_real[0][i] = 0;
move32();
intensity_real[1][i] = 0;
@@ -1416,11 +1502,36 @@ static void computeIntensityVector_enc_fx(
move32();
img = Cldfb_ImagBuffer[0][j];
move32();
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Word64 t1, t2, t3;
+ t1 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), Cldfb_ImagBuffer[3][j], img ); /* 2 * q_cldfb + 1 */
+ t2 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), Cldfb_ImagBuffer[1][j], img ); /* 2 * q_cldfb + 1 */
+ t3 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[2][j], real ), Cldfb_ImagBuffer[2][j], img ); /* 2 * q_cldfb + 1 */
+ t1 = W_shr( t1, gb );
+ t2 = W_shr( t2, gb );
+ t3 = W_shr( t3, gb );
+ /* Intensity is XYZ order, audio is WYZX order. */
+ tmp_1 = W_add( tmp_1, t1 ); /* 2 * q_cldfb + 1 */
+ tmp_2 = W_add( tmp_2, t2 ); /* 2 * q_cldfb + 1 */
+ tmp_3 = W_add( tmp_3, t3 ); /* 2 * q_cldfb + 1 */
+#else
/* Intensity is XYZ order, audio is WYZX order. */
tmp_1 = W_add( tmp_1, W_add( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), W_mult_32_32( Cldfb_ImagBuffer[3][j], img ) ) );
tmp_2 = W_add( tmp_2, W_add( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), W_mult_32_32( Cldfb_ImagBuffer[1][j], img ) ) );
tmp_3 = W_add( tmp_3, W_add( W_mult_32_32( Cldfb_RealBuffer[2][j], real ), W_mult_32_32( Cldfb_ImagBuffer[2][j], img ) ) );
+#endif
}
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ norm = s_min( W_norm( tmp_1 ), W_norm( tmp_2 ) );
+ norm = s_min( norm, W_norm( tmp_3 ) );
+ intensity_real[0][i] = W_extract_h( W_shl( tmp_1, norm ) ); // shift_value - (gb - norm)
+ move32();
+ intensity_real[1][i] = W_extract_h( W_shl( tmp_2, norm ) ); // shift_value - (gb - norm)
+ move32();
+ intensity_real[2][i] = W_extract_h( W_shl( tmp_3, norm ) ); // shift_value - (gb - norm)
+ q_intensity_real[i] = sub( shift_value, sub( gb, norm ) );
+ move16();
+#else
intensity_real[0][i] = W_extract_h( tmp_1 ); // output Q= 2* input_q + 1 - 32
move32();
@@ -1428,6 +1539,7 @@ static void computeIntensityVector_enc_fx(
move32();
intensity_real[2][i] = W_extract_h( tmp_3 ); // output Q= 2* input_q + 1 - 32
move32();
+#endif
}
return;
@@ -1439,11 +1551,11 @@ static void computeIntensityVector_enc_fx(
*
*------------------------------------------------------------------------*/
void computeDiffuseness_mdft_fx(
- Word32 **buffer_intensity[DIRAC_NUM_DIMS],
- const Word32 *buffer_energy,
- const Word16 num_freq_bands,
- const UWord16 no_col_avg_diff,
- Word32 *diffuseness,
+ Word32 **buffer_intensity[DIRAC_NUM_DIMS], /* q_factor_intensity */
+ const Word32 *buffer_energy, /* q_factor_energy */
+ const Word16 num_freq_bands, /* Q0 */
+ const UWord16 no_col_avg_diff, /* Q0 */
+ Word32 *diffuseness, /* q_diffuseness */
Word16 *q_factor_intensity,
Word16 *q_factor_energy,
Word16 *q_diffuseness /*Ouput Q*/
@@ -1479,7 +1591,7 @@ void computeDiffuseness_mdft_fx(
FOR( k = 0; k < num_freq_bands; k++ )
{
- energy_slow[k] = BASOP_Util_Add_Mant32Exp( energy_slow[k], energy_slow_e[k], p_tmp_c[k], sub( 31, tmp_q ), &energy_slow_e[k] );
+ energy_slow[k] = BASOP_Util_Add_Mant32Exp( energy_slow[k], energy_slow_e[k], p_tmp_c[k], sub( 31, tmp_q ), &energy_slow_e[k] ); /* exp(energy_slow_e)*/
move32();
}
@@ -1489,7 +1601,7 @@ void computeDiffuseness_mdft_fx(
p_tmp = buffer_intensity[j][i];
FOR( k = 0; k < num_freq_bands; k++ )
{
- intensity_slow[j * num_freq_bands + k] = BASOP_Util_Add_Mant32Exp( intensity_slow[j * num_freq_bands + k], intensity_slow_e[j * num_freq_bands + k], p_tmp[k], sub( 31, q_factor_intensity[i] ), &intensity_slow_e[j * num_freq_bands + k] );
+ intensity_slow[j * num_freq_bands + k] = BASOP_Util_Add_Mant32Exp( intensity_slow[j * num_freq_bands + k], intensity_slow_e[j * num_freq_bands + k], p_tmp[k], sub( 31, q_factor_intensity[i] ), &intensity_slow_e[j * num_freq_bands + k] ); /* exp(intensity_slow_e) */
move32();
}
}
@@ -1503,10 +1615,10 @@ void computeDiffuseness_mdft_fx(
FOR( k = 0; k < num_freq_bands; k++ )
{
- p_tmp[k] = Mpy_32_32( p_tmp[k], p_tmp[k] );
+ p_tmp[k] = Mpy_32_32( p_tmp[k], p_tmp[k] ); /* 2 * (31-p_tmp_e) - 31 */
move32();
tmp_q = sub( shl( sub( 31, p_tmp_e[k] ), 1 ), 31 );
- intensity_slow_abs[k] = BASOP_Util_Add_Mant32Exp( intensity_slow_abs[k], intensity_slow_abs_e[k], p_tmp[k], sub( 31, tmp_q ), &intensity_slow_abs_e[k] );
+ intensity_slow_abs[k] = BASOP_Util_Add_Mant32Exp( intensity_slow_abs[k], intensity_slow_abs_e[k], p_tmp[k], sub( 31, tmp_q ), &intensity_slow_abs_e[k] ); /* exp(intensity_slow_abs_e) */
move32();
}
}
@@ -1519,7 +1631,7 @@ void computeDiffuseness_mdft_fx(
{
tmp = Sqrt32( p_tmp[i], &intensity_slow_abs_e[i] );
- tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp, L_add( energy_slow[i], EPSILLON_FX ), &tmp_q ) );
+ tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp, L_add( energy_slow[i], EPSILLON_FX ), &tmp_q ) ); /* exp(tmp_q) */
tmp_q = add( tmp_q, sub( intensity_slow_abs_e[i], energy_slow_e[i] ) );
tmp = L_shl_sat( tmp, tmp_q );
tmp = L_sub( ONE_IN_Q31, tmp );
diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c
index bf9cc3c34c520d2452eccdb2d31f5fd5c9b0dff2..95cafd8ff37212c36822565bdd641c9296d56731 100644
--- a/lib_enc/ivas_enc.c
+++ b/lib_enc/ivas_enc.c
@@ -52,9 +52,9 @@
* Principal IVAS encoder routine
*-------------------------------------------------------------------*/
ivas_error ivas_enc_fx(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 *data, /* i : input signal Q0 */
- const Word16 n_samples /* i : number of input samples */
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const Word16 *data, /* i : input signal Q0*/
+ const Word16 n_samples /* i : number of input samples Q0*/
)
{
Word16 i, n, input_frame, n_samples_chan, nchan_inp /*, scale*/;
@@ -77,10 +77,10 @@ ivas_error ivas_enc_fx(
hEncoderConfig = st_ivas->hEncoderConfig;
- input_Fs = hEncoderConfig->input_Fs;
+ input_Fs = hEncoderConfig->input_Fs; /* Q0 */
ivas_format = hEncoderConfig->ivas_format;
- nchan_inp = hEncoderConfig->nchan_inp;
- ivas_total_brate = hEncoderConfig->ivas_total_brate;
+ nchan_inp = hEncoderConfig->nchan_inp; /* Q0 */
+ ivas_total_brate = hEncoderConfig->ivas_total_brate; /* Q0 */
move32();
move32();
move16();
@@ -89,12 +89,12 @@ ivas_error ivas_enc_fx(
input_frame = extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) );
IF( NE_16( nchan_inp, 1 ) )
{
- n_samples_chan = div_l( L_deposit_l( n_samples ), nchan_inp );
- n_samples_chan = shl( n_samples_chan, 1 );
+ n_samples_chan = div_l( L_deposit_l( n_samples ), nchan_inp ); /* Q0 */
+ n_samples_chan = shl( n_samples_chan, 1 ); /* Q0 */
}
ELSE
{
- n_samples_chan = n_samples;
+ n_samples_chan = n_samples; /* Q0 */
move16();
}
set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 );
@@ -106,9 +106,12 @@ ivas_error ivas_enc_fx(
FOR( n = 0; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
{
data_fx[n] = st_ivas->p_data_fx[n];
+ IF( data_fx[n] )
+ {
+ Scale_sig32( data_fx[n], input_frame, sub( Q11, st_ivas->q_data_fx ) ); // Q11
+ }
}
-
- st_ivas->q_data_fx = 11; // Q-factor of the input buffer
+ st_ivas->q_data_fx = Q11;
move16();
n = 0;
move16();
@@ -119,7 +122,7 @@ ivas_error ivas_enc_fx(
data_fx[n][i] = L_mult0( data[i * nchan_inp + n], shl( 1, st_ivas->q_data_fx ) );
move32();
}
- n++;
+ n = add( n, 1 );
}
IF( LT_16( n_samples_chan, input_frame ) )
@@ -132,14 +135,14 @@ ivas_error ivas_enc_fx(
IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- IF( NE_32( ( error = ivas_sba_enc_reconfigure( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
- IF( NE_32( ( error = ivas_osba_enc_reconfig( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_osba_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -177,9 +180,9 @@ ivas_error ivas_enc_fx(
test();
IF( EQ_32( ivas_format, STEREO_FORMAT ) )
{
- st_ivas->hCPE[0]->element_brate = ivas_total_brate;
+ st_ivas->hCPE[0]->element_brate = ivas_total_brate; /* Q0 */
move32();
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, 0 /* no metadata */ ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, 0 /* no metadata */, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -187,7 +190,7 @@ ivas_error ivas_enc_fx(
ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) )
{
/* select ISM format mode; reconfigure the ISM format encoder */
- IF( NE_32( ( error = ivas_ism_enc_config( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_enc_config( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -200,7 +203,7 @@ ivas_error ivas_enc_fx(
ivas_param_ism_stereo_dmx_fx( st_ivas, data_fx, input_frame );
/* Core coding of Stereo DMX */
- IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -208,7 +211,7 @@ ivas_error ivas_enc_fx(
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) )
{
/* Analysis, decision about bitrates per channel & core coding */
- IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -238,25 +241,25 @@ ivas_error ivas_enc_fx(
{
ivas_masa_estimate_energy_fx( st_ivas->hMasa, data_fx, input_frame, st_ivas->nchan_transport, st_ivas->q_data_fx ); /* energy-estimation uses TF-resolution: 4x24 */
- IF( NE_32( ( error = ivas_masa_enc_config_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_enc_config_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
IF( EQ_16( st_ivas->nchan_transport, 2 ) )
{
- IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->hCPE[0]->element_mode,
- ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ),
- IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->hCPE[0]->element_mode,
+ ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) !=
+ IVAS_ERR_OK )
{
return error;
}
}
ELSE
{
- IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, -1,
- ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ),
- IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, -1,
+ ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) !=
+ IVAS_ERR_OK )
{
return error;
}
@@ -264,7 +267,7 @@ ivas_error ivas_enc_fx(
}
ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- IF( NE_32( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -278,21 +281,21 @@ ivas_error ivas_enc_fx(
/* core-coding of transport channels */
IF( EQ_16( st_ivas->nSCE, 1 ) )
{
- IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */
{
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0], NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) /* FOA/HOA format */
{
- IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -313,18 +316,18 @@ ivas_error ivas_enc_fx(
IF( EQ_16( sub( st_ivas->hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) )
{
v_multc_fixed( data_fx[hEncoderConfig->nchan_ism], L_deposit_h( INV_SQRT2_FX_Q15 ) /* Q31 */, data_fx[hEncoderConfig->nchan_ism], input_frame );
- Copy32( data_fx[hEncoderConfig->nchan_ism], data_fx[hEncoderConfig->nchan_ism + 1], input_frame );
+ Copy32( data_fx[hEncoderConfig->nchan_ism], data_fx[hEncoderConfig->nchan_ism + 1], input_frame ); /* st_ivas->q_data_fx */
}
/* Estimate TF-tile energy for the input MASA stream */
ivas_masa_estimate_energy_fx( st_ivas->hMasa, &( data_fx[hEncoderConfig->nchan_ism] ), input_frame, st_ivas->nchan_transport, st_ivas->q_data_fx );
- IF( NE_32( ( error = ivas_omasa_enc_config_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_omasa_enc_config_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- set_s( nb_bits_metadata, 0, MAX_SCE + 1 );
+ set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 );
idx_separated_object = 0;
move16();
@@ -338,14 +341,15 @@ ivas_error ivas_enc_fx(
/* Scaling data_fx */
{
Word16 norm_data_in = MAX16B;
+ move16();
FOR( i = 0; i < hEncoderConfig->nchan_ism + st_ivas->nchan_transport; i++ )
{
norm_data_in = s_min( norm_data_in, L_norm_arr( data_fx[i], input_frame ) );
}
- norm_data_in = sub( norm_data_in, 6 ); /*guard bit is 3->to handle overflow in cldfbAnalysis*/
+ norm_data_in = sub( norm_data_in, 7 ); /*guard bit is 4->to handle overflow in cldfbAnalysis*/
FOR( i = 0; i < hEncoderConfig->nchan_ism + st_ivas->nchan_transport; i++ )
{
- scale_sig32( data_fx[i], input_frame, norm_data_in );
+ scale_sig32( data_fx[i], input_frame, norm_data_in ); /* st_ivas->q_data_fx + norm_data_in */
}
st_ivas->q_data_fx = add( st_ivas->q_data_fx, norm_data_in );
move16();
@@ -377,14 +381,14 @@ ivas_error ivas_enc_fx(
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- flag_omasa_ener_brate = ivas_omasa_ener_brate_fx( st_ivas->hEncoderConfig->nchan_ism, ivas_total_brate, data_fx, input_frame, sub( 31, st_ivas->q_data_fx ) );
+ flag_omasa_ener_brate = ivas_omasa_ener_brate_fx( st_ivas->hEncoderConfig->nchan_ism, ivas_total_brate, data_fx, input_frame, sub( 31, st_ivas->q_data_fx ) ); /* Q0 */
/* Analysis, decision about bitrates per channel & core coding */
IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, &nb_bits_metadata[1], flag_omasa_ener_brate ) ), IVAS_ERR_OK ) )
{
return error;
}
- n = st_ivas->hEncoderConfig->nchan_ism;
+ n = st_ivas->hEncoderConfig->nchan_ism; /* Q0 */
move16();
}
@@ -398,7 +402,19 @@ ivas_error ivas_enc_fx(
}
/* Encode MASA parameters and write MASA metadata bitstream */
- IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1,
+ Word16 element_mode;
+ if ( st_ivas->nchan_transport == 2 )
+ {
+ element_mode = st_ivas->hCPE[0]->element_mode;
+ move16();
+ }
+ else
+ {
+ element_mode = -1;
+ move16();
+ }
+
+ IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, element_mode,
st_ivas->ism_mode, hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, idx_separated_object, st_ivas->hOMasa, st_ivas->hIsmMetaData[0]->ism_imp, flag_omasa_ener_brate ) ),
IVAS_ERR_OK ) )
{
@@ -414,7 +430,7 @@ ivas_error ivas_enc_fx(
);
/* Encode MASA transport channels */
- IF( ( ivas_cpe_enc_fx( st_ivas, 0, data_fx[n], data_fx[n + 1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
+ IF( ( ivas_cpe_enc_fx( st_ivas, 0, data_fx[n], data_fx[n + 1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0], NULL ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -430,11 +446,11 @@ ivas_error ivas_enc_fx(
IF( st_ivas->ism_mode == ISM_MODE_NONE )
{
- nchan = imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) );
+ nchan = imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ); /* Q0 */
}
ELSE
{
- nchan = hEncoderConfig->nchan_ism;
+ nchan = hEncoderConfig->nchan_ism; /* Q0 */
move16();
}
FOR( n = 0; n < nchan; n++ )
@@ -459,27 +475,27 @@ ivas_error ivas_enc_fx(
}
/* SBA metadata encoding and SBA metadata bitstream writing */
- IF( NE_32( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK )
{
return error;
}
- hEncoderConfig->sba_planar = planar_sba_orig;
+ hEncoderConfig->sba_planar = planar_sba_orig; /* Q0 */
move16();
}
ELSE
{
- n = hEncoderConfig->nchan_ism;
+ n = hEncoderConfig->nchan_ism; /* Q0 */
move16();
hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;
- IF( NE_32( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_fx( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK )
{
return error;
}
/* SBA metadata encoding and SBA metadata bitstream writing */
- IF( NE_32( ( error = ivas_spar_enc_fx( st_ivas, &data_fx[n], input_frame, nb_bits_metadata, hMetaData ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_fx( st_ivas, &data_fx[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -491,21 +507,21 @@ ivas_error ivas_enc_fx(
/* core-coding of transport channels */
IF( EQ_16( st_ivas->nSCE, 1 ) )
{
- IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */
{
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0], NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) /* FOA/HOA format */
{
- IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -514,7 +530,7 @@ ivas_error ivas_enc_fx(
ELSE IF( EQ_32( ivas_format, MC_FORMAT ) )
{
/* select MC format mode; write MC LS setup; reconfigure the MC format encoder */
- IF( NE_32( ( error = ivas_mc_enc_config_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mc_enc_config_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -571,7 +587,7 @@ ivas_error ivas_enc_fx(
ivas_lfe_enc_fx( st_ivas->hLFE, data_fx[LFE_CHANNEL], st_ivas->q_data_fx, input_frame, st_ivas->hLFE->hBstr );
- IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -583,14 +599,14 @@ ivas_error ivas_enc_fx(
IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */
{
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -625,23 +641,23 @@ ivas_error ivas_enc_fx(
scale_sig32( st_ivas->hQMetaData->q_direction[0].band_data[i].energy_ratio_fx, MAX_PARAM_SPATIAL_SUBFRAMES, -1 ); // Q31 -> Q30
}
- IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1,
- ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ),
- IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1,
+ ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) !=
+ IVAS_ERR_OK )
{
return error;
}
IF( st_ivas->hMcMasa->separateChannelEnabled )
{
- IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[2], st_ivas->q_data_fx, input_frame, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[2], st_ivas->q_data_fx, input_frame, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot;
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -650,14 +666,14 @@ ivas_error ivas_enc_fx(
{
IF( EQ_16( st_ivas->nSCE, 1 ) )
{
- IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */
{
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c
index cf42f8cc89beccfe7ef532296592e76bac70d6ae..7f08778781cb9a3d5d14867f087b6751b8aaa312 100644
--- a/lib_enc/ivas_enc_cov_handler.c
+++ b/lib_enc/ivas_enc_cov_handler.c
@@ -62,12 +62,12 @@ static void ivas_band_cov_fx( Word32 **ppIn_FR_real, Word32 **ppIn_FR_imag, Word
*------------------------------------------------------------------------*/
ivas_error ivas_spar_covar_enc_open_fx(
- ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */
- ivas_filterbank_t *pFb, /* i/o: FB handle */
- const Word32 input_Fs, /* i : input sampling rate */
- const Word16 nchan_inp, /* i : number of input channels */
- const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC*/
- const Word32 ivas_total_brate /* i : IVAS total bitrate */
+ ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */
+ ivas_filterbank_t *pFb, /* i/o: FB handle */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
+ const Word16 nchan_inp, /* i : number of input channels Q0*/
+ const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */
+ const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/
)
{
ivas_enc_cov_handler_state_t *hCovState;
@@ -92,7 +92,7 @@ ivas_error ivas_spar_covar_enc_open_fx(
{
cov_smooth_cfg.max_update_rate_fx = ONE_IN_Q31; // Q31
move32();
- cov_smooth_cfg.min_pool_size = 20;
+ cov_smooth_cfg.min_pool_size = 20; // Q0
move16();
}
@@ -111,7 +111,7 @@ ivas_error ivas_spar_covar_enc_open_fx(
return error;
}
- hCovState->num_bins = extract_l( Mpy_32_32( input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ hCovState->num_bins = extract_l( Mpy_32_32( input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
hCovState->prior_dtx_present = 0;
move16();
@@ -133,7 +133,7 @@ ivas_error ivas_spar_covar_enc_open_fx(
void ivas_spar_covar_enc_close_fx(
ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */
- const Word16 nchan_inp /* i : number of input channels */
+ const Word16 nchan_inp /* i : number of input channels Q0*/
)
{
ivas_enc_cov_handler_state_t *hCovState;
@@ -165,14 +165,15 @@ void ivas_spar_covar_enc_close_fx(
static Word16 ivas_spar_get_activeW_flag_fx(
ivas_enc_cov_handler_state_t *hCovEnc,
- Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
- Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_real */
+ Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_real */
Word16 *q_cov_real[IVAS_SPAR_MAX_CH],
- const Word16 dtx_vad,
- const Word16 nchan_inp,
- const Word16 nchan_transport,
- Word16 *res_ind,
- const Word16 *dmx_order )
+ const Word16 dtx_vad, /* Q0 */
+ const Word16 nchan_inp, /* Q0 */
+ const Word16 nchan_transport, /* Q0 */
+ Word16 *res_ind, /* Q0 */
+ const Word16 *dmx_order /* Q0 */
+)
{
Word16 b, ch, num_bands, num_chs, activeW_flag;
Word32 bb_var[FOA_CHANNELS], sm_fact, side_ch_var, en_ratio;
@@ -182,8 +183,8 @@ static Word16 ivas_spar_get_activeW_flag_fx(
Word32 L_tmp, L_tmp1;
Word16 exp_diff, q_com, guard_bits;
- num_chs = s_min( nchan_inp, FOA_CHANNELS );
- num_bands = ivas_get_num_bands_from_bw_idx( SPAR_CONFIG_BW );
+ num_chs = s_min( nchan_inp, FOA_CHANNELS ); /* Q0 */
+ num_bands = ivas_get_num_bands_from_bw_idx( SPAR_CONFIG_BW ); /* Q0 */
set_zero_fx( bb_var, FOA_CHANNELS );
set_s( q_bb_var, Q31, FOA_CHANNELS );
@@ -225,7 +226,7 @@ static Word16 ivas_spar_get_activeW_flag_fx(
q_shift = Q31;
move16();
q_shift = W_norm( bb_var_64bit[ch] );
- bb_var[ch] = W_extract_l( W_shl_nosat( bb_var_64bit[ch], sub( q_shift, 32 ) ) );
+ bb_var[ch] = W_extract_l( W_shl_nosat( bb_var_64bit[ch], sub( q_shift, 32 ) ) ); /* q_bb_var[ch] + sub( q_shift, 32 ) */
move32();
q_bb_var[ch] = add( q_bb_var[ch], sub( q_shift, 32 ) );
move16();
@@ -294,7 +295,7 @@ static Word16 ivas_spar_get_activeW_flag_fx(
{
Word16 max_idx;
Word32 max_val;
- max_idx = nchan_transport;
+ max_idx = nchan_transport; /* Q0 */
move16();
max_val = hCovEnc->bb_var_lt_fx[max_idx]; // q_bb_var[max_idx]
move32();
@@ -306,12 +307,12 @@ static Word16 ivas_spar_get_activeW_flag_fx(
move32();
}
}
- *res_ind = max_idx;
+ *res_ind = max_idx; /* Q0 */
move16();
}
ELSE IF( EQ_16( nchan_transport, 3 ) )
{
- *res_ind = dmx_order[nchan_transport];
+ *res_ind = dmx_order[nchan_transport]; /* Q0 */
move16();
}
}
@@ -328,25 +329,26 @@ return activeW_flag;
void ivas_enc_cov_handler_process_fx(
ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */
- Word32 **ppIn_FR_real,
- Word32 **ppIn_FR_imag,
+ Word32 **ppIn_FR_real, /* q_ppIn_FR */
+ Word32 **ppIn_FR_imag, /* q_ppIn_FR */
Word16 q_ppIn_FR,
- Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_real */
Word16 *q_cov_real[IVAS_SPAR_MAX_CH],
- Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_dtx_real */
Word16 *q_cov_dtx_real[IVAS_SPAR_MAX_CH],
- ivas_filterbank_t *pFb, /* i/o: FB handle */
- const Word16 start_band,
- const Word16 end_band,
- const Word16 num_ch,
- const Word16 dtx_vad,
- const Word16 transient_det[2],
- const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH],
- Word16 *res_ind,
- const Word16 *remix_order,
- Word16 *dyn_active_w_flag,
- const Word16 nchan_transport,
- const Word16 is_sba )
+ ivas_filterbank_t *pFb, /* i/o: FB handle */
+ const Word16 start_band, /* Q0 */
+ const Word16 end_band, /* Q0 */
+ const Word16 num_ch, /* Q0 */
+ const Word16 dtx_vad, /* Q0 */
+ const Word16 transient_det[2], /* Q0 */
+ const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH], /* Q0 */
+ Word16 *res_ind, /* Q0 */
+ const Word16 *remix_order, /* Q0 */
+ Word16 *dyn_active_w_flag, /* Q0 */
+ const Word16 nchan_transport, /* Q0 */
+ const Word16 is_sba /* Q0 */
+)
{
Word16 i, j;
Word16 dtx_cov_flag;
@@ -410,7 +412,7 @@ void ivas_enc_cov_handler_process_fx(
move16();
IF( GT_16( nchan_transport, 1 ) && LE_16( nchan_transport, sub( FOA_CHANNELS, 1 ) ) )
{
- *dyn_active_w_flag = ivas_spar_get_activeW_flag_fx( hCovEnc, cov_real, cov_real, q_cov_real, dtx_vad, num_ch, nchan_transport, res_ind, remix_order );
+ *dyn_active_w_flag = ivas_spar_get_activeW_flag_fx( hCovEnc, cov_real, cov_real, q_cov_real, dtx_vad, num_ch, nchan_transport, res_ind, remix_order ); /* Q0 */
}
ELSE
{
@@ -423,7 +425,7 @@ void ivas_enc_cov_handler_process_fx(
{
FOR( j = 0; j < num_ch; j++ )
{
- Copy32( cov_real[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands );
+ Copy32( cov_real[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands ); /* q_cov_real */
q_cov_dtx_real[i][j] = q_cov_real[i][j];
move16();
}
@@ -437,13 +439,13 @@ void ivas_enc_cov_handler_process_fx(
{
FOR( j = 0; j < num_ch; j++ )
{
- Copy32( cov_real[i][j], hCovEnc->pCov_dtx_state->pPrior_cov_real_fx[i][j], pFb->filterbank_num_bands );
+ Copy32( cov_real[i][j], hCovEnc->pCov_dtx_state->pPrior_cov_real_fx[i][j], pFb->filterbank_num_bands ); /* q_cov_real */
FOR( k = 0; k < pFb->filterbank_num_bands; k++ )
{
hCovEnc->pCov_dtx_state->q_prior_cov_real_per_band[i][j][k] = hCovEnc->pCov_state->q_cov_real_per_band[i][j][k];
move16();
}
- Copy32( cov_real[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands );
+ Copy32( cov_real[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands ); /* q_cov_real */
Copy( hCovEnc->pCov_state->q_cov_real_per_band[i][j], hCovEnc->pCov_dtx_state->q_cov_real_per_band[i][j], pFb->filterbank_num_bands );
}
}
@@ -472,7 +474,7 @@ void ivas_enc_cov_handler_process_fx(
{
FOR( j = 0; j < num_ch; j++ )
{
- Copy32( hCovEnc->pCov_dtx_state->pPrior_cov_real_fx[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands );
+ Copy32( hCovEnc->pCov_dtx_state->pPrior_cov_real_fx[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands ); /* q_cov_real */
FOR( k = 0; k < pFb->filterbank_num_bands; k++ )
{
hCovEnc->pCov_dtx_state->q_cov_real_per_band[i][j][k] = hCovEnc->pCov_dtx_state->q_prior_cov_real_per_band[i][j][k];
@@ -491,20 +493,21 @@ void ivas_enc_cov_handler_process_fx(
static void ivas_band_cov_fx(
- Word32 **ppIn_FR_real,
- Word32 **ppIn_FR_imag,
+ Word32 **ppIn_FR_real, /* q_In_FR */
+ Word32 **ppIn_FR_imag, /* q_In_FR */
Word16 q_In_FR,
- const Word16 num_chans,
- const Word16 num_bins,
- Word16 stride,
- Word32 **pFb_bin_to_band,
- const Word16 *pFb_start_bin_per_band,
- const Word16 *pFb_active_bins_per_band,
- const Word16 start_band,
- const Word16 end_band,
- Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ const Word16 num_chans, /* Q0 */
+ const Word16 num_bins, /* Q0 */
+ Word16 stride, /* Q0 */
+ Word32 **pFb_bin_to_band, /* Q22 */
+ const Word16 *pFb_start_bin_per_band, /* Q0 */
+ const Word16 *pFb_active_bins_per_band, /* Q0 */
+ const Word16 start_band, /* Q0 */
+ const Word16 end_band, /* Q0 */
+ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_real */
Word16 *q_cov_real[IVAS_SPAR_MAX_CH],
- const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] )
+ const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] /* Q0 */
+)
{
Word16 i, j, k;
Word32 pV_re[L_FRAME48k];
@@ -517,8 +520,8 @@ static void ivas_band_cov_fx(
{
FOR( j = i; j < num_chans; j++ )
{
- Word16 i1 = HOA_md_ind[i];
- Word16 j1 = HOA_md_ind[j];
+ Word16 i1 = HOA_md_ind[i]; /* Q0 */
+ Word16 j1 = HOA_md_ind[j]; /* Q0 */
move16();
move16();
@@ -559,11 +562,11 @@ static void ivas_band_cov_fx(
temp = 0;
move64();
- num_blocks = idiv1616( num_bins, stride );
+ num_blocks = idiv1616( num_bins, stride ); /* Q0 */
move16();
- start_bin = pFb_start_bin_per_band[k];
+ start_bin = pFb_start_bin_per_band[k]; /* Q0 */
move16();
- active_bins = pFb_active_bins_per_band[k];
+ active_bins = pFb_active_bins_per_band[k]; /* Q0 */
move16();
FOR( blk = 0; blk < num_blocks; blk++ )
@@ -599,7 +602,7 @@ static void ivas_band_cov_fx(
}
FOR( k = start_band; k < end_band; k++ )
{
- cov_real[i][j][k] = W_extract_l( W_shl_nosat( cov_real_64bit[i][j][k], sub( q_shift, 32 ) ) );
+ cov_real[i][j][k] = W_extract_l( W_shl_nosat( cov_real_64bit[i][j][k], sub( q_shift, 32 ) ) ); /* q_cov_real[i][j] + q_shift - 32 */
move32();
}
q_cov_real[i][j] = add( q_cov_real[i][j], sub( q_shift, 32 ) );
diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder.c
index 9949aab631b0a61d79d957f54ed71601fc9fdf6e..da4826776567c8b471c1c3ffaa35ace99882d301 100644
--- a/lib_enc/ivas_entropy_coder.c
+++ b/lib_enc/ivas_entropy_coder.c
@@ -51,18 +51,19 @@
*-----------------------------------------------------------------------------------------*/
static ivas_error ivas_get_dyn_freq_model_fx(
- Word16 *pInput,
- const Word16 length,
- Word16 *model_index,
+ Word16 *pInput, /* Q0 */
+ const Word16 length, /* Q0 */
+ Word16 *model_index, /* Q0 */
ivas_arith_t *pArith,
- Word16 **ppCum_freq )
+ Word16 **ppCum_freq /* Q0 */
+)
{
Word32 curr_dist[IVAS_MAX_QUANT_LEVELS];
Word16 i, n[IVAS_MAX_QUANT_LEVELS + 1], model_idx;
Word32 curr_bps, curr_bps_min, curr_bps_new;
Word16 range = pArith->range;
Word16 m;
- Word16 offset = negate( pArith->vals[0] );
+ Word16 offset = negate( pArith->vals[0] ); /* Q0 */
ivas_error error;
error = IVAS_ERR_OK;
move32();
@@ -75,7 +76,7 @@ static ivas_error ivas_get_dyn_freq_model_fx(
FOR( i = 0; i < length; i++ )
{
- n[pInput[i] + offset] = add( n[pInput[i] + offset], 1 );
+ n[pInput[i] + offset] = add( n[pInput[i] + offset], 1 ); /* Q0 */
move16();
}
@@ -85,7 +86,7 @@ static ivas_error ivas_get_dyn_freq_model_fx(
{
curr_dist[i] = L_deposit_l( n[i] );
move32();
- curr_bps = L_sub( curr_bps, curr_dist[i] * pArith->saved_dist_arr[0][i] );
+ curr_bps = L_sub( curr_bps, W_extract_l( W_mult0_32_32( curr_dist[i], pArith->saved_dist_arr[0][i] ) ) );
}
curr_bps_min = curr_bps;
move32();
@@ -104,7 +105,7 @@ static ivas_error ivas_get_dyn_freq_model_fx(
move32();
FOR( i = 0; i < range; i++ )
{
- curr_bps_new = L_sub( curr_bps_new, ( curr_dist[i] * pArith->saved_dist_arr[m + 1][i] ) );
+ curr_bps_new = L_sub( curr_bps_new, W_extract_l( W_mult0_32_32( curr_dist[i], pArith->saved_dist_arr[m + 1][i] ) ) );
}
#ifdef DEBUGGING
{
@@ -123,32 +124,34 @@ static ivas_error ivas_get_dyn_freq_model_fx(
IF( LT_32( curr_bps_min, curr_bps ) )
{
- *ppCum_freq = pArith->cum_freq[model_idx + 1];
- model_idx = add( model_idx, 1 );
+ *ppCum_freq = pArith->cum_freq[model_idx + 1]; /* Q0 */
+ model_idx = add( model_idx, 1 ); /* Q0 */
}
ELSE
{
model_idx = 0;
- *ppCum_freq = pArith->cum_freq[0];
+ move16();
+ *ppCum_freq = pArith->cum_freq[0]; /* Q0 */
}
- *model_index = model_idx;
+ *model_index = model_idx; /* Q0 */
move16();
return error;
}
/*-----------------------------------------------------------------------------------------*
- * Function ivas_arith_encode_array()
+ * Function ivas_arith_encode_array_fx()
*
* Arith encoding of an array of symbols
*-----------------------------------------------------------------------------------------*/
-static Word16 ivas_arith_encode_array(
- Word16 *pInput,
+static Word16 ivas_arith_encode_array_fx(
+ Word16 *pInput, /* Q0 */
ivas_arith_t *pArith,
BSTR_ENC_HANDLE hMetaData,
- const Word16 in_len,
- const Word16 wc_strat_arith )
+ const Word16 in_len, /* Q0 */
+ const Word16 wc_strat_arith /* Q0 */
+)
{
Word16 model_index, i, ind;
Word16 *pCum_freq = NULL;
@@ -168,14 +171,14 @@ static Word16 ivas_arith_encode_array(
}
ELSE
{
- pCum_freq = pArith->cum_freq[0];
+ pCum_freq = pArith->cum_freq[0]; /* Q0 */
}
ari_start_encoding_14bits( &as );
FOR( i = 0; i < in_len; i++ )
{
- ind = sub( pInput[i], pArith->vals[0] );
+ ind = sub( pInput[i], pArith->vals[0] ); /* Q0 */
ivas_ari_encode_14bits_ext_fx( hMetaData, &as, ind, (const UWord16 *) pCum_freq );
IF( GT_16( hMetaData->nb_bits_tot, wc_strat_arith ) )
{
@@ -195,18 +198,19 @@ static Word16 ivas_arith_encode_array(
/*-----------------------------------------------------------------------------------------*
- * Function ivas_arithCoder_encode_array_diff()
+ * Function ivas_arithCoder_encode_array_diff_fx()
*
* Differential arith encoding
*-----------------------------------------------------------------------------------------*/
-static Word16 ivas_arithCoder_encode_array_diff(
+static Word16 ivas_arithCoder_encode_array_diff_fx(
ivas_arith_t *pArith_diff,
- Word16 *pIn_new,
- Word16 *pIn_old_scratch,
- const Word16 length,
+ Word16 *pIn_new, /* Q0 */
+ Word16 *pIn_old_scratch, /* Q0 */
+ const Word16 length, /* Q0 */
BSTR_ENC_HANDLE hMetaData,
- const Word16 wc_strat_arith )
+ const Word16 wc_strat_arith /* Q0 */
+)
{
Word16 n;
Word16 arith_result;
@@ -215,13 +219,13 @@ static Word16 ivas_arithCoder_encode_array_diff(
{
FOR( n = 0; n < length; n++ )
{
- pIn_old_scratch[n] = sub( pIn_new[n], pIn_old_scratch[n] );
+ pIn_old_scratch[n] = sub( pIn_new[n], pIn_old_scratch[n] ); /* Q0 */
move16();
}
ivas_wrap_arround_fx( pIn_old_scratch, pArith_diff->vals[0], pArith_diff->vals[pArith_diff->range - 1], length );
- arith_result = ivas_arith_encode_array( pIn_old_scratch, pArith_diff, hMetaData, length, wc_strat_arith );
+ arith_result = ivas_arith_encode_array_fx( pIn_old_scratch, pArith_diff, hMetaData, length, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
@@ -233,27 +237,28 @@ static Word16 ivas_arithCoder_encode_array_diff(
/*-----------------------------------------------------------------------------------------*
- * Function ivas_huffman_encode()
+ * Function ivas_huffman_encode_fx()
*
* ivas_huffman_encode
*-----------------------------------------------------------------------------------------*/
-void ivas_huffman_encode(
+void ivas_huffman_encode_fx(
ivas_huffman_cfg_t *huff_cfg,
- Word16 in,
- Word16 *hcode,
- Word16 *hlen )
+ Word16 in, /* Q0 */
+ Word16 *hcode, /* Q0 */
+ Word16 *hlen /* Q0 */
+)
{
Word16 min_sym_val;
const Word16 *codebook;
- min_sym_val = huff_cfg->codebook[0];
+ min_sym_val = huff_cfg->codebook[0]; /* Q0 */
move16();
- codebook = &huff_cfg->codebook[3 * ( in - min_sym_val )];
- *hlen = codebook[1];
+ codebook = &huff_cfg->codebook[3 * ( in - min_sym_val )]; /* Q0 */
+ *hlen = codebook[1]; /* Q0 */
move16();
- *hcode = codebook[2];
+ *hcode = codebook[2]; /* Q0 */
move16();
return;
@@ -261,17 +266,17 @@ void ivas_huffman_encode(
/*-----------------------------------------------------------------------------------------*
- * Function arith_encode_cell_array()
+ * Function arith_encode_cell_array_fx()
*
* Arithmetic encode a cell array
*-----------------------------------------------------------------------------------------*/
-static Word16 arith_encode_cell_array(
+static Word16 arith_encode_cell_array_fx(
ivas_cell_dim_t *pCell_dims,
BSTR_ENC_HANDLE hMetaData,
- const Word16 nB,
+ const Word16 nB, /* Q0 */
ivas_arith_t *pArith,
- Word16 *pSymbol,
+ Word16 *pSymbol, /* Q0 */
const Word16 wc_strat_arith )
{
Word16 total_symbol_len = 0;
@@ -281,7 +286,7 @@ static Word16 arith_encode_cell_array(
FOR( i = 0; i < nB; i++ )
{
- total_symbol_len = add( total_symbol_len, imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) );
+ total_symbol_len = add( total_symbol_len, imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) ); /* Q0 */
}
assert( LE_16( total_symbol_len, ( IVAS_MAX_INPUT_LEN ) ) );
@@ -290,7 +295,7 @@ static Word16 arith_encode_cell_array(
{
IF( GT_16( pArith->range, 1 ) )
{
- arith_result = ivas_arith_encode_array( pSymbol, pArith, hMetaData, total_symbol_len, wc_strat_arith );
+ arith_result = ivas_arith_encode_array_fx( pSymbol, pArith, hMetaData, total_symbol_len, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
@@ -303,19 +308,20 @@ static Word16 arith_encode_cell_array(
/*-----------------------------------------------------------------------------------------*
- * Function arith_encode_cell_array_diff()
+ * Function arith_encode_cell_array_diff_fx()
*
* Arithmetic encode a cell array - differential
*-----------------------------------------------------------------------------------------*/
-static Word16 arith_encode_cell_array_diff(
+static Word16 arith_encode_cell_array_diff_fx(
const ivas_cell_dim_t *pCell_dims,
BSTR_ENC_HANDLE hMetaData,
- Word16 nB,
+ Word16 nB, /* Q0 */
ivas_arith_t *pArith_diff,
- Word16 *pSymbol_old,
- Word16 *pSymbol,
- const Word16 wc_strat_arith )
+ Word16 *pSymbol_old, /* Q0 */
+ Word16 *pSymbol, /* Q0 */
+ const Word16 wc_strat_arith /* Q0 */
+)
{
Word16 i, total_symbol_len;
Word16 arith_result;
@@ -324,7 +330,7 @@ static Word16 arith_encode_cell_array_diff(
move16();
FOR( i = 0; i < nB; i++ )
{
- total_symbol_len = add( total_symbol_len, ( imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) ) );
+ total_symbol_len = add( total_symbol_len, ( imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) ) ); /* Q0 */
}
assert( LE_16( total_symbol_len, ( IVAS_MAX_INPUT_LEN ) ) );
@@ -333,7 +339,7 @@ static Word16 arith_encode_cell_array_diff(
{
IF( GT_16( pArith_diff->range, 1 ) )
{
- arith_result = ivas_arithCoder_encode_array_diff( pArith_diff, pSymbol, pSymbol_old, total_symbol_len, hMetaData, wc_strat_arith );
+ arith_result = ivas_arithCoder_encode_array_diff_fx( pArith_diff, pSymbol, pSymbol_old, total_symbol_len, hMetaData, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
@@ -346,22 +352,23 @@ static Word16 arith_encode_cell_array_diff(
/*-----------------------------------------------------------------------------------------*
- * Function ivas_arith_encode_cmplx_cell_array()
+ * Function ivas_arith_encode_cmplx_cell_array_fx()
*
* Arithmetic encode a cell array
*-----------------------------------------------------------------------------------------*/
-Word16 ivas_arith_encode_cmplx_cell_array(
+Word16 ivas_arith_encode_cmplx_cell_array_fx(
ivas_arith_t *pArith_re,
ivas_arith_t *pArith_re_diff,
- const Word16 *pDo_diff,
- const Word16 nB,
- Word16 *pSymbol_re,
- Word16 *pSymbol_old_re,
+ const Word16 *pDo_diff, /* Q0 */
+ const Word16 nB, /* Q0 */
+ Word16 *pSymbol_re, /* Q0 */
+ Word16 *pSymbol_old_re, /* Q0 */
ivas_cell_dim_t *pCell_dims,
BSTR_ENC_HANDLE hMetaData,
- const Word16 any_diff,
- const Word16 wc_strat_arith )
+ const Word16 any_diff, /* Q0 */
+ const Word16 wc_strat_arith /* Q0 */
+)
{
Word16 input_old[IVAS_MAX_INPUT_LEN];
Word16 input_new[IVAS_MAX_INPUT_LEN];
@@ -381,19 +388,19 @@ Word16 ivas_arith_encode_cmplx_cell_array(
move16();
FOR( i = 0; i < nB; i++ )
{
- len = ( imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) );
+ len = ( imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) ); /* Q0 */
move16();
IF( pDo_diff[i] != 0 )
{
FOR( j = 0; j < len; j++ )
{
- input_old[idx] = pSymbol_old_re[total_len + j];
- input_new[idx++] = pSymbol_re[total_len + j];
+ input_old[idx] = pSymbol_old_re[total_len + j]; /* Q0 */
+ input_new[idx++] = pSymbol_re[total_len + j]; /* Q0 */
move16();
move16();
}
- cell_dim_diff[i].dim1 = pCell_dims[i].dim1;
- cell_dim_diff[i].dim2 = pCell_dims[i].dim2;
+ cell_dim_diff[i].dim1 = pCell_dims[i].dim1; /* Q0 */
+ cell_dim_diff[i].dim2 = pCell_dims[i].dim2; /* Q0 */
cell_dim[i].dim1 = 0;
cell_dim[i].dim2 = 0;
move16();
@@ -405,28 +412,28 @@ Word16 ivas_arith_encode_cmplx_cell_array(
{
FOR( j = 0; j < len; j++ )
{
- input[idx1++] = pSymbol_re[total_len + j];
+ input[idx1++] = pSymbol_re[total_len + j]; /* Q0 */
move16();
}
cell_dim_diff[i].dim1 = 0;
cell_dim_diff[i].dim2 = 0;
- cell_dim[i].dim1 = pCell_dims[i].dim1;
- cell_dim[i].dim2 = pCell_dims[i].dim2;
+ cell_dim[i].dim1 = pCell_dims[i].dim1; /* Q0 */
+ cell_dim[i].dim2 = pCell_dims[i].dim2; /* Q0 */
move16();
move16();
move16();
move16();
}
- total_len = add( total_len, len );
+ total_len = add( total_len, len ); /* Q0 */
}
- arith_result = arith_encode_cell_array( cell_dim, hMetaData, nB, pArith_re, input, wc_strat_arith );
+ arith_result = arith_encode_cell_array_fx( cell_dim, hMetaData, nB, pArith_re, input, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
}
- arith_result = arith_encode_cell_array_diff( cell_dim_diff, hMetaData, nB, pArith_re_diff, input_old, input_new, wc_strat_arith );
+ arith_result = arith_encode_cell_array_diff_fx( cell_dim_diff, hMetaData, nB, pArith_re_diff, input_old, input_new, wc_strat_arith ); /* Q0 */
move16();
IF( arith_result < 0 )
{
@@ -435,7 +442,7 @@ Word16 ivas_arith_encode_cmplx_cell_array(
}
ELSE
{
- arith_result = arith_encode_cell_array( pCell_dims, hMetaData, nB, pArith_re, pSymbol_re, wc_strat_arith );
+ arith_result = arith_encode_cell_array_fx( pCell_dims, hMetaData, nB, pArith_re, pSymbol_re, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c
index f892dca8f87d7936ebbb81c09e093f94221a4a7c..023b9fa59b72e7cb023a38f0937677bc526dc58d 100644
--- a/lib_enc/ivas_front_vad.c
+++ b/lib_enc/ivas_front_vad.c
@@ -52,21 +52,25 @@
* Standalone front-VAD module
*-----------------------------------------------------------------------------------------*/
ivas_error front_vad_fx(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */
- Encoder_State *st, /* i/o: encoder state structure */
- const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
- FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: FrontVad handles */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word16 input_frame, /* i : frame length */
- Word16 vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */
- Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands Q_buffer[n] + QSCALE + 2 */
- Word16 Etot_LR_fx[], /* o : total energy Left & Right channel Q8 */
- Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels Q_buffer[n] + QSCALE */
- Word16 localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels */
- Word16 vad_hover_flag[], /* o : VAD hangover flag */
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN Q_buffer[1] + QSCALE + 2 - band_ener_guardbits*/
- Word32 *PS_out_fx, /* o : energy spectrum Q_buffer + QSCALE */
- Word16 *Bin_E_out_fx, /* o : log-energy spectrum of the current frame Q7 */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */
+ Encoder_State *st, /* i/o: encoder state structure */
+ const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
+ FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: FrontVad handles */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ Word16 vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO Q0*/
+ Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands q_fr_bands_fx*/
+ Word16 q_fr_bands[], /* o : Q of fr_bands_fx */
+ Word16 Etot_LR_fx[], /* o : total energy Left & Right channel Q8*/
+ Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels q_lf_E*/
+ Word16 q_lf_E[], /* o : Q of lf_E_fx */
+ Word16 localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels Q0*/
+ Word16 vad_hover_flag[], /* o : VAD hangover flag Q0*/
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN q_band_energies_LR */
+ Word16 *q_band_energies_LR, /* o : Q of band_energies_LR_fx */
+ Word32 *PS_out_fx, /* o : energy spectrum q_PS_out*/
+ Word16 *q_PS_out, /* o : Q of PS_out_fx Q0*/
+ Word16 *Bin_E_out_fx, /* o : log-energy spectrum of the current frame Q7*/
Word16 Q_inp,
Word16 *Q_buffer,
Word16 Q_add,
@@ -86,24 +90,30 @@ ivas_error front_vad_fx(
Word16 dummy_short;
Word16 element_mode, last_element_mode;
ivas_error error;
- Word16 Q_new = 0, band_ener_guardbits = 0;
+ Word16 Q_new;
Word16 Qband, mem_decim_size;
error = IVAS_ERR_OK;
push_wmops( "front_vad" );
+ move16();
+ move16();
+
+ Q_new = 0;
+ move16();
lgBin_E_fx = NULL;
if ( st != NULL )
{
- lgBin_E_fx = &st->lgBin_E_fx[0];
+ lgBin_E_fx = &st->lgBin_E_fx[0]; /* Q8 */
move16();
}
IF( hCPE != NULL )
{
n_chan = CPE_CHANNELS;
+ move16();
sts = &hCPE->hCoreCoder[0];
- element_mode = hCPE->element_mode;
+ element_mode = hCPE->element_mode; /* Q0 */
move16();
- last_element_mode = hCPE->last_element_mode;
+ last_element_mode = hCPE->last_element_mode; /* Q0 */
move16();
}
ELSE IF( st != NULL )
@@ -192,13 +202,16 @@ ivas_error front_vad_fx(
{
FOR( n = 0; n < n_chan; n++ )
{
- scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, 20, sub( add( Q_new_old, QSCALE ), Q11 ) );
- scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE ), Q11 ) );
+ scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, 20, sub( add( Q_new_old, QSCALE ), Q11 ) ); /* Q_new_old + QSCALE */
+ scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE ), Q11 ) ); /* Q_new_old + QSCALE */
hFrontVads[n]->lp_speech_fx = shr( hFrontVads[n]->lp_speech_fx, 1 );
move16();
}
}
- band_ener_guardbits = find_guarded_bits_fx( 2 * NB_BANDS );
+
+ Word16 q_Bin_E, q_Bin_E_old;
+ Word16 q_band_energies;
+ Word16 q_fft_buffLR;
FOR( n = 0; n < n_chan; n++ )
{
FRONT_VAD_ENC_HANDLE hFrontVad;
@@ -212,50 +225,96 @@ ivas_error front_vad_fx(
modify_Fs_fx( sts[n]->input_fx, input_frame, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2, INT_FS_12k8, hFrontVad->mem_decim_fx, ( sts[0]->max_bwidth == NB ), &Qband, &mem_decim_size );
/* Preemphasis */
- hFrontVad->mem_preemph_fx = shl( hFrontVad->mem_preemph_fx, sub( add( Q_inp, Qband ), hFrontVad->q_mem_preemph_fx ) );
+ hFrontVad->mem_preemph_fx = shl( hFrontVad->mem_preemph_fx, sub( add( Q_inp, Qband ), hFrontVad->q_mem_preemph_fx ) ); /* Q_inp + Qband */
move16();
hFrontVad->q_mem_preemph_fx = add( Q_inp, Qband );
move16();
PREEMPH_FX( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx );
- Word16 Scale_fac[2];
Q_new = add( sub( Q_inp, Qband ), Q_add );
- Scale_sig( hFrontVad->buffer_12k8_fx, L_FFT / 2, Q_new - Q_buffer[n] );
- Scale_sig( hFrontVad->buffer_12k8_fx + L_FFT / 2, 384 - L_FFT / 2, Q_new - add( Q_inp, Qband ) );
+ Scale_sig( hFrontVad->buffer_12k8_fx, L_FFT / 2, sub( Q_new, Q_buffer[n] ) ); /* Q_new */
+ Scale_sig( hFrontVad->buffer_12k8_fx + L_FFT / 2, 384 - L_FFT / 2, sub( Q_new, add( Q_inp, Qband ) ) ); /* Q_new */
Q_buffer[n] = Q_new;
- Word32 Le_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_new, QSCALE ) ) ), 1 ), 1 );
- Le_min_scaled = L_shl( Le_min_scaled, 2 );
- ivas_analy_sp_fx( IVAS_CPE_TD, hCPE, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2 - 3 * ( L_SUBFR / 2 ), Q_new, fr_bands_fx[n], lf_E_fx[n], &Etot_LR_fx[n], sts[0]->min_band, sts[0]->max_band, Le_min_scaled, Scale_fac, Bin_E_fx, Bin_E_old_fx, PS_fx, lgBin_E_fx, band_energies_fx, fft_buffLR_fx );
+ move16();
+
+ ivas_analy_sp_fx( IVAS_CPE_TD, hCPE, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2 - 3 * ( L_SUBFR / 2 ), Q_new, fr_bands_fx[n],
+ &q_fr_bands[n], lf_E_fx[n], &q_lf_E[n], &Etot_LR_fx[n], sts[0]->min_band, sts[0]->max_band, Bin_E_fx, &q_Bin_E, Bin_E_old_fx,
+ &q_Bin_E_old, PS_fx, q_PS_out, lgBin_E_fx, band_energies_fx, &q_band_energies, fft_buffLR_fx, &q_fft_buffLR );
+ if ( n == 0 )
+ {
+ *q_band_energies_LR = q_band_energies;
+ move16();
+ }
+
+ /* v_add( &band_energies[0], &band_energies_LR[0], &band_energies_LR[0], 2 * NB_BANDS ); */
+ IF( EQ_16( n, 1 ) )
+ {
+ IF( LT_16( *q_band_energies_LR, q_band_energies ) )
+ {
+ scale_sig32( band_energies_fx, 2 * NB_BANDS, sub( *q_band_energies_LR, q_band_energies ) ); // q_band_energies_LR
+ }
+ ELSE
+ {
+ scale_sig32( band_energies_LR_fx, 2 * NB_BANDS, sub( q_band_energies, *q_band_energies_LR ) ); // q_band_energies_LR
+ *q_band_energies_LR = q_band_energies;
+ move16();
+ }
+ }
+
+ v_add_fx( &band_energies_fx[0], &band_energies_LR_fx[0], &band_energies_LR_fx[0], 2 * NB_BANDS ); // q_band_energies_LR
/* add up energies for later calculating average of channel energies */
- // Scale_sig32( &band_energies_LR_fx[0], ( Q_new + QSCALE + 2 ) - ( Q_new_old + QSCALE + 2 - band_ener_guardbits ), 40 );
Q_new_old = Q_new;
- v_add_fixed( &band_energies_fx[0], &band_energies_LR_fx[0], &band_energies_LR_fx[0], 2 * NB_BANDS, band_ener_guardbits );
+ move16();
- Word32 Etot_fx = L_deposit_h( Etot_LR_fx[n] );
+ Word32 Etot_fx = L_deposit_h( Etot_LR_fx[n] ); /* Q24 */
noise_est_pre_32fx( Etot_fx, hFrontVads[0]->ini_frame, hFrontVad->hNoiseEst, 0, 0, 0 );
/* wb_vad */
- Scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS, Q_new + QSCALE - ( Q_new_old + QSCALE ) );
- Scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS, Q_new + QSCALE - ( Q_new_old + QSCALE ) );
- hFrontVad->hVAD->vad_flag = wb_vad_ivas_fx( sts[n], fr_bands_fx[n], &dummy, &dummy, &dummy, &snr_sum_he_fx, &localVAD_HE_SAD[n], &dummy_short, Q_new, hFrontVad->hVAD, hFrontVad->hNoiseEst, hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx );
+ Word16 scale = getScaleFactor32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS );
+ scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS, scale ); // hFrontVads[n]->hNoiseEst->q_bckr + scale
+ hFrontVads[n]->hNoiseEst->q_bckr = add( hFrontVads[n]->hNoiseEst->q_bckr, scale );
+ move16();
+
+ scale = getScaleFactor32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS );
+ scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS, scale ); // hFrontVads[n]->hNoiseEst->q_enrO + scale
+ hFrontVads[n]->hNoiseEst->q_enrO = add( hFrontVads[n]->hNoiseEst->q_enrO, scale );
+ move16();
+
+ scale = s_min( q_fr_bands[n], s_min( hFrontVads[n]->hNoiseEst->q_bckr, hFrontVads[n]->hNoiseEst->q_enrO ) );
+
+ scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVads[n]->hNoiseEst->q_bckr ) ); // scale
+ hFrontVads[n]->hNoiseEst->q_bckr = scale;
+ move16();
+
+ scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS, sub( scale, hFrontVads[n]->hNoiseEst->q_enrO ) ); // scale
+ hFrontVads[n]->hNoiseEst->q_enrO = scale;
+ move16();
+
+ scale_sig32( fr_bands_fx[n], 2 * NB_BANDS, sub( scale, q_fr_bands[n] ) ); // scale
+ q_fr_bands[n] = scale;
+ move16();
+
+ hFrontVad->hVAD->vad_flag = wb_vad_ivas_fx( sts[n], fr_bands_fx[n], q_fr_bands[n], &dummy, &dummy, &dummy, &snr_sum_he_fx,
+ &localVAD_HE_SAD[n], &dummy_short, hFrontVad->hVAD, hFrontVad->hNoiseEst,
+ hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ); // Q0
test();
test();
if ( n == 0 && GT_16( n_chan, 1 ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) )
{
- sts[1]->last_coder_type = sts[0]->last_coder_type;
+ sts[1]->last_coder_type = sts[0]->last_coder_type; /* Q0 */
move16();
}
- vad_flag_dtx[n] = ivas_dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, hFrontVad->lp_speech_fx - hFrontVad->lp_noise_fx, 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho );
+ vad_flag_dtx[n] = ivas_dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */
move16();
if ( EQ_16( n_chan, 1 ) )
{
- sts[n]->vad_flag = hFrontVad->hVAD->vad_flag;
+ sts[n]->vad_flag = hFrontVad->hVAD->vad_flag; /* Q0 */
move16();
}
}
@@ -263,10 +322,12 @@ ivas_error front_vad_fx(
IF( EQ_16( n_chan, CPE_CHANNELS ) )
{
/* get average channel energies, adding up was already done, so only need to scale by number of channels */
- v_multc_fixed( &band_energies_LR_fx[0], ONE_IN_Q30, &band_energies_LR_fx[0], 2 * NB_BANDS );
+ v_multc_fixed( &band_energies_LR_fx[0], ONE_IN_Q30 /* 0.5f in Q31 */, &band_energies_LR_fx[0], 2 * NB_BANDS );
/* Logical OR between L and R decisions */
+ test();
vad_flag_dtx[0] = vad_flag_dtx[0] || vad_flag_dtx[1];
+ move16();
}
IF( sts[0]->hFdCngEnc != NULL )
{
@@ -433,10 +494,10 @@ void front_vad_destroy_fx(
* Standalone front-VAD module for SPAR
*-----------------------------------------------------------------------------------------*/
ivas_error front_vad_spar_fx(
- SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */
- const Word32 *omni_in, /* i : omnidirectional input signal Q11 */
- ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */
- const Word16 input_frame /* i : input frame length */
+ SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */
+ const Word32 *omni_in, /* i : omnidirectional input signal Q11*/
+ ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */
+ const Word16 input_frame /* i : input frame length Q0*/
)
{
FRONT_VAD_ENC_HANDLE hFrontVad;
@@ -488,6 +549,7 @@ ivas_error front_vad_spar_fx(
Word16 tmp;
Word16 old_pitch;
ivas_error error;
+ Word16 Qfact_PS;
push_wmops( "front_vad_SPAR" );
error = IVAS_ERR_OK;
@@ -511,8 +573,8 @@ ivas_error front_vad_spar_fx(
Word16 Q_bands = Q9;
move16();
- Scale_sig32( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS, ( Q_bands + QSCALE ) - hFrontVad->hNoiseEst->ave_enr_q );
- Scale_sig32( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS, ( Q_bands + QSCALE ) - hFrontVad->hNoiseEst->ave_enr_q );
+ Scale_sig32( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS, ( Q_bands + QSCALE ) - hFrontVad->hNoiseEst->ave_enr_q ); /* Q_bands + QSCALE */
+ Scale_sig32( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS, ( Q_bands + QSCALE ) - hFrontVad->hNoiseEst->ave_enr_q ); /* Q_bands + QSCALE */
hFrontVad->hNoiseEst->ave_enr_q = ( Q_bands + QSCALE );
move16();
Word16 tmp1;
@@ -525,8 +587,8 @@ ivas_error front_vad_spar_fx(
MVR2R_WORD16( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM );
wsp_fx = old_wsp_fx + L_WSP_MEM;
- st->core_brate = -1; /* updated in dtx() */
- st->input_bwidth = st->last_input_bwidth;
+ st->core_brate = -1; /* updated in dtx() */
+ st->input_bwidth = st->last_input_bwidth; /* Q0 */
move32();
move16();
@@ -535,7 +597,7 @@ ivas_error front_vad_spar_fx(
*-----------------------------------------------------------------*/
st->input_fx = input_fx;
- Copy_Scale_sig32_16( omni_in, st->input_fx, input_frame, Q16 - Q11 );
+ Copy_Scale_sig32_16( omni_in, st->input_fx, input_frame, Q16 - Q11 ); /* Q16 */
delay_signal( st->input_fx, input_frame, hFrontVad->delay_buf_fx, hFrontVad->delay_samples );
/* Scaling only if the omni_in buffer contains non-zero values */
@@ -559,7 +621,7 @@ ivas_error front_vad_spar_fx(
}
IF( tmp != 0 )
{
- Scale_sig( st->input_fx, input_frame, s );
+ Scale_sig( st->input_fx, input_frame, s ); /* s */
}
Q_inp = s;
move16();
@@ -571,15 +633,22 @@ ivas_error front_vad_spar_fx(
Word16 Q_new_old = add( sub( Q_inp, Qband ), Q_add );
Scale_sig32( hFrontVad->hNoiseEst->bckr_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_bckr ) ); // Q_new_old +QSCALE +2
- Scale_sig32( hFrontVad->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_enrO ) );
- hFrontVad->hNoiseEst->q_enrO = add( Q_new_old, QSCALE + 2 );
+ Scale_sig32( hFrontVad->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_enrO ) ); // Q_new_old +QSCALE +2
+ hFrontVad->hNoiseEst->q_bckr = add( Q_new_old, QSCALE + 2 );
+ move16();
+ hFrontVad->hNoiseEst->q_enrO = hFrontVad->hNoiseEst->q_bckr;
move16();
Word16 Q_buffer = hFrontVad->q_buffer_12k8;
move16();
- Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp, hFrontVad->q_mem_decim ) );
+ Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp, hFrontVad->q_mem_decim ) ); /* Q_inp */
hFrontVad->q_mem_decim = Q_inp;
move16();
- IF( NE_32( ( error = front_vad_fx( NULL, st, hEncoderConfig, &hFrontVad, 0 /* MCT_flag */, input_frame, vad_flag_dtx, fr_bands_fx, Etot_fx, lf_E_fx, localVAD_HE_SAD, vad_hover_flag, band_energies_fx, &PS_fx[0], &st->lgBin_E_fx[0], Q_inp, &Q_buffer, Q_add, &front_create_flag ) ), IVAS_ERR_OK ) )
+ Word16 q_band_energies;
+ Word16 q_fr_bands[2], q_lf_E[2];
+ IF( NE_32( ( error = front_vad_fx( NULL, st, hEncoderConfig, &hFrontVad, 0 /* MCT_flag */, input_frame, vad_flag_dtx, fr_bands_fx,
+ q_fr_bands, Etot_fx, lf_E_fx, q_lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_fx,
+ &q_band_energies, PS_fx, &Qfact_PS, &st->lgBin_E_fx[0], Q_inp, &Q_buffer, Q_add, &front_create_flag ) ),
+ IVAS_ERR_OK ) )
{
return error;
}
@@ -589,25 +658,23 @@ ivas_error front_vad_spar_fx(
Q_inp_12k8 = hFrontVad->q_buffer_12k8;
move16();
- IF( st->lgBin_E_fx != NULL )
- {
- Copy_Scale_sig_16_32( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
- }
- Scale_sig32( fr_bands_fx[0], 40, sub( ( Q_bands + QSCALE ), add( Q_buffer, QSCALE + 2 ) ) );
+ Scale_sig32( fr_bands_fx[0], 40, sub( add( Q_bands, QSCALE ), q_fr_bands[0] ) ); // Q_bands+QSCALE
+ q_fr_bands[0] = add( Q_bands, QSCALE );
+ move16();
Word32 e_min_scaled;
e_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_bands, QSCALE ) ) ), 1 ), 1 );
- Scale_sig32( hFrontVad->hNoiseEst->bckr_fx, 20, sub( Q_bands + QSCALE, add( Q_new_old, QSCALE + 2 ) ) );
- hFrontVad->hNoiseEst->q_bckr = Q_bands + QSCALE;
+ Scale_sig32( hFrontVad->hNoiseEst->bckr_fx, 20, sub( add( Q_bands, QSCALE ), hFrontVad->hNoiseEst->q_bckr ) ); /* Q_bands + QSCALE */
+ hFrontVad->hNoiseEst->q_bckr = add( Q_bands, QSCALE );
move16();
noise_est_down_fx( fr_bands_fx[0], hFrontVad->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise_fx, Etot_fx[0], &hFrontVad->hNoiseEst->Etot_last_fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx, Q_bands, e_min_scaled );
- corr_shift_fx = correlation_shift_fx( hFrontVad->hNoiseEst->totalNoise_fx );
+ corr_shift_fx = correlation_shift_fx( hFrontVad->hNoiseEst->totalNoise_fx ); /* Q15 */
dtx_ivas_fx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 );
/* linear prediction analysis */
- alw_pitch_lag_12k8[0] = st->old_pitch_la;
- alw_pitch_lag_12k8[1] = st->old_pitch_la;
+ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */
+ alw_pitch_lag_12k8[1] = st->old_pitch_la; /* Q0 */
alw_voicing_fx[0] = st->voicing_fx[2];
alw_voicing_fx[1] = st->voicing_fx[2];
move16();
@@ -617,8 +684,8 @@ ivas_error front_vad_spar_fx(
Word16 Q_r[2] = { 0 };
move16();
move16();
- Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), hFrontVad->q_mem_decim ) );
- Scale_sig( inp_12k8_fx, 3 * L_FRAME / 2, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), Q_inp_12k8 ) );
+ Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), hFrontVad->q_mem_decim ) ); /* min( hFrontVad->q_mem_decim, hFrontVad->q_buffer_12k8 */
+ Scale_sig( inp_12k8_fx, 3 * L_FRAME / 2, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), Q_inp_12k8 ) ); /* min( hFrontVad->q_mem_decim, hFrontVad->q_buffer_12k8 */
Q_inp_12k8 = s_min( hFrontVad->q_mem_decim, hFrontVad->q_buffer_12k8 );
hFrontVad->q_mem_decim = Q_inp_12k8;
move16();
@@ -635,10 +702,10 @@ ivas_error front_vad_spar_fx(
relE_fx = sub( Etot_fx[0], st->lp_speech_fx );
Scale_sig( A_fx, ( L_FRAME / L_SUBFR ) * ( M + 1 ), -2 ); // Q12
- st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q );
+ st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); /* Q_inp_12k8 */
st->mem_wsp_q = Q_inp_12k8;
move16();
- ivas_find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
+ ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
IF( st->vad_flag == 0 )
{
@@ -648,19 +715,29 @@ ivas_error front_vad_spar_fx(
old_pitch = st->pitch[1];
move16();
- Scale_sig( wsp_fx, 368, sub( Q8, Q_inp_12k8 ) );
- pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR );
+ Scale_sig( wsp_fx, 368, sub( Q8, Q_inp_12k8 ) ); // Q8
+ pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q8 );
+
/* Updates for adaptive lag window memory */
- st->old_pitch_la = st->pitch[2];
+ st->old_pitch_la = st->pitch[2]; /* Q0 */
move16();
- Scale_sig( wsp_fx, 368, Q9 - Q8 );
+ Scale_sig( wsp_fx, 368, Q9 - Q8 ); /* Q9 */
StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q12, st->lgBin_E_fx );
IF( st->hSpMusClas != NULL )
{
Word16 dummy_int;
+ Word16 *cor_strong_limit;
dummy_int = 0;
move16();
- loc_harm = multi_harm_fx( st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, ( st->hGSCEnc != NULL ) ? &st->hGSCEnc->cor_strong_limit : &dummy_int, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx );
+ if ( st->hGSCEnc != NULL )
+ {
+ cor_strong_limit = &st->hGSCEnc->cor_strong_limit;
+ }
+ else
+ {
+ cor_strong_limit = &dummy_int;
+ }
+ loc_harm = multi_harm_fx( st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, cor_strong_limit, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx ); /* Q0 */
}
scale = getScaleFactor32( epsP_fx, M + 1 );
Q_esp = add( Q_r[0], scale );
@@ -671,7 +748,10 @@ ivas_error front_vad_spar_fx(
}
Q_bands = Q9;
move16();
- Scale_sig32( lf_E_fx[0], 148, ( Q_bands + QSCALE - 2 ) - ( Q_buffer + QSCALE ) );
+
+ Scale_sig32( lf_E_fx[0], 148, sub( add( Q_bands, QSCALE - 2 ), q_lf_E[0] ) ); // Q_bands+QSCALE-2
+ q_lf_E[0] = add( Q_bands, QSCALE - 2 );
+ move16();
noise_est_ivas_fx( st, old_pitch, tmpN_fx, epsP_h, epsP_l, Etot_fx[0], Etot_fx[0] - hFrontVad->lp_speech_fx, corr_shift_fx, tmpE_fx, fr_bands_fx[0], &cor_map_sum_fx, NULL, &sp_div_fx, &Q_sp_div, &non_staX_fx, &loc_harm, lf_E_fx[0], &hFrontVad->hNoiseEst->harm_cor_cnt, hFrontVad->hNoiseEst->Etot_l_lp_fx, hFrontVad->hNoiseEst->Etot_v_h2_fx, &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, Q_bands, e_min_scaled, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame );
MVR2R_WORD16( st->pitch, st->pitch, 3 );
@@ -683,7 +763,7 @@ ivas_error front_vad_spar_fx(
Word16 Etot_fx_0 = Etot_fx[0];
move16();
scale = getScaleFactor32( PS_fx, 128 );
- Word16 Qfact_PS = add( add( Q_buffer, QSCALE ), scale );
+ Qfact_PS = add( Qfact_PS, scale );
Scale_sig32( PS_fx, 128, scale );
ivas_smc_gmm_fx( st, NULL, localVAD_HE_SAD[0], Etot_fx_0, lsp_new_fx, cor_map_sum_fx, epsP_fx, PS_fx, non_sta_fx, relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, Q_esp, hSpMusClas->past_PS_Q );
@@ -691,10 +771,10 @@ ivas_error front_vad_spar_fx(
ivas_long_enr_fx( st, -1, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot_fx );
/* increase ini_frame counter */
- hFrontVad->ini_frame = min( add( hFrontVad->ini_frame, 1 ), MAX_FRAME_COUNTER );
- st->ini_frame = hFrontVad->ini_frame;
+ hFrontVad->ini_frame = s_min( add( hFrontVad->ini_frame, 1 ), MAX_FRAME_COUNTER ); /* Q0 */
+ st->ini_frame = hFrontVad->ini_frame; /* Q0 */
move16();
- hSpar->front_vad_flag = st->vad_flag;
+ hSpar->front_vad_flag = st->vad_flag; /* Q0 */
move16();
hSpar->front_vad_dtx_flag = 1;
move16();
diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c
index 83c6655f0af5d05ac822902bf30c0a85cd131046..d6a3597bd2d7c7d39407372215c3d01408ab3d2c 100644
--- a/lib_enc/ivas_init_enc.c
+++ b/lib_enc/ivas_init_enc.c
@@ -78,7 +78,7 @@ void ivas_write_format_fx(
ind = 4;
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
}
BREAK;
case MC_FORMAT:
@@ -89,26 +89,26 @@ void ivas_write_format_fx(
ind = 6;
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
BREAK;
case MASA_FORMAT:
ind = 7;
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
BREAK;
case MASA_ISM_FORMAT:
IF( st_ivas->ism_mode == ISM_MODE_NONE )
{
ind = 7; /* send MASA format */
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
}
ELSE
{
ind = 10;
move16();
- nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) );
+ nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) ); /* Q0 */
}
BREAK;
case SBA_ISM_FORMAT:
@@ -116,13 +116,13 @@ void ivas_write_format_fx(
{
ind = 6; /* send SBA format */
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
}
ELSE
{
ind = 11; /* 1011 */
move16();
- nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) );
+ nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) ); /* Q0 */
}
BREAK;
default:
@@ -150,7 +150,7 @@ void ivas_write_format_fx(
void ivas_write_format_sid_fx(
const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 element_mode, /* i : element bitrate */
+ const Word16 element_mode, /* i : element bitrate Q0*/
BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
)
{
@@ -234,78 +234,91 @@ Word16 getNumChanAnalysis_fx(
{
Word16 n;
- n = add( st_ivas->nSCE, CPE_CHANNELS * st_ivas->nCPE );
+ n = add( st_ivas->nSCE, CPE_CHANNELS * st_ivas->nCPE ); /* Q0 */
test();
test();
test();
test();
IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, SBA_FORMAT ) )
{
- n = imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) );
+ n = imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ); /* Q0 */
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) || EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) )
{
- n = st_ivas->hEncoderConfig->nchan_inp;
+ n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
{
- n = st_ivas->hEncoderConfig->nchan_inp;
+ n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- n = st_ivas->hEncoderConfig->nchan_inp;
+ n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
- n = st_ivas->hEncoderConfig->nchan_inp;
+ n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) )
{
- n = add( st_ivas->hEncoderConfig->nchan_ism, imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ) );
+ n = add( st_ivas->hEncoderConfig->nchan_ism, imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ) ); /* Q0 */
}
return n;
}
/*-------------------------------------------------------------------*
- * copy_encoder_config()
+ * copy_encoder_config_ivas_fx()
*
* Copy configuration structrue to the state structrure
*-------------------------------------------------------------------*/
-void copy_encoder_config(
- Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
- Encoder_State *st, /* o : encoder state structure */
- const int16_t flag_all /* i : flag 1==update all, 0=partial update*/
+void copy_encoder_config_ivas_fx(
+ Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
+ Encoder_State *st, /* o : encoder state structure */
+ const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/
)
{
- if ( flag_all )
+ IF( flag_all )
{
- st->input_Fs = st_ivas->hEncoderConfig->input_Fs;
+ st->input_Fs = st_ivas->hEncoderConfig->input_Fs; /* Q0 */
+ move32();
- st->last_codec_mode = st_ivas->last_codec_mode;
- st->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate;
+ st->last_codec_mode = st_ivas->last_codec_mode; /* Q0 */
+ move16();
+ st->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate; /* Q0 */
+ move32();
- st->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON;
+ st->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON; /* Q0 */
+ move16();
- st->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR;
+ st->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR; /* Q0 */
+ move16();
}
- st->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB;
- st->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR;
+ st->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB; /* Q0 */
+ st->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR; /* Q0 */
+ move16();
+ move16();
- st->codec_mode = st_ivas->codec_mode;
- st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth;
+ st->codec_mode = st_ivas->codec_mode; /* Q0 */
+ st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; /* Q0 */
+ move16();
+ move16();
- st->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON;
- st->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset;
- st->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator;
+ st->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON; /* Q0 */
+ st->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset; /* Q0 */
+ st->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator; /* Q0 */
+ move16();
+ move16();
+ move16();
- st->element_mode = st_ivas->hEncoderConfig->element_mode_init;
+ st->element_mode = st_ivas->hEncoderConfig->element_mode_init; /* Q0 */
+ move16();
return;
}
@@ -316,62 +329,62 @@ void copy_encoder_config(
*-------------------------------------------------------------------*/
void copy_encoder_config_fx(
- Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
- Encoder_State *st_fx, /* o : encoder state structure */
- const Word16 flag_all /* i : flag 1==update all, 0=partial update*/
+ Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
+ Encoder_State *st_fx, /* o : encoder state structure */
+ const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/
)
{
IF( flag_all )
{
- st_fx->input_Fs = st_ivas->hEncoderConfig->input_Fs;
+ st_fx->input_Fs = st_ivas->hEncoderConfig->input_Fs; /* Q0 */
move32();
- st_fx->last_codec_mode = st_ivas->last_codec_mode;
+ st_fx->last_codec_mode = st_ivas->last_codec_mode; /* Q0 */
move16();
- st_fx->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate;
+ st_fx->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate; /* Q0 */
move32();
- st_fx->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON;
+ st_fx->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON; /* Q0 */
move16();
- st_fx->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR;
+ st_fx->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR; /* Q0 */
move16();
}
- st_fx->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB;
+ st_fx->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB; /* Q0 */
move16();
- st_fx->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR;
+ st_fx->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR; /* Q0 */
move16();
- st_fx->codec_mode = st_ivas->codec_mode;
+ st_fx->codec_mode = st_ivas->codec_mode; /* Q0 */
move16();
- st_fx->max_bwidth = st_ivas->hEncoderConfig->max_bwidth;
+ st_fx->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; /* Q0 */
move16();
- st_fx->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON;
+ st_fx->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON; /* Q0 */
move16();
- st_fx->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset;
+ st_fx->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset; /* Q0 */
move16();
- st_fx->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator;
+ st_fx->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator; /* Q0 */
move16();
#ifdef DEBUGGING
st_fx->force = st_ivas->hEncoderConfig->force;
#endif
- st_fx->element_mode = st_ivas->hEncoderConfig->element_mode_init;
+ st_fx->element_mode = st_ivas->hEncoderConfig->element_mode_init; /* Q0 */
move16();
return;
}
/*-------------------------------------------------------------------------
- * ivas_initialize_handles_enc()
+ * ivas_initialize_handles_enc_fx()
*
* NULL initialization of handles
*-------------------------------------------------------------------------*/
-void ivas_initialize_handles_enc(
+void ivas_initialize_handles_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
@@ -453,12 +466,12 @@ ivas_error ivas_init_encoder(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
- int16_t i, n;
- int16_t nchan_inp_buff;
- int16_t sce_id, cpe_id;
+ Word16 i, n;
+ Word16 nchan_inp_buff;
+ Word16 sce_id, cpe_id;
IVAS_FORMAT ivas_format;
- int32_t input_Fs, ivas_total_brate;
- int32_t element_brate_tmp[MAX_NUM_OBJECTS];
+ Word32 input_Fs, ivas_total_brate;
+ Word32 element_brate_tmp[MAX_NUM_OBJECTS];
ENCODER_CONFIG_HANDLE hEncoderConfig;
ivas_error error;
@@ -466,38 +479,48 @@ ivas_error ivas_init_encoder(
hEncoderConfig = st_ivas->hEncoderConfig;
ivas_format = hEncoderConfig->ivas_format;
- input_Fs = hEncoderConfig->input_Fs;
- ivas_total_brate = hEncoderConfig->ivas_total_brate;
+ input_Fs = hEncoderConfig->input_Fs; /* Q0 */
+ ivas_total_brate = hEncoderConfig->ivas_total_brate; /* Q0 */
+ move32();
+ move32();
- hEncoderConfig->last_ivas_total_brate = ivas_total_brate;
+ hEncoderConfig->last_ivas_total_brate = ivas_total_brate; /* Q0 */
+ move32();
- if ( ivas_format != MONO_FORMAT )
+ if ( NE_32( ivas_format, MONO_FORMAT ) )
{
/* In IVAS, ensure that minimum coded bandwidth is WB */
- hEncoderConfig->max_bwidth = max( hEncoderConfig->max_bwidth, WB );
+ hEncoderConfig->max_bwidth = max( hEncoderConfig->max_bwidth, WB ); /* Q0 */
+ move16();
}
st_ivas->ism_mode = ISM_MODE_NONE;
st_ivas->mc_mode = MC_MODE_NONE;
+ move32();
+ move32();
st_ivas->nchan_transport = -1;
+ move16();
/*-----------------------------------------------------------------*
* Allocate floating-point input audio buffers
*-----------------------------------------------------------------*/
- nchan_inp_buff = hEncoderConfig->nchan_inp;
- if ( ivas_format == MONO_FORMAT )
+ nchan_inp_buff = hEncoderConfig->nchan_inp; /* Q0 */
+ move16();
+
+ IF( EQ_32( ivas_format, MONO_FORMAT ) )
{
nchan_inp_buff = 0;
+ move16();
}
- else if ( ivas_format == MASA_ISM_FORMAT )
+ ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
{
- if ( hEncoderConfig->nchan_inp - hEncoderConfig->nchan_ism == 1 ) /* mono is duplicated in monoMASA */
+ if ( EQ_32( sub( hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) ) /* mono is duplicated in monoMASA */
{
- nchan_inp_buff++;
+ nchan_inp_buff = add( nchan_inp_buff, 1 );
}
- nchan_inp_buff++; /* for *data_separated_object */
+ nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object */
}
FOR( n = 0; n < nchan_inp_buff; n++ )
@@ -507,7 +530,10 @@ ivas_error ivas_init_encoder(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) );
}
+ set32_fx( st_ivas->p_data_fx[n], 0, extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ) );
}
+ st_ivas->q_data_fx = Q11;
+ move16();
FOR( ; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
{
st_ivas->p_data_fx[n] = NULL;
@@ -517,10 +543,11 @@ ivas_error ivas_init_encoder(
*-----------------------------------------------------------------*/
/* set the maximum allowed number of indices in the list */
- st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate );
+ st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate ); /* Q0 */
+ move16();
/* allocate buffer of indices */
- if ( ( st_ivas->ind_list = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices * sizeof( Indice ) ) ) == NULL )
+ IF( ( st_ivas->ind_list = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices * sizeof( Indice ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) );
}
@@ -529,15 +556,17 @@ ivas_error ivas_init_encoder(
for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ )
{
st_ivas->ind_list[i].nb_bits = -1;
+ move16();
}
/* set the maximum allowed number of metadata indices in the list */
- st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate );
+ st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate ); /* Q0 */
+ move16();
/* allocate buffer of metadata indices */
- if ( st_ivas->ivas_max_num_indices_metadata > 0 )
+ IF( st_ivas->ivas_max_num_indices_metadata > 0 )
{
- if ( ( st_ivas->ind_list_metadata = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices_metadata * sizeof( Indice ) ) ) == NULL )
+ IF( ( st_ivas->ind_list_metadata = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices_metadata * sizeof( Indice ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of metadata indices!\n" ) );
}
@@ -546,9 +575,10 @@ ivas_error ivas_init_encoder(
for ( i = 0; i < st_ivas->ivas_max_num_indices_metadata; i++ )
{
st_ivas->ind_list_metadata[i].nb_bits = -1;
+ move16();
}
}
- else
+ ELSE
{
st_ivas->ind_list_metadata = NULL;
}
@@ -557,7 +587,7 @@ ivas_error ivas_init_encoder(
* Allocate and initialize SCE/CPE and other handles
*-----------------------------------------------------------------*/
- if ( ivas_format == MONO_FORMAT )
+ IF( EQ_32( ivas_format, MONO_FORMAT ) )
{
st_ivas->nSCE = 1; /* in mono, there is always only one SCE */
move16();
@@ -569,91 +599,92 @@ ivas_error ivas_init_encoder(
move16();
test();
- IF( NE_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) )
+ IF( st_ivas->hEncoderConfig->element_mode_init != EVS_MONO )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE
{
- IF( NE_32( ( error = create_evs_sce_enc( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_evs_sce_enc( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* prepare stereo downmix for EVS */
- if ( hEncoderConfig->stereo_dmx_evs == 1 )
+ IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) )
{
- if ( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ) != IVAS_ERR_OK )
+ IF( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else if ( ivas_format == STEREO_FORMAT )
+ ELSE IF( EQ_32( ivas_format, STEREO_FORMAT ) )
{
st_ivas->nSCE = 0;
st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */
st_ivas->nchan_transport = CPE_CHANNELS;
cpe_id = 0;
+ move16();
+ move16();
+ move16();
+ move16();
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
}
- else if ( ivas_format == ISM_FORMAT )
+ ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) )
{
st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate );
- if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
- for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- if ( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( st_ivas->ism_mode == ISM_MODE_PARAM )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- if ( ( error = ivas_param_ism_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_param_ism_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( st_ivas->hEncoderConfig->Opt_DTX_ON )
+ IF( st_ivas->hEncoderConfig->Opt_DTX_ON )
{
- if ( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else if ( ivas_format == SBA_FORMAT || ivas_format == MASA_FORMAT )
+ ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, MASA_FORMAT ) )
{
-#ifndef IVAS_FLOAT_FIXED
- if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
-#else
IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
- if ( ivas_format == SBA_FORMAT )
+ IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order );
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */
+ move16();
- if ( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -663,74 +694,82 @@ ivas_error ivas_init_encoder(
return error;
}
}
- else
+ ELSE
{
- st_ivas->nchan_transport = hEncoderConfig->nchan_inp;
+ st_ivas->nchan_transport = hEncoderConfig->nchan_inp; /* Q0 */
+ move16();
- if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ivas_format == SBA_FORMAT && st_ivas->hEncoderConfig->Opt_DTX_ON )
+ if ( EQ_32( ivas_format, SBA_FORMAT ) && st_ivas->hEncoderConfig->Opt_DTX_ON )
{
st_ivas->hSCE[sce_id]->hCoreCoder[0]->dtx_sce_sba = 1;
+ move16();
}
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
if ( hEncoderConfig->Opt_DTX_ON )
{
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1;
+ move16();
}
}
}
- if ( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else if ( ivas_format == MASA_ISM_FORMAT )
+ ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
{
- int32_t ism_total_brate;
- int16_t k;
+ Word32 ism_total_brate;
+ Word16 k;
- st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism );
+ st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); /* Q0 */
move32();
st_ivas->nchan_transport = 2;
+ move16();
- if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
k = 0;
- while ( k < SIZE_IVAS_BRATE_TBL && ivas_total_brate != ivas_brate_tbl[k] )
+ move16();
+ while ( k < SIZE_IVAS_BRATE_TBL && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) )
{
k++;
}
ism_total_brate = 0;
+ move32();
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
ism_total_brate = L_add( ism_total_brate, sep_object_brate[k - 2][st_ivas->nSCE - 1] );
@@ -740,68 +779,63 @@ ivas_error ivas_init_encoder(
}
}
-#ifndef IVAS_FLOAT_FIXED
- if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
-#else
IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
- if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC )
+ IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- if ( ( error = ivas_omasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_omasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ivas_total_brate - ism_total_brate >= MIN_BRATE_MDCT_STEREO )
+ if ( GE_32( L_sub( ivas_total_brate, ism_total_brate ), MIN_BRATE_MDCT_STEREO ) )
{
st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ move16();
}
else
{
st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_DFT;
+ move16();
}
- if ( ( error = create_cpe_enc_fx( st_ivas, 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK )
+ IF( ( error = create_cpe_enc_fx( st_ivas, 0, L_sub( ivas_total_brate, ism_total_brate ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- else if ( ivas_format == SBA_ISM_FORMAT )
+ ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
st_ivas->ism_mode = ISM_MODE_NONE;
- if ( ivas_total_brate >= IVAS_256k )
+ if ( GE_32( ivas_total_brate, IVAS_256k ) )
{
st_ivas->ism_mode = ISM_SBA_MODE_DISC;
}
- if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
/* allocate and initialize SBA handles */
-#ifndef IVAS_FLOAT_FIXED
- if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
-#else
IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order );
+ move16();
- if ( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -811,7 +845,7 @@ ivas_error ivas_init_encoder(
return error;
}
- if ( st_ivas->ism_mode == ISM_MODE_NONE )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) )
{
/* allocate and initialize SBA core-coders */
IF( EQ_16( st_ivas->nchan_transport, 1 ) )
@@ -822,151 +856,163 @@ ivas_error ivas_init_encoder(
}
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else
+ ELSE
{
/* allocate and initialize MCT core coder */
- st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
+ st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) );
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- else if ( ivas_format == MC_FORMAT )
+ ELSE IF( EQ_32( ivas_format, MC_FORMAT ) )
{
- st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate );
+ st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate ); /* Q0 */
- if ( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( st_ivas->mc_mode == MC_MODE_MCT )
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
{
st_ivas->nSCE = 0;
- st_ivas->nCPE = hEncoderConfig->nchan_inp / CPE_CHANNELS;
+ st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS ); /* Q0 */
+ move16();
+ move16();
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / ( hEncoderConfig->nchan_inp - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, sub( hEncoderConfig->nchan_inp, 1 ), &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
- st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup );
+ st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup ); /* Q0 */
+ move16();
}
- else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
{
st_ivas->nSCE = 0;
st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / 2;
st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
+ move16();
+ move16();
+ move16();
- if ( ( error = ivas_mc_paramupmix_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_mc_paramupmix_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, st_ivas->nCPE, &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
- else if ( st_ivas->mc_mode == MC_MODE_PARAMMC )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
- if ( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nCPE, st_ivas->nSCE ), &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
- int32_t brate_sce, brate_cpe;
+ Word32 brate_sce, brate_cpe;
ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( hEncoderConfig->element_mode_init ), ivas_total_brate );
-#ifndef IVAS_FLOAT_FIXED
- if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
-#else
IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
- if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -981,11 +1027,12 @@ ivas_error ivas_init_encoder(
}
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ move16();
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -998,7 +1045,8 @@ ivas_error ivas_init_encoder(
*-----------------------------------------------------------------*/
/* set number of input channels used for analysis/coding */
- n = getNumChanAnalysis_fx( st_ivas );
+ n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */
+ move16();
IF( n > 0 )
{
@@ -1042,18 +1090,18 @@ ivas_error ivas_init_encoder_fx(
hEncoderConfig = st_ivas->hEncoderConfig;
ivas_format = hEncoderConfig->ivas_format;
move32();
- input_Fs = hEncoderConfig->input_Fs;
+ input_Fs = hEncoderConfig->input_Fs; /* Q0 */
move32();
- ivas_total_brate = hEncoderConfig->ivas_total_brate;
+ ivas_total_brate = hEncoderConfig->ivas_total_brate; /* Q0 */
move32();
- hEncoderConfig->last_ivas_total_brate = ivas_total_brate;
+ hEncoderConfig->last_ivas_total_brate = ivas_total_brate; /* Q0 */
move32();
IF( NE_16( ivas_format, MONO_FORMAT ) )
{
/* In IVAS, ensure that minimum coded bandwidth is WB */
- hEncoderConfig->max_bwidth = extract_l( L_max( hEncoderConfig->max_bwidth, WB ) );
+ hEncoderConfig->max_bwidth = extract_l( L_max( hEncoderConfig->max_bwidth, WB ) ); /* Q0 */
move16();
}
st_ivas->ism_mode = ISM_MODE_NONE;
@@ -1068,7 +1116,7 @@ ivas_error ivas_init_encoder_fx(
* Allocate floating-point input audio buffers
*-----------------------------------------------------------------*/
- nchan_inp_buff = hEncoderConfig->nchan_inp;
+ nchan_inp_buff = hEncoderConfig->nchan_inp; /* Q0 */
move16();
IF( EQ_16( ivas_format, MONO_FORMAT ) )
{
@@ -1079,10 +1127,10 @@ ivas_error ivas_init_encoder_fx(
{
IF( EQ_16( sub( hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) ) /* mono is duplicated in monoMASA */
{
- nchan_inp_buff = add( nchan_inp_buff, 1 );
+ nchan_inp_buff = add( nchan_inp_buff, 1 ); /* Q0 */
}
- nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object */
+ nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object Q0*/
}
FOR( n = 0; n < nchan_inp_buff; n++ )
@@ -1104,7 +1152,7 @@ ivas_error ivas_init_encoder_fx(
*-----------------------------------------------------------------*/
/* set the maximum allowed number of indices in the list */
- st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate );
+ st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate ); /* Q0 */
move16();
/* allocate buffer of indices */
@@ -1121,7 +1169,7 @@ ivas_error ivas_init_encoder_fx(
}
/* set the maximum allowed number of metadata indices in the list */
- st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate );
+ st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate ); /* Q0 */
move16();
/* allocate buffer of metadata indices */
IF( st_ivas->ivas_max_num_indices_metadata > 0 )
@@ -1147,7 +1195,7 @@ ivas_error ivas_init_encoder_fx(
* Allocate and initialize SCE/CPE and other handles
*-----------------------------------------------------------------*/
test();
- IF( EQ_16( ivas_format, MONO_FORMAT ) )
+ IF( EQ_32( ivas_format, MONO_FORMAT ) )
{
st_ivas->nSCE = 1; /* in mono, there is always only one SCE */
move16();
@@ -1159,16 +1207,16 @@ ivas_error ivas_init_encoder_fx(
move16();
test();
- IF( EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) )
+ IF( st_ivas->hEncoderConfig->element_mode_init == EVS_MONO )
{
- IF( NE_32( ( error = create_evs_sce_enc( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_evs_sce_enc( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1177,13 +1225,13 @@ ivas_error ivas_init_encoder_fx(
/* prepare stereo downmix for EVS */
IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) )
{
- IF( NE_32( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- ELSE IF( ivas_format == STEREO_FORMAT )
+ ELSE IF( EQ_32( ivas_format, STEREO_FORMAT ) )
{
st_ivas->nSCE = 0;
move16();
@@ -1194,24 +1242,24 @@ ivas_error ivas_init_encoder_fx(
cpe_id = 0;
move16();
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) )
{
- st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate );
+ st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate ); /* Q0 */
move32();
- IF( NE_32( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1219,7 +1267,7 @@ ivas_error ivas_init_encoder_fx(
IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- IF( NE_32( ( error = ivas_param_ism_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_param_ism_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1227,7 +1275,7 @@ ivas_error ivas_init_encoder_fx(
IF( st_ivas->hEncoderConfig->Opt_DTX_ON )
{
- IF( NE_32( ( error = ivas_ism_dtx_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1235,31 +1283,31 @@ ivas_error ivas_init_encoder_fx(
}
ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, MASA_FORMAT ) )
{
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order );
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */
move16();
- IF( NE_32( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_dirac_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE
{
- st_ivas->nchan_transport = hEncoderConfig->nchan_inp;
+ st_ivas->nchan_transport = hEncoderConfig->nchan_inp; /* Q0 */
move16();
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1269,7 +1317,7 @@ ivas_error ivas_init_encoder_fx(
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, res_dec ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1285,7 +1333,7 @@ ivas_error ivas_init_encoder_fx(
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1302,7 +1350,7 @@ ivas_error ivas_init_encoder_fx(
IF( st_ivas->nCPE > 1 )
{
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1313,12 +1361,12 @@ ivas_error ivas_init_encoder_fx(
Word32 ism_total_brate;
Word16 k;
- st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism );
+ st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); /* Q0 */
move32();
st_ivas->nchan_transport = 2;
move16();
- IF( NE_32( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1328,32 +1376,32 @@ ivas_error ivas_init_encoder_fx(
test();
WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) )
{
- k = add( k, 1 );
+ k++;
}
ism_total_brate = 0;
move32();
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- ism_total_brate = L_add( ism_total_brate, sep_object_brate[k - 2][st_ivas->nSCE - 1] );
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, sep_object_brate[k - 2][st_ivas->nSCE - 1] ) ), IVAS_ERR_OK ) )
+ ism_total_brate = L_add( ism_total_brate, sep_object_brate[k - 2][st_ivas->nSCE - 1] ); /* Q0 */
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, sep_object_brate[k - 2][st_ivas->nSCE - 1] ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- IF( NE_32( ( error = ivas_omasa_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_omasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1370,7 +1418,7 @@ ivas_error ivas_init_encoder_fx(
move16();
}
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, 0, L_sub( ivas_total_brate, ism_total_brate ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, 0, L_sub( ivas_total_brate, ism_total_brate ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1386,25 +1434,25 @@ ivas_error ivas_init_encoder_fx(
move32();
}
- IF( NE_32( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
/* allocate and initialize SBA handles */
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
- st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order );
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */
- IF( NE_32( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_dirac_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1414,7 +1462,7 @@ ivas_error ivas_init_encoder_fx(
/* allocate and initialize SBA core-coders */
IF( EQ_16( st_ivas->nchan_transport, 1 ) )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, 0, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, 0, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1424,7 +1472,7 @@ ivas_error ivas_init_encoder_fx(
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1432,7 +1480,7 @@ ivas_error ivas_init_encoder_fx(
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1441,34 +1489,34 @@ ivas_error ivas_init_encoder_fx(
ELSE
{
/* allocate and initialize MCT core coder */
- st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) );
+ st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) ); /* Q0 */
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = ivas_osba_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_32( ivas_format, MC_FORMAT ) )
{
- st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate );
+ st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate ); /* Q0 */
move32();
- IF( NE_32( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1477,30 +1525,30 @@ ivas_error ivas_init_encoder_fx(
{
st_ivas->nSCE = 0;
move16();
- st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS );
+ st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS ); /* Q0 */
move16();
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, sub( hEncoderConfig->nchan_inp, 1 ), &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
- st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup );
+ st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup ); /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
@@ -1512,7 +1560,7 @@ ivas_error ivas_init_encoder_fx(
st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
move16();
- IF( NE_32( ( error = ivas_mc_paramupmix_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mc_paramupmix_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1521,32 +1569,32 @@ ivas_error ivas_init_encoder_fx(
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nCPE, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
- ELSE IF( st_ivas->mc_mode == MC_MODE_PARAMMC )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
- IF( NE_32( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1554,7 +1602,7 @@ ivas_error ivas_init_encoder_fx(
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1566,17 +1614,17 @@ ivas_error ivas_init_encoder_fx(
ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( hEncoderConfig->element_mode_init ), ivas_total_brate );
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1584,7 +1632,7 @@ ivas_error ivas_init_encoder_fx(
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_sce ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1592,10 +1640,10 @@ ivas_error ivas_init_encoder_fx(
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; /* Q0 */
move16();
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1945,16 +1993,17 @@ void destroy_evs_core_enc_fx(
/*-------------------------------------------------------------------------
- * ivas_destroy_enc()
+ * ivas_destroy_enc_fx()
*
* Close IVAS encoder handles
*-------------------------------------------------------------------------*/
-void ivas_destroy_enc(
+void ivas_destroy_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
- int16_t i, n, nchan_inp;
+ Word16 i, n, nchan_inp;
nchan_inp = st_ivas->hEncoderConfig->nchan_inp;
+ move16();
/* SCE handles */
for ( i = 0; i < MAX_SCE; i++ )
@@ -1979,7 +2028,7 @@ void ivas_destroy_enc(
/* HP20 filter handles */
if ( st_ivas->mem_hp20_in_fx != NULL )
{
- n = getNumChanAnalysis_fx( st_ivas );
+ n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */
for ( i = 0; i < n; i++ )
{
@@ -2007,25 +2056,25 @@ void ivas_destroy_enc(
ivas_dirac_enc_close_fx( &( st_ivas->hDirAC ), st_ivas->hEncoderConfig->input_Fs );
/* ParamISM handle */
- ivas_param_ism_enc_close( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_param_ism_enc_close_fx( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
/* SPAR handle */
ivas_spar_enc_close_fx( &( st_ivas->hSpar ), st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 );
/* MASA handle */
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
/* MCT handle */
- ivas_mct_enc_close( &( st_ivas->hMCT ) );
+ ivas_mct_enc_close_fx( &( st_ivas->hMCT ) );
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
/* LFE low pass filter state */
- ivas_lfe_lpf_enc_close( &( st_ivas->hLfeLpf ) );
+ ivas_lfe_lpf_enc_close_fx( &( st_ivas->hLfeLpf ) );
/* Param-Upmix MC handle */
- ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_mc_paramupmix_enc_close_fx( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
/* Parametric MC handle */
ivas_param_mc_enc_close_fx( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs );
@@ -2043,27 +2092,27 @@ void ivas_destroy_enc(
stereo_dmx_evs_close_encoder_fx( &( st_ivas->hStereoDmxEVS ) );
/* Encoder configuration handle */
- if ( st_ivas->hEncoderConfig != NULL )
+ IF( st_ivas->hEncoderConfig != NULL )
{
free( st_ivas->hEncoderConfig );
st_ivas->hEncoderConfig = NULL;
}
/* Buffer of indices */
- if ( st_ivas->ind_list != NULL )
+ IF( st_ivas->ind_list != NULL )
{
free( st_ivas->ind_list );
}
- if ( st_ivas->ind_list_metadata != NULL )
+ IF( st_ivas->ind_list_metadata != NULL )
{
free( st_ivas->ind_list_metadata );
}
/* floating-point input audio buffers */
- for ( n = 0; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
+ FOR( n = 0; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
{
- if ( st_ivas->p_data_fx[n] != NULL )
+ IF( st_ivas->p_data_fx[n] != NULL )
{
free( st_ivas->p_data_fx[n] );
st_ivas->p_data_fx[n] = NULL;
@@ -2077,12 +2126,12 @@ void ivas_destroy_enc(
}
/*-------------------------------------------------------------------------
- * ivas_initialize_MD_bstr_enc()
+ * ivas_initialize_MD_bstr_enc_fx()
*
* Allocate and initialize SCE/CPE MD bitstream handle
*-------------------------------------------------------------------------*/
-ivas_error ivas_initialize_MD_bstr_enc(
+ivas_error ivas_initialize_MD_bstr_enc_fx(
BSTR_ENC_HANDLE *hMetaData_out, /* o : encoder MD bitstream handle */
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
@@ -2097,7 +2146,7 @@ ivas_error ivas_initialize_MD_bstr_enc(
/* set pointer to the buffer of metadata indices */
hMetaData->ind_list = st_ivas->ind_list_metadata;
hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata;
- hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata;
+ hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata; /* Q0 */
hMetaData->st_ivas = st_ivas;
reset_indices_enc( hMetaData, st_ivas->ivas_max_num_indices_metadata );
@@ -2109,12 +2158,12 @@ ivas_error ivas_initialize_MD_bstr_enc(
/*-------------------------------------------------------------------------
- * ivas_destroy_MD_bstr_enc()
+ * ivas_destroy_MD_bstr_enc_fx()
*
* Destroy SCE/CPE MD bitstream handle
*-------------------------------------------------------------------------*/
-void ivas_destroy_MD_bstr_enc(
+void ivas_destroy_MD_bstr_enc_fx(
BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */
)
{
diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c
index 244734b996a5e8fe4a6ea7a4cbd23729b9b80501..68325273e092f1c9608c867abaef91c9e31f293c 100644
--- a/lib_enc/ivas_ism_dtx_enc.c
+++ b/lib_enc/ivas_ism_dtx_enc.c
@@ -108,13 +108,13 @@ ivas_error ivas_ism_dtx_open(
Word16 ivas_ism_dtx_enc_fx(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
- const Word32 ivas_total_brate, /* i : IVAS total bitrate */
- const Word16 nchan_ism, /* i : number of objects */
- const Word16 nchan_transport, /* i : number of transport channels */
- Word16 vad_flag[MAX_NUM_OBJECTS], /* i : VAD flag */
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/
+ const Word16 nchan_ism, /* i : number of objects Q0*/
+ const Word16 nchan_transport, /* i : number of transport channels Q0*/
+ Word16 vad_flag[MAX_NUM_OBJECTS], /* i : VAD flag Q0*/
ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
- Word16 md_diff_flag[], /* o : metadata differential flag */
- Word16 *sid_flag /* o : indication of SID frame */
+ Word16 md_diff_flag[], /* o : metadata differential flag Q0*/
+ Word16 *sid_flag /* o : indication of SID frame Q0*/
)
{
Word16 ch, dtx_flag;
@@ -139,7 +139,7 @@ Word16 ivas_ism_dtx_enc_fx(
move16();
FOR( ch = 0; ch < nchan_transport; ch++ )
{
- dtx_flag = s_and( dtx_flag, !vad_flag[ch] );
+ dtx_flag = s_and( dtx_flag, !vad_flag[ch] ); /* Q0 */
}
/* compute global ISM based on long-term background noise */
@@ -222,33 +222,33 @@ Word16 ivas_ism_dtx_enc_fx(
}
/* estimate SID metadata bit-budget */
- nBits = add( nBits, 1 ); /* number of objects */
- nBits = add( nBits, 1 ); /* SID metadata flag */
+ nBits = add( nBits, 1 ); /* number of objects Q0*/
+ nBits = add( nBits, 1 ); /* SID metadata flag Q0*/
IF( EQ_16( md_diff_flag[ch], 1 ) )
{
- nBits = add( nBits, nBits_azimuth );
- nBits = add( nBits, nBits_elevation );
+ nBits = add( nBits, nBits_azimuth ); /* Q0 */
+ nBits = add( nBits, nBits_elevation ); /* Q0 */
}
}
/* calculate maximum available MD bit-budget */
nBits_MD_max = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC;
move16();
- nBits_MD_max = sub( nBits_MD_max, SID_FORMAT_NBITS );
+ nBits_MD_max = sub( nBits_MD_max, SID_FORMAT_NBITS ); /* Q0 */
if ( GT_16( nchan_transport, 1 ) )
{
- nBits_MD_max = sub( nBits_MD_max, nBits_sce_id );
+ nBits_MD_max = sub( nBits_MD_max, nBits_sce_id ); /* Q0 */
}
FOR( ch = 0; ch < nchan_transport - 1; ch++ )
{
- nBits_MD_max = sub( nBits_MD_max, nBits_coh ); /* coherence */
+ nBits_MD_max = sub( nBits_MD_max, nBits_coh ); /* coherence Q0*/
}
if ( GT_16( nchan_ism, 3 ) )
{
- nBits_MD_max = sub( nBits_MD_max, 1 ); /* ism_mode flag */
+ nBits_MD_max = sub( nBits_MD_max, 1 ); /* ism_mode flag Q0*/
}
/* too many metadata bits -> switch to active coding */
@@ -308,12 +308,12 @@ Word16 ivas_ism_dtx_enc_fx(
}
/* * update the global SID counter */
- hISMDTX->cnt_SID_ISM = add( hISMDTX->cnt_SID_ISM, 1 );
+ hISMDTX->cnt_SID_ISM = add( hISMDTX->cnt_SID_ISM, 1 ); /* Q0 */
move16();
IF( GE_16( hISMDTX->cnt_SID_ISM, hSCE[0]->hCoreCoder[0]->hDtxEnc->max_SID ) )
{
/* adaptive SID update interval */
- hSCE[0]->hCoreCoder[0]->hDtxEnc->max_SID = hSCE[0]->hCoreCoder[0]->hDtxEnc->interval_SID;
+ hSCE[0]->hCoreCoder[0]->hDtxEnc->max_SID = hSCE[0]->hCoreCoder[0]->hDtxEnc->interval_SID; /* Q0 */
hISMDTX->cnt_SID_ISM = 0;
move16();
move16();
@@ -326,7 +326,7 @@ Word16 ivas_ism_dtx_enc_fx(
move32();
}
- IF( EQ_16( hISMDTX->cnt_SID_ISM, 0 ) )
+ IF( hISMDTX->cnt_SID_ISM == 0 )
{
hSCE[hISMDTX->sce_id_dtx]->hCoreCoder[0]->core_brate = SID_2k40;
*sid_flag = 1;
@@ -336,7 +336,7 @@ Word16 ivas_ism_dtx_enc_fx(
}
test();
- IF( EQ_16( dtx_flag, 1 ) && EQ_16( *sid_flag, 0 ) )
+ IF( EQ_16( dtx_flag, 1 ) && *sid_flag == 0 )
{
set16_fx( md_diff_flag, 0, nchan_transport );
}
@@ -352,8 +352,8 @@ Word16 ivas_ism_dtx_enc_fx(
void ivas_ism_get_sce_id_dtx_fx(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
- const Word16 nchan_transport, /* i : number of transport channels */
- const Word16 input_frame /* i : input frame length per channel */
+ const Word16 nchan_transport, /* i : number of transport channels Q0*/
+ const Word16 input_frame /* i : input frame length per channel Q0*/
)
{
Word32 tmp_energy[MAX_NUM_OBJECTS];
@@ -380,7 +380,7 @@ void ivas_ism_get_sce_id_dtx_fx(
{
FOR( i = 0; i < ( PARAM_ISM_HYS_BUF_SIZE - 1 ); i++ )
{
- hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i] = hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i + 1];
+ hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i] = hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i + 1]; /* exp(hISMDTX->long_term_energy_stereo_dmx_enc_e) */
move32();
}
long_term_energy_stereo_dmx_enc_e[j] = 20;
@@ -404,10 +404,10 @@ void ivas_ism_get_sce_id_dtx_fx(
{
FOR( i = 0; i < PARAM_ISM_HYS_BUF_SIZE - 1; i++ )
{
- hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i] = L_shr( hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i], max_exp - hISMDTX->long_term_energy_stereo_dmx_enc_e );
+ hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i] = L_shr( hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i], max_exp - hISMDTX->long_term_energy_stereo_dmx_enc_e ); /* exp(max_exp) */
move32();
}
- hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][PARAM_ISM_HYS_BUF_SIZE - 1] = L_shr( hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][PARAM_ISM_HYS_BUF_SIZE - 1], max_exp - long_term_energy_stereo_dmx_enc_e[j] );
+ hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][PARAM_ISM_HYS_BUF_SIZE - 1] = L_shr( hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][PARAM_ISM_HYS_BUF_SIZE - 1], max_exp - long_term_energy_stereo_dmx_enc_e[j] ); /* exp(max_exp) */
move32();
}
hISMDTX->long_term_energy_stereo_dmx_enc_e = max_exp;
@@ -433,10 +433,10 @@ void ivas_ism_get_sce_id_dtx_fx(
*
*-------------------------------------------------------------------*/
void ivas_ism_coh_estim_dtx_enc_fx(
- ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
- SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
- const Word16 nchan_transport, /* i : number of transport channels */
- const Word16 input_frame /* i : input frame length */
+ ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
+ SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
+ const Word16 nchan_transport, /* i : number of transport channels Q0*/
+ const Word16 input_frame /* i : input frame length Q0*/
)
{
Encoder_State *st, *st_id0;
@@ -465,7 +465,7 @@ void ivas_ism_coh_estim_dtx_enc_fx(
norm_inp = norm_l( st_id0->input32_fx[i] );
scaled_inp = L_shl( st_id0->input32_fx[i], norm_inp );
tot_exp = shl( sub( 20, norm_inp ), 1 );
- acorr_ene_fx[hISMDTX->sce_id_dtx] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[hISMDTX->sce_id_dtx], acorr_ene_e[hISMDTX->sce_id_dtx], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[hISMDTX->sce_id_dtx] );
+ acorr_ene_fx[hISMDTX->sce_id_dtx] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[hISMDTX->sce_id_dtx], acorr_ene_e[hISMDTX->sce_id_dtx], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[hISMDTX->sce_id_dtx] ); /* exp(acorr_ene_e) */
move32();
}
@@ -473,7 +473,7 @@ void ivas_ism_coh_estim_dtx_enc_fx(
{
IF( EQ_16( sce_id, hISMDTX->sce_id_dtx ) )
{
- hISMDTX->coh_fx[sce_id] = 32767;
+ hISMDTX->coh_fx[sce_id] = 32767; /* 1 in Q15 */
move16();
continue;
}
@@ -492,14 +492,14 @@ void ivas_ism_coh_estim_dtx_enc_fx(
norm_inp = norm_l( st->input32_fx[i] );
scaled_inp = L_shl( st->input32_fx[i], norm_inp );
tot_exp = shl( sub( 20, norm_inp ), 1 );
- acorr_ene_fx[sce_id] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[sce_id], acorr_ene_e[sce_id], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[sce_id] );
+ acorr_ene_fx[sce_id] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[sce_id], acorr_ene_e[sce_id], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[sce_id] ); /* exp(acorr_ene_e) */
move32();
- xcorr_ene_fx = BASOP_Util_Add_Mant32Exp( xcorr_ene_fx, xcorr_ene_e, Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &xcorr_ene_e );
+ xcorr_ene_fx = BASOP_Util_Add_Mant32Exp( xcorr_ene_fx, xcorr_ene_e, Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &xcorr_ene_e ); /* exp(xcorr_ene_e) */
}
Word16 coh_e;
Word16 temp_e = acorr_ene_e[hISMDTX->sce_id_dtx] + acorr_ene_e[sce_id];
Word32 temp = Sqrt32( L_add( Mult_32_32( acorr_ene_fx[hISMDTX->sce_id_dtx], acorr_ene_fx[sce_id] ), EPSILON_FX ), &temp_e ); /*fabsf( xcorr_ene ) / ( sqrtf( ( acorr_ene[hISMDTX->sce_id_dtx] * acorr_ene[sce_id] ) + EPSILON ) );*/
- hISMDTX->coh_fx[sce_id] = BASOP_Util_Divide3232_Scale( L_abs( xcorr_ene_fx ), temp, &coh_e );
+ hISMDTX->coh_fx[sce_id] = BASOP_Util_Divide3232_Scale( L_abs( xcorr_ene_fx ), temp, &coh_e ); /* coh_e + (xcorr_ene_e - temp_e) */
move16();
coh_e = add( coh_e, sub( xcorr_ene_e, temp_e ) );
IF( coh_e < 0 )
@@ -509,7 +509,7 @@ void ivas_ism_coh_estim_dtx_enc_fx(
coh_e = 0;
}
/* ensure value of coherence is between [0,1] */
- hISMDTX->coh_fx[sce_id] = check_bounds_s( hISMDTX->coh_fx[sce_id], 0, shl_sat( 1, 15 - coh_e ) );
+ hISMDTX->coh_fx[sce_id] = check_bounds_s_fx( hISMDTX->coh_fx[sce_id], 0, shl_sat( 1, 15 - coh_e ) ); /* Q0 */
hISMDTX->coh_fx[sce_id] = shl_sat( hISMDTX->coh_fx[sce_id], coh_e );
move16();
move16();
diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c
index b39a26f28bad07cea595c6fe8c04a364156660b4..6f8fb2b9f8b544950c3e55e3a7fc7d2c62e4a0bc 100644
--- a/lib_enc/ivas_ism_enc.c
+++ b/lib_enc/ivas_ism_enc.c
@@ -51,21 +51,22 @@
* ISM CoreCoders encoding routine
*-------------------------------------------------------------------*/
ivas_error ivas_ism_enc_fx(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- Word32 *data[], /* i : input signal [channels][samples] Q(q_data) */
- Word16 q_data, /* i : Q-factor of input signal */
- const Word16 input_frame, /* i : input frame length per channel */
- Word16 *nb_bits_metadata, /* i : number of metadata bits */
- const Word16 flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ Word32 *data[], /* i : input signal [channels][samples] Q(q_data)*/
+ Word16 q_data, /* i : Q-factor of input signal */
+ const Word16 input_frame, /* i : input frame length per channel Q0*/
+ Word16 *nb_bits_metadata, /* i : number of metadata bits Q0*/
+ const Word16 flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag Q0*/
)
{
SCE_ENC_HANDLE hSCE;
Encoder_State *st;
Word16 sce_id;
- Word16 old_inp_12k8_fx[MAX_NUM_OBJECTS][1][L_INP_12k8]; /* buffer of input signal @ 12k8 Q-1 */
- Word16 old_inp_16k_fx[MAX_NUM_OBJECTS][1][L_INP]; /* buffer of input signal @ 12k8 Q-1 */
- Word16 vad_flag[MAX_NUM_OBJECTS]; /* VAD flag */
- Word32 ener_fx[MAX_NUM_OBJECTS][1]; /* residual energy from Levinson-Durbin Q6 */
+ Word16 old_inp_12k8_fx[MAX_NUM_OBJECTS][1][L_INP_12k8]; /* buffer of input signal @ 12k8 Q_new-1 */
+ Word16 old_inp_16k_fx[MAX_NUM_OBJECTS][1][L_INP]; /* buffer of input signal @ 12k8 Q_new-1 */
+ Word16 Q_new[MAX_NUM_OBJECTS][1] = { 0 };
+ Word16 vad_flag[MAX_NUM_OBJECTS]; /* VAD flag */
+ Word32 ener_fx[MAX_NUM_OBJECTS][1]; /* residual energy from Levinson-Durbin Q6 */
Word16 relE_fx[MAX_NUM_OBJECTS][1];
/* frame relative energy, Q8 */
Word16 A_fx[MAX_NUM_OBJECTS][1][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* A(z) unquantized for subframes */
@@ -103,6 +104,10 @@ ivas_error ivas_ism_enc_fx(
Word16 i, nchan_transport_ism;
Word16 q_st_inp_16;
ivas_error error;
+ move16(); // Q_new
+ move16(); // Q_new
+ move16(); // Q_new
+ move16(); // Q_new
push_wmops( "ivas_ism_enc" );
@@ -133,7 +138,7 @@ ivas_error ivas_ism_enc_fx(
move16();
set16_fx( md_diff_flag, 1, nchan_ism );
- nchan_transport_ism = st_ivas->nchan_transport;
+ nchan_transport_ism = st_ivas->nchan_transport; /* Q0 */
move16();
IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
{
@@ -144,7 +149,7 @@ ivas_error ivas_ism_enc_fx(
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- nchan_transport_ism = st_ivas->hEncoderConfig->nchan_ism;
+ nchan_transport_ism = st_ivas->hEncoderConfig->nchan_ism; /* Q0 */
move16();
}
FOR( sce_id = 0; sce_id < nchan_transport_ism; sce_id++ )
@@ -232,11 +237,11 @@ ivas_error ivas_ism_enc_fx(
q_old_wsp = Q15;
move16();
-
+ Word16 q_fr_bands[2];
error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0],
&ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0],
realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0],
- fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, 31, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate
+ fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0]
#ifdef DEBUG_MODE_INFO
,
st->id_element
@@ -244,7 +249,7 @@ ivas_error ivas_ism_enc_fx(
);
e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp );
move16();
- IF( NE_32( error, IVAS_ERR_OK ) )
+ IF( error != IVAS_ERR_OK )
{
return error;
}
@@ -256,7 +261,7 @@ ivas_error ivas_ism_enc_fx(
}
ELSE
{
- vad_flag[sce_id] = st->vad_flag;
+ vad_flag[sce_id] = st->vad_flag; /* Q0 */
move16();
}
}
@@ -271,7 +276,7 @@ ivas_error ivas_ism_enc_fx(
test();
IF( st_ivas->hSCE[j] && st_ivas->hSCE[j]->hCoreCoder[0] )
{
- Copy_Scale_sig_16_32( st_ivas->hSCE[j]->hCoreCoder[0]->input_fx, st_ivas->hSCE[j]->hCoreCoder[0]->input32_fx, input_frame, sub( Q11, st_ivas->hSCE[j]->hCoreCoder[0]->q_inp ) );
+ Copy_Scale_sig_16_32( st_ivas->hSCE[j]->hCoreCoder[0]->input_fx, st_ivas->hSCE[j]->hCoreCoder[0]->input32_fx, input_frame, sub( Q11, st_ivas->hSCE[j]->hCoreCoder[0]->q_inp ) ); /* Q11 */
st_ivas->hSCE[j]->hCoreCoder[0]->q_inp32 = Q11;
move16();
}
@@ -281,7 +286,7 @@ ivas_error ivas_ism_enc_fx(
{
ivas_ism_get_sce_id_dtx_fx( st_ivas->hISMDTX, st_ivas->hSCE, st_ivas->nchan_transport, input_frame );
- dtx_flag = ivas_ism_dtx_enc_fx( st_ivas->hISMDTX, st_ivas->hSCE, st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, vad_flag, st_ivas->hIsmMetaData, md_diff_flag, &sid_flag );
+ dtx_flag = ivas_ism_dtx_enc_fx( st_ivas->hISMDTX, st_ivas->hSCE, st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, vad_flag, st_ivas->hIsmMetaData, md_diff_flag, &sid_flag ); /* Q0 */
IF( sid_flag )
{
@@ -295,20 +300,20 @@ ivas_error ivas_ism_enc_fx(
* Metadata quantization and encoding
*-----------------------------------------------------------------*/
- IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- ivas_param_ism_compute_noisy_speech_flag( st_ivas );
- flag_noisy_speech = st_ivas->hParamIsm->flag_noisy_speech;
+ ivas_param_ism_compute_noisy_speech_flag_fx( st_ivas );
+ flag_noisy_speech = st_ivas->hParamIsm->flag_noisy_speech; // Q0
move16();
}
IF( dtx_flag )
{
- ivas_ism_metadata_sid_enc( st_ivas->hISMDTX, flag_noisy_speech, nchan_ism, st_ivas->nchan_transport, st_ivas->ism_mode, st_ivas->hIsmMetaData, sid_flag, md_diff_flag, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata );
+ ivas_ism_metadata_sid_enc_fx( st_ivas->hISMDTX, flag_noisy_speech, nchan_ism, st_ivas->nchan_transport, st_ivas->ism_mode, st_ivas->hIsmMetaData, sid_flag, md_diff_flag, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata );
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- IF( NE_32( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_fx( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -322,28 +327,49 @@ ivas_error ivas_ism_enc_fx(
move16();
FOR( i = 0; i < st_ivas->nSCE; i++ )
{
- ism_total_brate = L_add( ism_total_brate, st_ivas->hSCE[i]->element_brate );
+ ism_total_brate = L_add( ism_total_brate, st_ivas->hSCE[i]->element_brate ); /* Q0 */
}
}
ELSE
{
- ism_total_brate = st_ivas->hEncoderConfig->ivas_total_brate;
+ ism_total_brate = st_ivas->hEncoderConfig->ivas_total_brate; /* Q0 */
move32();
}
- ism_total_brate_ref = ism_total_brate;
+ ism_total_brate_ref = ism_total_brate; /* Q0 */
move32();
- IF( NE_32( ( error = ivas_ism_metadata_enc( &ism_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
- nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, st_ivas->hMasa != NULL ? st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx : 0, flag_omasa_ener_brate, st_ivas->hMasa != NULL ? &( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt ) : NULL, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ),
- IVAS_ERR_OK ) )
+ Word16 lp_noise_CPE_fx;
+ if ( st_ivas->hMasa != NULL )
+ {
+ lp_noise_CPE_fx = st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx;
+ move16();
+ }
+ else
+ {
+ lp_noise_CPE_fx = 0;
+ move16();
+ }
+
+ Word16 *omasa_stereo_sw_cnt;
+ if ( st_ivas->hMasa != NULL )
+ {
+ omasa_stereo_sw_cnt = &( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt );
+ }
+ else
+ {
+ omasa_stereo_sw_cnt = NULL;
+ }
+ IF( ( error = ivas_ism_metadata_enc_fx( &ism_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
+ nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, lp_noise_CPE_fx, flag_omasa_ener_brate, omasa_stereo_sw_cnt, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ) !=
+ IVAS_ERR_OK )
{
return error;
}
IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
- st_ivas->hCPE[0]->brate_surplus = L_sub( ism_total_brate_ref, ism_total_brate );
+ st_ivas->hCPE[0]->brate_surplus = L_sub( ism_total_brate_ref, ism_total_brate ); /* Q0 */
move32();
}
}
@@ -398,7 +424,7 @@ ivas_error ivas_ism_enc_fx(
{
Word16 igf;
igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->max_bwidth, st->rf_mode );
- IF( NE_32( ( error = IGF_Reconfig_fx( &st->hIGFEnc, igf, 0, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->max_bwidth, st->element_mode, st->rf_mode ) ), IVAS_ERR_OK ) )
+ IF( ( error = IGF_Reconfig_fx( &st->hIGFEnc, igf, 0, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->max_bwidth, st->element_mode, st->rf_mode ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -418,7 +444,7 @@ ivas_error ivas_ism_enc_fx(
}
ELSE
{
- st->flag_ACELP16k = set_ACELP_flag_IVAS( IVAS_SCE, hSCE->element_brate, st->total_brate, 0, 0, -1, -1 );
+ st->flag_ACELP16k = set_ACELP_flag_IVAS( IVAS_SCE, hSCE->element_brate, st->total_brate, 0, 0, -1, -1 ); /* Q0 */
move16();
}
@@ -432,10 +458,10 @@ ivas_error ivas_ism_enc_fx(
test();
IF( !dtx_flag || ( dtx_flag && EQ_16( sce_id, st_ivas->hISMDTX->sce_id_dtx ) ) )
{
- Scale_sig( old_wsp_fx[sce_id][0], L_WSP, sub( e_old_wsp[sce_id][0], Q16 ) );
+ Scale_sig( old_wsp_fx[sce_id][0], L_WSP, sub( e_old_wsp[sce_id][0], Q16 ) ); /* exp(16) */
e_old_wsp[sce_id][0] = 16;
move16();
- IF( NE_32( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8_fx[sce_id], old_inp_16k_fx[sce_id], ener_fx[sce_id], A_fx[sce_id], Aw_fx[sce_id], epsP_fx[sce_id], epsP_fx_q[sce_id], lsp_new_fx[sce_id], lsp_mid_fx[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer_fx[sce_id], imagBuffer_fx[sce_id], &q_re_im_buf[sce_id], old_wsp_fx[sce_id], e_old_wsp[sce_id], loc_harm[sce_id], cor_map_sum_fx[sce_id], vad_flag_dtx[sce_id], enerBuffer_fx[sce_id], enerBuffer_fx_exp[sce_id], fft_buff_fx[sce_id], 0, ISM_FORMAT, 0 ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_core_enc_fx( hSCE, NULL, NULL, 1, old_inp_12k8_fx[sce_id], old_inp_16k_fx[sce_id], Q_new[sce_id], ener_fx[sce_id], A_fx[sce_id], Aw_fx[sce_id], epsP_fx[sce_id], epsP_fx_q[sce_id], lsp_new_fx[sce_id], lsp_mid_fx[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer_fx[sce_id], imagBuffer_fx[sce_id], &q_re_im_buf[sce_id], old_wsp_fx[sce_id], e_old_wsp[sce_id], loc_harm[sce_id], cor_map_sum_fx[sce_id], vad_flag_dtx[sce_id], enerBuffer_fx[sce_id], enerBuffer_fx_exp[sce_id], fft_buff_fx[sce_id], 0, ISM_FORMAT, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -447,15 +473,15 @@ ivas_error ivas_ism_enc_fx(
/* update input samples buffer */
- Copy( st->input_fx, st->old_input_signal_fx, input_frame );
+ Copy( st->input_fx, st->old_input_signal_fx, input_frame ); /* st->q_inp */
st->q_old_inp = st->q_inp;
move16();
- hSCE->last_element_brate = hSCE->element_brate;
+ hSCE->last_element_brate = hSCE->element_brate; /* Q0 */
move32();
/* Store previous attack detection flag */
- st->hTranDet->transientDetector.prev_bIsAttackPresent = st->hTranDet->transientDetector.bIsAttackPresent;
+ st->hTranDet->transientDetector.prev_bIsAttackPresent = st->hTranDet->transientDetector.bIsAttackPresent; /* Q0 */
move16();
prev_st = st;
@@ -467,9 +493,9 @@ ivas_error ivas_ism_enc_fx(
{
IF( NE_16( sce_id, st_ivas->hISMDTX->sce_id_dtx ) )
{
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_core = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->last_core;
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_core_brate = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->core_brate;
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_L_frame = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->last_L_frame;
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_core = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->last_core; /* Q0 */
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_core_brate = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->core_brate; /* Q0 */
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_L_frame = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->last_L_frame; /* Q0 */
move16();
move32();
move16();
@@ -504,7 +530,7 @@ ivas_error ivas_ism_enc_config(
move16();
/* select ISM format mode */
- st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->hEncoderConfig->nchan_inp, st_ivas->hEncoderConfig->ivas_total_brate );
+ st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->hEncoderConfig->nchan_inp, st_ivas->hEncoderConfig->ivas_total_brate ); /* Q0 */
move16();
/* ISM bit-rate switching */
@@ -513,7 +539,7 @@ ivas_error ivas_ism_enc_config(
{
Word32 element_brate_tmp[MAX_NUM_OBJECTS];
- nchan_transport_old = st_ivas->nchan_transport;
+ nchan_transport_old = st_ivas->nchan_transport; /* Q0 */
move16();
/* Reset and Initialize */
@@ -523,25 +549,25 @@ ivas_error ivas_ism_enc_config(
}
ELSE
{
- st_ivas->nchan_transport = st_ivas->hEncoderConfig->nchan_inp;
+ st_ivas->nchan_transport = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
}
move16();
- nCPE_old = st_ivas->nCPE;
+ nCPE_old = st_ivas->nCPE; /* Q0 */
move16();
- nSCE_old = st_ivas->nSCE;
+ nSCE_old = st_ivas->nSCE; /* Q0 */
move16();
- st_ivas->nSCE = st_ivas->nchan_transport;
+ st_ivas->nSCE = st_ivas->nchan_transport; /* Q0 */
move16();
st_ivas->nCPE = 0;
move16();
- IF( NE_32( ( error = ivas_ism_config_fx( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_config_fx( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_corecoder_enc_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport, imult3216( ( st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport ), CPE_CHANNELS ), MC_MODE_NONE ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_corecoder_enc_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport, imult3216( ( st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport ), CPE_CHANNELS ), MC_MODE_NONE ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -550,7 +576,7 @@ ivas_error ivas_ism_enc_config(
IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) && EQ_16( last_ism_mode, ISM_MODE_DISC ) )
{
/* Allocate and Initialize the memory used by ParamISM when switch from Discrete ISM */
- IF( NE_32( ( error = ivas_param_ism_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_param_ism_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -560,7 +586,7 @@ ivas_error ivas_ism_enc_config(
IF( EQ_16( st_ivas->ism_mode, ISM_MODE_DISC ) && EQ_16( last_ism_mode, ISM_MODE_PARAM ) )
{
/* Deallocate the memory used by ParamISM when switch to Discrete ISM */
- ivas_param_ism_enc_close( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_param_ism_enc_close_fx( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
}
}
diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c
index ffd0e1b1d456362d6500b9e23f4f0607d8fb0135..9bcc34dd8003099485b07e246bc3a98006ec4ce5 100644
--- a/lib_enc/ivas_ism_metadata_enc.c
+++ b/lib_enc/ivas_ism_metadata_enc.c
@@ -72,9 +72,9 @@
* Local function declarations
*-----------------------------------------------------------------------*/
-static void encode_angle_indices( BSTR_ENC_HANDLE hBstr, ISM_METADATA_ANGLE_HANDLE angle, const int16_t last_ism_metadata_flag, const int16_t ini_frame, const int16_t idx_angle1_abs, const int16_t idx_angle2_abs, int16_t *flag_abs_angle1, int16_t *flag_abs_angle2 );
+static void encode_angle_indices_fx( BSTR_ENC_HANDLE hBstr, ISM_METADATA_ANGLE_HANDLE angle, const Word16 last_ism_metadata_flag, const Word16 ini_frame, const Word16 idx_angle1_abs, const Word16 idx_angle2_abs, Word16 *flag_abs_angle1, Word16 *flag_abs_angle2 );
-static void encode_radius( BSTR_ENC_HANDLE hBstr, int16_t *last_radius_idx, int16_t *radius_diff_cnt, const int16_t last_ism_metadata_flag, const int16_t idx_radius_abs, int16_t *flag_abs_radius );
+static void encode_radius_fx( BSTR_ENC_HANDLE hBstr, Word16 *last_radius_idx, Word16 *radius_diff_cnt, const Word16 last_ism_metadata_flag, const Word16 idx_radius_abs, Word16 *flag_abs_radius );
/*-------------------------------------------------------------------------*
@@ -102,15 +102,15 @@ ivas_error ivas_set_ism_metadata_fx(
move16();
/* save read metadata parameters to the internal codec structure */
- hIsmMeta->azimuth_fx = azimuth;
+ hIsmMeta->azimuth_fx = azimuth; // Q22
move32();
- hIsmMeta->elevation_fx = elevation;
+ hIsmMeta->elevation_fx = elevation; // Q22
move32();
- hIsmMeta->radius_fx = radius_meta;
+ hIsmMeta->radius_fx = radius_meta; // Q9
move16();
- hIsmMeta->yaw_fx = yaw;
+ hIsmMeta->yaw_fx = yaw; // Q22
move16();
- hIsmMeta->pitch_fx = pitch;
+ hIsmMeta->pitch_fx = pitch; // Q22
move16();
hIsmMeta->non_diegetic_flag = non_diegetic_flag;
move16();
@@ -124,7 +124,7 @@ ivas_error ivas_set_ism_metadata_fx(
* Rate importance of particular ISM streams
*-------------------------------------------------------------------------*/
-static void rate_ism_importance(
+static void rate_ism_importance_fx(
const Word16 nchan_transport, /* i : number of transported channels */
ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */
@@ -187,7 +187,7 @@ static void rate_ism_importance(
* quantize and encode ISM metadata
*-------------------------------------------------------------------------*/
-ivas_error ivas_ism_metadata_enc(
+ivas_error ivas_ism_metadata_enc_fx(
Word32 *ism_total_brate, /* i/o: ISM total bitrate */
const Word16 nchan_ism, /* i : number of ISM channels */
const Word16 nchan_transport, /* i : number of transport channels */
@@ -334,7 +334,7 @@ ivas_error ivas_ism_metadata_enc(
IF( NE_16( ism_mode, ISM_SBA_MODE_DISC ) )
{
- rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp );
+ rate_ism_importance_fx( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp );
}
}
@@ -475,18 +475,18 @@ ivas_error ivas_ism_metadata_enc(
/* Map azimuth to panning range [-90:90] */
IF( GT_32( hIsmMetaData->azimuth_fx, 377487360 /*90.0f Q22*/ ) )
{
- hIsmMetaData->azimuth_fx = L_sub( 754974720 /*180.0f Q22*/, hIsmMetaData->azimuth_fx );
+ hIsmMetaData->azimuth_fx = L_sub( 754974720 /*180.0f Q22*/, hIsmMetaData->azimuth_fx ); // Q22
move32();
}
IF( LT_32( hIsmMetaData->azimuth_fx, L_negate( 377487360 ) /*-90.0f Q22*/ ) )
{
- hIsmMetaData->azimuth_fx = L_sub( L_negate( 754974720 ) /*-180.0f Q22*/, hIsmMetaData->azimuth_fx );
+ hIsmMetaData->azimuth_fx = L_sub( L_negate( 754974720 ) /*-180.0f Q22*/, hIsmMetaData->azimuth_fx ); // Q22
move32();
}
idx_angle1_abs = ism_quant_meta_fx( hIsmMetaData->azimuth_fx, &valQ_fx, ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_AZIMUTH_NBITS );
- encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, 0, &flag_abs_azimuth[ch], NULL );
+ encode_angle_indices_fx( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, 0, &flag_abs_azimuth[ch], NULL );
}
ELSE
{
@@ -506,7 +506,7 @@ ivas_error ivas_ism_metadata_enc(
idx_angle2_abs = hParamIsm->ele_index[ch];
move16();
}
- encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] );
+ encode_angle_indices_fx( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] );
/*----------------------------------------------------------------*
* Quantize and encode radius, yaw, and pitch
*----------------------------------------------------------------*/
@@ -520,8 +520,8 @@ ivas_error ivas_ism_metadata_enc(
idx_radius_abs = usquant_fx( hIsmMetaData->radius_fx, &valQ_fx_tmp, ISM_RADIUS_MIN_Q9, ISM_RADIUS_DELTA_Q8, 1 << ISM_RADIUS_NBITS );
valQ_fx = L_shr( L_deposit_h( valQ_fx_tmp ), 3 ); // Q22
// valQ = fixedToFloat( valQ_fx, Q22 );
- encode_angle_indices( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] );
- encode_radius( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] );
+ encode_angle_indices_fx( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] );
+ encode_radius_fx( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] );
}
}
@@ -536,11 +536,11 @@ ivas_error ivas_ism_metadata_enc(
}
/* Updates */
- hIsmMeta[ch]->last_true_azimuth_fx = hIsmMeta[ch]->azimuth_fx;
+ hIsmMeta[ch]->last_true_azimuth_fx = hIsmMeta[ch]->azimuth_fx; // Q22
move32();
- hIsmMeta[ch]->last_true_elevation_fx = hIsmMeta[ch]->elevation_fx;
+ hIsmMeta[ch]->last_true_elevation_fx = hIsmMeta[ch]->elevation_fx; // Q22
move32();
- hIsmMeta[ch]->last_true_radius_fx = hIsmMeta[ch]->radius_fx;
+ hIsmMeta[ch]->last_true_radius_fx = hIsmMeta[ch]->radius_fx; // Q22
move16();
}
}
@@ -553,7 +553,7 @@ ivas_error ivas_ism_metadata_enc(
i = 0;
move16();
test();
- WHILE( i == 0 || i < idiv1616( nchan_ism, INTER_OBJECT_PARAM_CHECK ) )
+ WHILE( i == 0 || i < ( nchan_ism / INTER_OBJECT_PARAM_CHECK ) )
{
Word16 num, abs_num, abs_first, abs_next, pos_zero;
Word16 abs_matrice[INTER_OBJECT_PARAM_CHECK * ISM_NUM_PARAM];
@@ -581,7 +581,7 @@ ivas_error ivas_ism_metadata_enc(
abs_first = 0;
move16();
- WHILE( GT_16( abs_num, 1 ) )
+ WHILE( abs_num > 1 )
{
/* find first "1" entry */
WHILE( abs_matrice[abs_first] == 0 )
@@ -599,7 +599,7 @@ ivas_error ivas_ism_metadata_enc(
/* find "0" position */
pos_zero = 0;
move16();
- WHILE( EQ_16( abs_matrice[pos_zero], 1 ) )
+ WHILE( abs_matrice[pos_zero] == 1 )
{
pos_zero = add( pos_zero, 1 );
}
@@ -612,7 +612,7 @@ ivas_error ivas_ism_metadata_enc(
move16();
}
- IF( abs_next % ISM_NUM_PARAM == 1 )
+ IF( EQ_16( abs_next % ISM_NUM_PARAM, 1 ) )
{
hIsmMeta[ch]->position_angle.angle2_diff_cnt = sub( abs_num, 1 );
move16();
@@ -869,7 +869,7 @@ ivas_error ivas_ism_metadata_enc(
* Create, allocate, initialize and configure IVAS encoder ISM metadata handles
*-------------------------------------------------------------------------*/
-ivas_error ivas_ism_metadata_enc_create(
+ivas_error ivas_ism_metadata_enc_create_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const Word16 n_ISms, /* i : number of objects */
Word32 element_brate_tmp[] /* o : element bitrate per object */
@@ -976,21 +976,21 @@ ivas_error ivas_ism_metadata_enc_create(
ivas_ism_reset_metadata_enc( st_ivas->hIsmMetaData[ch] );
- st_ivas->hIsmMetaData[ch]->last_azimuth_fx = 0;
+ st_ivas->hIsmMetaData[ch]->last_azimuth_fx = 0; // Q22
move32();
- st_ivas->hIsmMetaData[ch]->last_elevation_fx = 0;
+ st_ivas->hIsmMetaData[ch]->last_elevation_fx = 0; // Q22
move32();
- st_ivas->hIsmMetaData[ch]->last_true_azimuth_fx = 0;
+ st_ivas->hIsmMetaData[ch]->last_true_azimuth_fx = 0; // Q22
move32();
- st_ivas->hIsmMetaData[ch]->last_true_elevation_fx = 0;
+ st_ivas->hIsmMetaData[ch]->last_true_elevation_fx = 0; // Q22
move32();
st_ivas->hIsmMetaData[ch]->ism_md_fec_cnt_enc = 0;
move16();
st_ivas->hIsmMetaData[ch]->ism_md_inc_diff_cnt = ISM_MD_INC_DIFF_CNT_MAX;
move16();
- st_ivas->hIsmMetaData[ch]->last_true_radius_fx = ONE_IN_Q9;
+ st_ivas->hIsmMetaData[ch]->last_true_radius_fx = ONE_IN_Q9; // Q9
move16();
}
@@ -1028,7 +1028,7 @@ ivas_error ivas_ism_metadata_enc_create(
*
* Radius index encoding
*-------------------------------------------------------------------------*/
-static void encode_radius(
+static void encode_radius_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
Word16 *last_radius_idx, /* i/o: last radius index */
Word16 *radius_diff_cnt, /* i/o: radius diff coding counter */
@@ -1143,7 +1143,7 @@ static void encode_radius(
* Encoding of an angle
*----------------------------------------------------------------*/
-static void encode_angle_indices(
+static void encode_angle_indices_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */
const Word16 last_ism_metadata_flag, /* i : last frame ism_metadata_flag */
@@ -1168,8 +1168,8 @@ static void encode_angle_indices(
move16();
*flag_abs_angle1 = 0; /* differential coding by default */
test();
- if ( EQ_16( angle->angle1_diff_cnt, ISM_FEC_MAX ) /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */
- || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */
+ IF( EQ_16( angle->angle1_diff_cnt, ISM_FEC_MAX ) /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */
+ || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */
)
{
*flag_abs_angle1 = 1;
@@ -1418,7 +1418,7 @@ static void encode_angle_indices(
* Quantize and encode ISM metadata in SID frame
*-------------------------------------------------------------------*/
-void ivas_ism_metadata_sid_enc(
+void ivas_ism_metadata_sid_enc_fx(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
const Word16 flag_noisy_speech, /* i : noisy speech flag */
const Word16 nchan_ism, /* i : number of objects */
diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c
index 171b229b4bcd8d47533f0b9c98ba640b7e387970..3169962f50970a32ff501b135766ea6da13223fd 100644
--- a/lib_enc/ivas_ism_param_enc.c
+++ b/lib_enc/ivas_ism_param_enc.c
@@ -160,7 +160,7 @@ static void ivas_param_ism_compute_obj_parameters_fx(
move16();
move16();
}
- assert( ( power_ratios_m[b][m] >= ONE_IN_Q14 /* 0.5 in Q15 */ ) && ( power_ratios_m[b][m] <= ONE_IN_Q15 /* 1 in Q15 */ ) );
+ assert( ( power_ratios_m[b][m] >= ONE_IN_Q14 /* 0.5 in Q15 */ ) && ( power_ratios_m[b][m] <= MAX_16 /* 1 in Q15 */ ) );
/* Quantize power ratios */
/* Power ratio range [0.5,1] is mapped to [0,1] first, rounding via truncation float->integer */
@@ -180,7 +180,7 @@ static void ivas_param_ism_compute_obj_parameters_fx(
tmp1 = W_norm( ref_power_local_frame[0] );
tmp2 = W_norm( ref_power_local_frame[i] );
tmp_ratio = BASOP_Util_Divide3232_Scale( W_extract_h( W_shl( ref_power_local_frame[0], tmp1 ) ), W_extract_h( W_shl( ref_power_local_frame[i], tmp2 ) ), &e_tmp ); // ((Qx + tmp1) - 16) - ((Qx + tmp2) - 16) + 15 - e_tmp = 15 + tmp1 - tmp2 - e_tmp
- tmp_ratio = W_shl( tmp_ratio, sub( sub( e_tmp, 1 ), sub( tmp1, tmp2 ) ) ); // Q14
+ tmp_ratio = W_shl( tmp_ratio, sub( sub( e_tmp, 1 ), sub( tmp1, tmp2 ) ) ); // Q14 // Q14
test();
IF( GT_64( tmp_ratio, 15974 /* 0.975f in Q14 */ ) && LT_64( tmp_ratio, 16794 /* 1.025f in Q14*/ ) )
@@ -220,7 +220,7 @@ static void ivas_param_ism_enc_quantize_DOA_fx(
azi_idx = ism_quant_meta_fx( hIsmMetaData[i]->azimuth_fx, &valQ_fx, ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_AZIMUTH_NBITS );
/*Replace azimuth with quantized values */
- hIsmMetaData[i]->azimuth_fx = valQ_fx;
+ hIsmMetaData[i]->azimuth_fx = valQ_fx; // Q22
move32();
/* Copy the quantized indices */
@@ -312,17 +312,17 @@ void ivas_param_ism_stereo_dmx_fx(
cardioid_right[i] = sub( ONE_IN_Q14 /* 1.0f in Q14 */, cardioid_left[i] ); /* corresponds to: alpha + ( 1 - alpha ) * cosf( tmp + tmp_1 ); */
move16();
/* Loop over all samples */
- FOR( j = 0; j < shr( input_frame, 1 ); j++ )
+ FOR( j = 0; j < input_frame >> 1; j++ )
{
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_left, mult0( j, grad ) ) ), 15 ) );
- stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_left, mult0( j, grad ) ) ), 15 ) ); /* Qx DMX Left */
+ stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
move32();
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_right, negate( mult0( j, grad ) ) ) ), 15 ) );
- stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_right, negate( mult0( j, grad ) ) ) ), 15 ) ); /* Qx DMX Right */
+ stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
move32();
ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */
}
@@ -330,13 +330,13 @@ void ivas_param_ism_stereo_dmx_fx(
{
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) );
- stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) ); /* Qx DMX Left */
+ stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
move32();
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) );
- stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) ); /* Qx DMX Right */
+ stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
move32();
ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */
}
@@ -351,18 +351,18 @@ void ivas_param_ism_stereo_dmx_fx(
{
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) );
- stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) ); /* Qx DMX Left */
+ stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
move32();
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) );
- stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) ); /* Qx DMX Right */
+ stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
move32();
ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */
}
}
- st_ivas->hParamIsm->last_cardioid_left_fx[i] = cardioid_left[i];
+ st_ivas->hParamIsm->last_cardioid_left_fx[i] = cardioid_left[i]; // Q14
move16();
}
@@ -389,7 +389,7 @@ void ivas_param_ism_stereo_dmx_fx(
tmp_1 = 15 + 1;
move16();
- FOR( i = 0; i < shr( input_frame, 1 ); i++ )
+ FOR( i = 0; i < input_frame >> 1; i++ )
{
stereo_dmx[0][i] = W_extract_l( W_shr( W_mult_32_32( stereo_dmx[0][i], L_add( tmp, mult0( i, grad ) ) ), tmp_1 ) ); // Qx
move32();
@@ -437,7 +437,7 @@ void ivas_param_ism_stereo_dmx_fx(
* Open Param ISM handle
*-------------------------------------------------------------------------*/
-ivas_error ivas_param_ism_enc_open(
+ivas_error ivas_param_ism_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
@@ -479,7 +479,7 @@ ivas_error ivas_param_ism_enc_open(
hParamIsm->nbands = MAX_PARAM_ISM_NBANDS;
move16();
- max_bins = extract_l( Mpy_32_32( input_Fs, 10737418 ) ); // (int16_t) ( ( MDFT_FB_BANDS_240 * input_Fs ) / 48000 );
+ max_bins = extract_l( Mpy_32_32( input_Fs, 10737418 /*240/48000.Q31*/ ) ); // (int16_t) ( ( MDFT_FB_BANDS_240 * input_Fs ) / 48000 );
FOR( i = 0; i < ( hParamIsm->nbands + 1 ); i++ )
{
hParamIsm->band_grouping[i] = CLDFB_TO_MDFT_FAC * Param_ISM_band_grouping[i];
@@ -505,7 +505,7 @@ ivas_error ivas_param_ism_enc_open(
* Close Param ISM encoder handle
*-------------------------------------------------------------------------*/
-void ivas_param_ism_enc_close(
+void ivas_param_ism_enc_close_fx(
PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */
const Word32 input_Fs /* i : input sampling_rate */
)
@@ -604,7 +604,7 @@ void ivas_param_ism_enc_fx(
*
*-------------------------------------------------------------------*/
-void ivas_param_ism_compute_noisy_speech_flag(
+void ivas_param_ism_compute_noisy_speech_flag_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c
index 6a67cd814f4ab00b21402f326de9305e1d1de693..e72270e6cb513fef5a0680588777c2ea79366a22 100644
--- a/lib_enc/ivas_lfe_enc.c
+++ b/lib_enc/ivas_lfe_enc.c
@@ -433,14 +433,14 @@ void ivas_lfe_enc_fx(
IF( LT_16( q_data_lfe_ch, hLFE->q_old_wtda_audio ) )
{
- Scale_sig32( hLFE->old_wtda_audio_fx, fade_len, sub( q_data_lfe_ch, hLFE->q_old_wtda_audio ) );
+ Scale_sig32( hLFE->old_wtda_audio_fx, fade_len, sub( q_data_lfe_ch, hLFE->q_old_wtda_audio ) ); // hLFE->q_old_wtda_audio
hLFE->q_old_wtda_audio = q_data_lfe_ch;
move16();
}
IF( GT_16( q_data_lfe_ch, hLFE->q_old_wtda_audio ) )
{
- Scale_sig32( data_lfe_ch, input_frame, sub( hLFE->q_old_wtda_audio, q_data_lfe_ch ) );
+ Scale_sig32( data_lfe_ch, input_frame, sub( hLFE->q_old_wtda_audio, q_data_lfe_ch ) ); // hLFE->q_old_wtda_audio;
q_data_lfe_ch = hLFE->q_old_wtda_audio;
move16();
}
@@ -451,7 +451,7 @@ void ivas_lfe_enc_fx(
q_out1 = Find_Max_Norm32( wtda_audio_fx, input_frame );
q_out1 = sub( q_out1, find_guarded_bits_fx( dct_len ) );
- Scale_sig32( wtda_audio_fx, input_frame, q_out1 );
+ Scale_sig32( wtda_audio_fx, input_frame, q_out1 ); // Q10 + q_out1
q_out1 = add( q_data_lfe_ch, q_out1 );
ivas_mdct_fx( wtda_audio_fx, t_audio_fx, dct_len, &q_out1 );
@@ -464,7 +464,7 @@ void ivas_lfe_enc_fx(
/* mdct */
q_out2 = Find_Max_Norm32( wtda_audio_fx, input_frame );
q_out2 = sub( q_out2, find_guarded_bits_fx( dct_len ) );
- Scale_sig32( wtda_audio_fx, input_frame, q_out2 );
+ Scale_sig32( wtda_audio_fx, input_frame, q_out2 ); // Q10 + q_out2
q_out2 = add( q_data_lfe_ch, q_out2 );
ivas_mdct_fx( wtda_audio_fx, t_audio_fx, dct_len, &q_out2 );
@@ -479,7 +479,7 @@ void ivas_lfe_enc_fx(
q_out2 = add( q_out2, min( q_tmp2, sub( q_out1, q_out2 ) ) );
IF( GT_16( q_out1, q_out2 ) )
{
- Scale_sig32( lfe_dct_fx, num_dct_pass_bins, sub( q_out2, q_out1 ) );
+ Scale_sig32( lfe_dct_fx, num_dct_pass_bins, sub( q_out2, q_out1 ) ); // q_out2
q_out1 = q_out2;
move16();
}
@@ -490,7 +490,7 @@ void ivas_lfe_enc_fx(
q_out1 = add( q_out1, min( q_tmp1, sub( q_out2, q_out1 ) ) );
IF( LT_16( q_out1, q_out2 ) )
{
- Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, sub( q_out1, q_out2 ) );
+ Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, sub( q_out1, q_out2 ) ); // q_out1
q_out1 = q_out2;
move16();
}
@@ -507,7 +507,7 @@ void ivas_lfe_enc_fx(
*
* Create, allocate and initialize IVAS encoder LFE handle
*-------------------------------------------------------------------------*/
-ivas_error ivas_create_lfe_enc(
+ivas_error ivas_create_lfe_enc_fx(
LFE_ENC_HANDLE *hLFE_out, /* o : IVAS LFE encoder structure */
const Word32 input_Fs /* i : input sampling rate */
)
@@ -575,7 +575,7 @@ ivas_error ivas_create_lfe_enc(
// hLFE->lfe_enc_indices_coeffs_tbl[i][j] =
// (int16_t) ceilf( log2f( (float) ( ivas_lfe_num_ele_in_coder_models[i][j] + 1 ) ) );
hLFE->lfe_enc_indices_coeffs_tbl[i][j] =
- floor_log_2( add( ivas_lfe_num_ele_in_coder_models[i][j], 1 ) );
+ floor_log_2( add( ivas_lfe_num_ele_in_coder_models[i][j], 1 ) ); // Q0
move16();
}
}
@@ -590,7 +590,7 @@ ivas_error ivas_create_lfe_enc(
*
* Destroy IVAS cncoder LFE handle
*-------------------------------------------------------------------------*/
-void ivas_lfe_enc_close(
+void ivas_lfe_enc_close_fx(
LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */
)
{
@@ -628,7 +628,7 @@ ivas_error ivas_create_lfe_lpf_enc_fx(
const Word32 input_Fs /* i : input sampling rate */
)
{
- const Word32 *filt_coeff;
+ const Word32 *filt_coeff; // 31 - filt_coeff_e
const Word16 *filt_coeff_e = NULL;
IF( hLfeLpf == NULL )
@@ -657,7 +657,7 @@ ivas_error ivas_create_lfe_lpf_enc_fx(
*
* Destroy IVAS cncoder LFE low pass filter state
*-------------------------------------------------------------------------*/
-void ivas_lfe_lpf_enc_close(
+void ivas_lfe_lpf_enc_close_fx(
ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */
)
{
@@ -681,7 +681,7 @@ void ivas_lfe_lpf_enc_close(
*-------------------------------------------------------------------------*/
void ivas_lfe_lpf_enc_apply_fx(
ivas_filters_process_state_t *hLfeLpf, /* i/o: LFE LPF handle */
- Word32 data_lfe_ch[], /* i/o: LFE signal */
+ Word32 data_lfe_ch[], /* i/o: LFE signal Q11*/
const Word16 input_frame /* i : input frame length per channel */
)
{
diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c
index c7c0777db269a2da359c6cd375031803c4f9b638..d14088e272d7fea289b0a16ba7e3e210876edaf4 100644
--- a/lib_enc/ivas_masa_enc.c
+++ b/lib_enc/ivas_masa_enc.c
@@ -118,7 +118,7 @@ static void masa_metadata_direction_alignment_fx( MASA_ENCODER_HANDLE hMasa );
*
* open and initialize MASA encoder
*-----------------------------------------------------------------------*/
-ivas_error ivas_masa_enc_open(
+ivas_error ivas_masa_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
)
{
@@ -179,16 +179,16 @@ ivas_error ivas_masa_enc_open(
Copy( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 );
Copy( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 );
- hMasa->data.onset_detector_1_fx = 0;
- hMasa->data.onset_detector_2_fx = 0;
+ hMasa->data.onset_detector_1_fx = 0; // hMasa->data.q_onset_detector
+ hMasa->data.onset_detector_2_fx = 0; // hMasa->data.q_onset_detector
hMasa->data.q_onset_detector = 0;
move32();
move32();
move16();
- set32_fx( hMasa->data.lfeToTotalEnergyRatio_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
+ set32_fx( hMasa->data.lfeToTotalEnergyRatio_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); // hMasa->data.lfeToTotalEnergyRatio_e
set16_fx( hMasa->data.lfeToTotalEnergyRatio_e, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
- hMasa->data.prevq_lfeToTotalEnergyRatio_fx = 0;
+ hMasa->data.prevq_lfeToTotalEnergyRatio_fx = 0; // Q31
move32();
hMasa->data.prevq_lfeIndex = 0;
@@ -201,10 +201,10 @@ ivas_error ivas_masa_enc_open(
move16();
move32();
- set_zero_fx( hMasa->data.dir_align_state.previous_azi_dir1_fx, MASA_FREQUENCY_BANDS );
- set_zero_fx( hMasa->data.dir_align_state.previous_ele_dir1_fx, MASA_FREQUENCY_BANDS );
- set_zero_fx( hMasa->data.dir_align_state.previous_azi_dir2_fx, MASA_FREQUENCY_BANDS );
- set_zero_fx( hMasa->data.dir_align_state.previous_ele_dir2_fx, MASA_FREQUENCY_BANDS );
+ set_zero_fx( hMasa->data.dir_align_state.previous_azi_dir1_fx, MASA_FREQUENCY_BANDS ); // Q22
+ set_zero_fx( hMasa->data.dir_align_state.previous_ele_dir1_fx, MASA_FREQUENCY_BANDS ); // Q22
+ set_zero_fx( hMasa->data.dir_align_state.previous_azi_dir2_fx, MASA_FREQUENCY_BANDS ); // Q22
+ set_zero_fx( hMasa->data.dir_align_state.previous_ele_dir2_fx, MASA_FREQUENCY_BANDS ); // Q22
IF( EQ_32( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
@@ -217,7 +217,7 @@ ivas_error ivas_masa_enc_open(
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- set32_fx( hOmasaData->masa_to_total_energy_ratio_fx[i], 0, MASA_FREQUENCY_BANDS );
+ set32_fx( hOmasaData->masa_to_total_energy_ratio_fx[i], 0, MASA_FREQUENCY_BANDS ); // Q30
}
hOmasaData->lp_noise_CPE_fx = -256; /* -1 in Q8 */
@@ -227,7 +227,7 @@ ivas_error ivas_masa_enc_open(
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- set_zero_fx( hOmasaData->energy_ism_fx[i], MASA_FREQUENCY_BANDS );
+ set_zero_fx( hOmasaData->energy_ism_fx[i], MASA_FREQUENCY_BANDS ); // hOmasaData->energy_ism_fx_e
set16_fx( hOmasaData->energy_ism_fx_e[i], 0, MASA_FREQUENCY_BANDS );
}
@@ -248,7 +248,7 @@ ivas_error ivas_masa_enc_open(
*
* close MASA encoder
*-----------------------------------------------------------------------*/
-void ivas_masa_enc_close(
+void ivas_masa_enc_close_fx(
MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */
)
{
@@ -322,7 +322,6 @@ ivas_error ivas_masa_encode_fx(
IF( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) )
{
/* Create the MASA SID descriptor for the metadata and CPE mode, in order to have the SID frame self-contained. */
- test();
IF( Opt_DTX_ON && hQMetaData != NULL )
{
IF( EQ_16( nchan_transport, 2 ) ) /* this is MASA format in CPE only */
@@ -351,9 +350,9 @@ ivas_error ivas_masa_encode_fx(
{
FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
{
- Copy32( hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], h_orig_metadata[i].azimuth_fx[j], MASA_FREQUENCY_BANDS );
- Copy32( hMasa->masaMetadata.directional_meta[i].elevation_fx[j], h_orig_metadata[i].elevation_fx[j], MASA_FREQUENCY_BANDS );
- Copy32( hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], h_orig_metadata[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS );
+ Copy32( hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], h_orig_metadata[i].azimuth_fx[j], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( hMasa->masaMetadata.directional_meta[i].elevation_fx[j], h_orig_metadata[i].elevation_fx[j], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], h_orig_metadata[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS ); // Q30
Copy( (Word16 *) ( hMasa->masaMetadata.directional_meta[i].spherical_index[j] ), (Word16 *) ( h_orig_metadata[i].spherical_index[j] ), MASA_FREQUENCY_BANDS );
}
}
@@ -384,7 +383,7 @@ ivas_error ivas_masa_encode_fx(
{
FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
{
- hMasa->data.energy_fx[i][j] = L_shr( hMasa->data.energy_fx[i][j], sub( s, hMasa->data.energy_e[i][j] ) );
+ hMasa->data.energy_fx[i][j] = L_shr( hMasa->data.energy_fx[i][j], sub( s, hMasa->data.energy_e[i][j] ) ); // hMasa->data.energy_e[i][j] -> s
hMasa->data.energy_e[i][j] = s;
move32();
move16();
@@ -700,9 +699,9 @@ ivas_error ivas_masa_encode_fx(
{
FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
{
- Copy32( h_orig_metadata[i].azimuth_fx[j], hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], MASA_FREQUENCY_BANDS );
- Copy32( h_orig_metadata[i].elevation_fx[j], hMasa->masaMetadata.directional_meta[i].elevation_fx[j], MASA_FREQUENCY_BANDS );
- Copy32( h_orig_metadata[i].energy_ratio_fx[j], hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS );
+ Copy32( h_orig_metadata[i].azimuth_fx[j], hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( h_orig_metadata[i].elevation_fx[j], hMasa->masaMetadata.directional_meta[i].elevation_fx[j], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( h_orig_metadata[i].energy_ratio_fx[j], hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS ); // Q30
}
}
@@ -815,6 +814,9 @@ void ivas_masa_estimate_energy_fx(
{
q_buf = q_data;
move16();
+ scale_sig32( hMasa->data.cldfbAnaEnc[i]->cldfb_state_fx, hMasa->data.cldfbAnaEnc[i]->cldfb_state_length, sub( q_buf, hMasa->data.cldfbAnaEnc[i]->Q_cldfb_state ) );
+ hMasa->data.cldfbAnaEnc[i]->Q_cldfb_state = q_buf;
+ move16();
cldfbAnalysis_ts_fx_fixed_q( &( data_fx[i][l_ts * ts] ), Input_RealBuffer[i], Input_ImagBuffer[i], l_ts, hMasa->data.cldfbAnaEnc[i], &q_buf ); // (q_data - 5) for Input_RealBuffer[i], Input_ImagBuffer[i]
}
@@ -1105,7 +1107,7 @@ ivas_error ivas_masa_enc_config_fx(
maxBand = 0;
move16();
test();
- WHILE( LE_16( maxBand, MASA_FREQUENCY_BANDS ) && LE_16( MASA_band_grouping_24[maxBand], maxBin ) )
+ WHILE( ( maxBand <= MASA_FREQUENCY_BANDS ) && ( MASA_band_grouping_24[maxBand] <= maxBin ) )
{
test();
maxBand = (UWord8) add( maxBand, 1 );
@@ -1131,7 +1133,7 @@ ivas_error ivas_masa_enc_config_fx(
continueLoop = 1;
move16();
test();
- WHILE( GT_16( maxBand, 5 ) && continueLoop )
+ WHILE( ( maxBand > 5 ) && continueLoop )
{
test();
FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
@@ -1203,7 +1205,8 @@ ivas_error ivas_masa_enc_config_fx(
}
ELSE
{
- st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = shr( add( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_fx, st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise_fx ), 1 ); /*Q8*/
+ /* ( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise + st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise ) / CPE_CHANNELS; */
+ st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = extract_h( L_mac( L_mult( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_fx, ONE_IN_Q14 ), st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise_fx, ONE_IN_Q14 ) ); /*Q8*/
}
move16();
}
@@ -1519,7 +1522,7 @@ static void combine_freqbands_and_subframes_fx(
}
}
- if ( i == 0 )
+ IF( i == 0 )
{
energy[j][k] = energySum; // 31-energySum_e
energy_e[j][k] = energySum_e;
@@ -1887,7 +1890,7 @@ void ivas_masa_combine_directions_fx(
}
static void find_n_largest_fx(
- const Word32 *input_fx,
+ const Word32 *input_fx, // Q(31 - exp_input)
Word16 exp_input,
Word16 *largestIndices,
const Word16 numElements,
@@ -1900,13 +1903,13 @@ static void find_n_largest_fx(
FOR( j = 0; j < numElements; j++ )
{
- values[j] = input_fx[j];
+ values[j] = input_fx[j]; // Q(31 - exp_input)
move32();
}
FOR( i = 0; i < numLargest; i++ )
{
- largestValue = values[0];
+ largestValue = values[0]; // Q(31 - exp_input)
move32();
largestIndex = 0;
move16();
@@ -1914,7 +1917,7 @@ static void find_n_largest_fx(
{
IF( GT_32( values[j], largestValue ) )
{
- largestValue = values[j];
+ largestValue = values[j]; // Q(31 - exp_input)
largestIndex = j;
move32();
move16();
@@ -1924,12 +1927,12 @@ static void find_n_largest_fx(
move16();
IF( exp_input != 0 )
{
- values[largestIndex] = L_negate( 1 << ( sub( 31, exp_input ) ) );
+ values[largestIndex] = L_negate( 1 << ( sub( 31, exp_input ) ) ); // Q(31 - exp_input)
move32();
}
ELSE
{
- values[largestIndex] = 1 << ( sub( 31, exp_input ) );
+ values[largestIndex] = 1 << ( sub( 31, exp_input ) ); // Q(31 - exp_input)
move32();
}
}
@@ -1966,9 +1969,9 @@ static void move_metadata_to_qmetadata_fx(
{
FOR( band = 0; band < numCodingBands; band++ )
{
- hQMeta->q_direction[dir].band_data[band].azimuth_fx[sf] = hMeta->directional_meta[dir].azimuth_fx[sf][band];
- hQMeta->q_direction[dir].band_data[band].elevation_fx[sf] = hMeta->directional_meta[dir].elevation_fx[sf][band];
- hQMeta->q_direction[dir].band_data[band].energy_ratio_fx[sf] = hMeta->directional_meta[dir].energy_ratio_fx[sf][band];
+ hQMeta->q_direction[dir].band_data[band].azimuth_fx[sf] = hMeta->directional_meta[dir].azimuth_fx[sf][band]; // Q22
+ hQMeta->q_direction[dir].band_data[band].elevation_fx[sf] = hMeta->directional_meta[dir].elevation_fx[sf][band]; // Q22
+ hQMeta->q_direction[dir].band_data[band].energy_ratio_fx[sf] = hMeta->directional_meta[dir].energy_ratio_fx[sf][band]; // Q30
hQMeta->q_direction[dir].band_data[band].spherical_index[sf] = hMeta->directional_meta[dir].spherical_index[sf][band];
move32();
move32();
@@ -1977,7 +1980,7 @@ static void move_metadata_to_qmetadata_fx(
IF( hQMeta->q_direction[dir].coherence_band_data != NULL )
{
- hQMeta->q_direction[dir].coherence_band_data[band].spread_coherence[sf] = (UWord8) mult_r( hMeta->directional_meta[dir].spread_coherence_fx[sf][band], UINT8_MAX );
+ hQMeta->q_direction[dir].coherence_band_data[band].spread_coherence[sf] = (UWord8) mult_r( hMeta->directional_meta[dir].spread_coherence_fx[sf][band], UINT8_MAX ); // Q15
move16();
}
}
@@ -1990,7 +1993,7 @@ static void move_metadata_to_qmetadata_fx(
{
IF( hQMeta->surcoh_band_data != NULL )
{
- hQMeta->surcoh_band_data[band].surround_coherence[sf] = (UWord8) mult_r( hMeta->common_meta.surround_coherence_fx[sf][band], UINT8_MAX );
+ hQMeta->surcoh_band_data[band].surround_coherence[sf] = (UWord8) mult_r( hMeta->common_meta.surround_coherence_fx[sf][band], UINT8_MAX ); // Q15
move16();
}
}
@@ -2072,12 +2075,12 @@ static void detect_metadata_composition_fx(
{
sf = 0;
move16();
- WHILE( !dirValid[dir] && LT_16( sf, MAX_PARAM_SPATIAL_SUBFRAMES ) )
+ WHILE( !dirValid[dir] && ( sf < MAX_PARAM_SPATIAL_SUBFRAMES ) )
{
test();
band = 0;
move16();
- WHILE( !dirValid[dir] && LT_16( band, MASA_FREQUENCY_BANDS ) )
+ WHILE( !dirValid[dir] && ( band < MASA_FREQUENCY_BANDS ) )
{
test();
IF( GE_32( hMeta->directional_meta[dir].energy_ratio_fx[sf][band] /*q30*/, MASA_RATIO_THRESHOLD_FX >> 1 /*q30*/ ) )
@@ -2119,7 +2122,7 @@ static void detect_metadata_composition_fx(
}
}
- IF( *isTwoDir == FALSE )
+ if ( *isTwoDir == FALSE )
{
/* Further checks will be done with just one direction */
numDir = 1;
@@ -2132,9 +2135,10 @@ static void detect_metadata_composition_fx(
sf = 1;
move16();
move16();
- WHILE( EQ_16( sfSimilar, TRUE ) && LT_16( sf, MAX_PARAM_SPATIAL_SUBFRAMES ) )
+
+ test();
+ WHILE( ( sfSimilar == TRUE ) && ( sf < MAX_PARAM_SPATIAL_SUBFRAMES ) )
{
- test();
sfSimilar = are_masa_subframes_similar_fx( hMeta, 0, hMeta, sf );
sf = (Word8) add( sf, 1 );
move16();
@@ -2155,19 +2159,19 @@ static void detect_metadata_composition_fx(
/* Check spread coherence */
dir = 0;
move16();
- WHILE( cohPresent == FALSE && LT_16( dir, numDir ) )
+ test();
+ WHILE( cohPresent == FALSE && ( dir < numDir ) )
{
- test();
sf = 0;
move16();
- WHILE( cohPresent == FALSE && LT_16( sf, nSubFrames ) )
+ test();
+ WHILE( cohPresent == FALSE && ( sf < nSubFrames ) )
{
- test();
band = 0;
move16();
- WHILE( cohPresent == FALSE /*has value zero*/ && LT_16( band, MASA_FREQUENCY_BANDS ) )
+ test();
+ WHILE( cohPresent == FALSE /*has value zero*/ && ( band < MASA_FREQUENCY_BANDS ) )
{
- test();
/* Check coherences for presence of coherence */
IF( GT_16( hMeta->directional_meta[dir].spread_coherence_fx[sf][band] /*Q15*/, MASA_COHERENCE_THRESHOLD_FX >> 16 ) ) /*Q15*/
{
@@ -2563,7 +2567,7 @@ static void reduce_metadata_further_fx(
{
FOR( band = 0; band < numCodingBands; band++ )
{
- hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[0];
+ hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[0]; // Q0
move16();
}
}
@@ -2582,18 +2586,18 @@ static void reduce_metadata_further_fx(
/* Use the selected frequency band to represent all data */
FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
{
- hqmetadata->q_direction[0].band_data[0].azimuth_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].azimuth_fx[sf];
- hqmetadata->q_direction[0].band_data[0].elevation_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].elevation_fx[sf];
- hqmetadata->q_direction[0].band_data[0].energy_ratio_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].energy_ratio_fx[sf];
+ hqmetadata->q_direction[0].band_data[0].azimuth_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].azimuth_fx[sf]; // Q22
+ hqmetadata->q_direction[0].band_data[0].elevation_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].elevation_fx[sf]; // Q22
+ hqmetadata->q_direction[0].band_data[0].energy_ratio_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].energy_ratio_fx[sf]; // Q30
move32();
move32();
move32();
- if ( hqmetadata->q_direction[0].coherence_band_data != NULL )
+ IF( hqmetadata->q_direction[0].coherence_band_data != NULL )
{
- hqmetadata->q_direction[0].coherence_band_data[0].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[selectedBand].spread_coherence[sf];
+ hqmetadata->q_direction[0].coherence_band_data[0].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[selectedBand].spread_coherence[sf]; // Q0
move16();
}
- if ( hqmetadata->surcoh_band_data != NULL )
+ IF( hqmetadata->surcoh_band_data != NULL )
{
hqmetadata->surcoh_band_data[0].surround_coherence[sf] = hqmetadata->surcoh_band_data[selectedBand].surround_coherence[sf];
move16();
@@ -2607,7 +2611,7 @@ static void reduce_metadata_further_fx(
{
FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
{
- hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[0].spread_coherence[sf];
+ hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[0].spread_coherence[sf]; // Q0
move16();
}
}
@@ -2657,7 +2661,7 @@ static Word16 encode_lfe_to_total_energy_ratio_fx(
move16();
/* Determine maximum amount of LFE energy in any subframe */
- maxLFESubFrameEner = 0;
+ maxLFESubFrameEner = 0; // maxLFESubFrameEner_e
move32();
maxLFESubFrameEner_e = 0;
move16();
@@ -2665,7 +2669,7 @@ static Word16 encode_lfe_to_total_energy_ratio_fx(
{
IF( BASOP_Util_Cmp_Mant32Exp( hMasa->data.lfeToTotalEnergyRatio_fx[i], hMasa->data.lfeToTotalEnergyRatio_e[i], maxLFESubFrameEner, maxLFESubFrameEner_e ) > 0 )
{
- maxLFESubFrameEner = hMasa->data.lfeToTotalEnergyRatio_fx[i];
+ maxLFESubFrameEner = hMasa->data.lfeToTotalEnergyRatio_fx[i]; // hMasa->data.lfeToTotalEnergyRatio_e[i]
move32();
maxLFESubFrameEner_e = hMasa->data.lfeToTotalEnergyRatio_e[i];
move16();
@@ -2763,7 +2767,7 @@ static Word16 encode_lfe_to_total_energy_ratio_fx(
/* Do 1st stage scalar quantization */
lfeToTotalEnergyRatioIndices[0] = 1;
move16();
- lfeToTotalEnergyRatioIndices[1] = usquant_fx( extract_l( L_shr( log2LFEaverage, Q13 ) ), &xq, MCMASA_LFE_QLOW_Q12, MCMASA_LFE_DELTA_Q11, 8 );
+ lfeToTotalEnergyRatioIndices[1] = usquant_fx( extract_l( L_shr( log2LFEaverage, Q14 ) ), &xq, MCMASA_LFE_QLOW_Q11, MCMASA_LFE_DELTA_Q10, 8 );
move16();
IF( GE_32( ivas_total_brate, IVAS_24k4 ) ) /* Vector quantization is applied if bitrate >= 24.4 kbps */
@@ -2771,7 +2775,7 @@ static Word16 encode_lfe_to_total_energy_ratio_fx(
/* Remove scalar value from the vector*/
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- log2LFEratio[i] = L_sub( log2LFEratio[i], L_shl( xq, Q13 ) ); // Q25
+ log2LFEratio[i] = L_sub( log2LFEratio[i], L_shl( xq, Q14 ) ); // Q25
move32();
}
@@ -2897,7 +2901,7 @@ void ivas_masa_enc_reconfigure_fx(
st_ivas->hCPE[cpe_id]->element_brate = imult3216( tmp_br, 2 ); //( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
move32();
- IF( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
tmp = 1;
}
@@ -2939,7 +2943,7 @@ void ivas_masa_enc_reconfigure_fx(
*-------------------------------------------------------------------*/
static void average_masa_metadata_fx(
MASA_METADATA_FRAME *hMeta,
- Word32 energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*i*/
+ Word32 energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*i Q(31 - energy_e) */
Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*i:stores exponent values for energy_e*/
const SPHERICAL_GRID_DATA *Sph_Grid16,
const UWord8 useSphGrid )
@@ -3111,16 +3115,16 @@ static void copy_masa_metadata_subframe_fx(
/* directional metadata */
FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
{
- Copy32( hMetaFrom->directional_meta[dir].azimuth_fx[sfFrom], hMetaTo->directional_meta[dir].azimuth_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy32( hMetaFrom->directional_meta[dir].elevation_fx[sfFrom], hMetaTo->directional_meta[dir].elevation_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy32( hMetaFrom->directional_meta[dir].energy_ratio_fx[sfFrom], hMetaTo->directional_meta[dir].energy_ratio_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy( hMetaFrom->directional_meta[dir].spread_coherence_fx[sfFrom], hMetaTo->directional_meta[dir].spread_coherence_fx[sfTo], MASA_FREQUENCY_BANDS );
+ Copy32( hMetaFrom->directional_meta[dir].azimuth_fx[sfFrom], hMetaTo->directional_meta[dir].azimuth_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( hMetaFrom->directional_meta[dir].elevation_fx[sfFrom], hMetaTo->directional_meta[dir].elevation_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( hMetaFrom->directional_meta[dir].energy_ratio_fx[sfFrom], hMetaTo->directional_meta[dir].energy_ratio_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q30
+ Copy( hMetaFrom->directional_meta[dir].spread_coherence_fx[sfFrom], hMetaTo->directional_meta[dir].spread_coherence_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q15
}
/* common metadata */
- Copy32( hMetaFrom->common_meta.diffuse_to_total_ratio_fx[sfFrom], hMetaTo->common_meta.diffuse_to_total_ratio_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy( hMetaFrom->common_meta.surround_coherence_fx[sfFrom], hMetaTo->common_meta.surround_coherence_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy32( hMetaFrom->common_meta.remainder_to_total_ratio_fx[sfFrom], hMetaTo->common_meta.remainder_to_total_ratio_fx[sfTo], MASA_FREQUENCY_BANDS );
+ Copy32( hMetaFrom->common_meta.diffuse_to_total_ratio_fx[sfFrom], hMetaTo->common_meta.diffuse_to_total_ratio_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q30
+ Copy( hMetaFrom->common_meta.surround_coherence_fx[sfFrom], hMetaTo->common_meta.surround_coherence_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q15
+ Copy32( hMetaFrom->common_meta.remainder_to_total_ratio_fx[sfFrom], hMetaTo->common_meta.remainder_to_total_ratio_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q30
return;
}
@@ -3209,18 +3213,18 @@ static UWord8 are_masa_subframes_similar_fx(
move16();
move16();
- WHILE( EQ_16( sf_differ, FALSE ) && LE_16( dir, num_dir ) )
+ WHILE( ( sf_differ == FALSE ) && ( dir <= num_dir ) )
{
test();
band_idx = 0;
move16();
- WHILE( EQ_16( sf_differ, FALSE ) && LT_16( band_idx, MASA_FREQUENCY_BANDS ) )
+ WHILE( ( sf_differ == FALSE ) && ( band_idx < MASA_FREQUENCY_BANDS ) )
{
test();
Word32 azi_dif_fx;
- azi_dif_fx = L_abs( L_sub( frame1->directional_meta[dir].azimuth_fx[sf1_idx][band_idx], frame2->directional_meta[dir].azimuth_fx[sf2_idx][band_idx] ) );
+ azi_dif_fx = L_abs( L_sub( frame1->directional_meta[dir].azimuth_fx[sf1_idx][band_idx], frame2->directional_meta[dir].azimuth_fx[sf2_idx][band_idx] ) ); // Q22
IF( GT_32( azi_dif_fx, 180 << Q22 ) )
- azi_dif_fx = L_sub( 360 << Q22, azi_dif_fx );
+ azi_dif_fx = L_sub( 360 << Q22, azi_dif_fx ); // Q22
IF( GT_32( azi_dif_fx, ONE_IN_Q21 /*0.5 in Q22*/ ) )
{
@@ -3258,7 +3262,7 @@ static UWord8 are_masa_subframes_similar_fx(
}
/* check the common metadata */
- WHILE( EQ_16( sf_differ, FALSE ) && LT_16( band_idx, MASA_FREQUENCY_BANDS ) )
+ WHILE( ( sf_differ == FALSE ) && ( band_idx < MASA_FREQUENCY_BANDS ) )
{
test();
IF( GT_32( L_abs( L_sub( frame1->common_meta.surround_coherence_fx[sf1_idx][band_idx], frame2->common_meta.surround_coherence_fx[sf2_idx][band_idx] ) ), MASA_COHERENCE_TOLERANCE_FX ) )
@@ -3770,19 +3774,19 @@ void ivas_merge_masa_metadata_fx(
move16();
IF( EQ_16( band_n_dirs, 2 ) )
{
- energyTimesRatioMASA_fx[1] = Mpy_32_32( eneBand_fx, hMeta->directional_meta[1].energy_ratio_fx[sf][band] );
+ energyTimesRatioMASA_fx[1] = Mpy_32_32( eneBand_fx, hMeta->directional_meta[1].energy_ratio_fx[sf][band] ); // energyTimesRatioMASA_e
energyTimesRatioMASA_e[1] = add( eneBand_e, 1 );
}
ELSE
{
- energyTimesRatioMASA_fx[1] = 0;
+ energyTimesRatioMASA_fx[1] = 0; // energyTimesRatioMASA_e
energyTimesRatioMASA_e[1] = 0;
}
move32();
move16();
/* target is original MASA diffuseness */
- total_diff_nrg_fx = Mpy_32_32( eneBand_fx, hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] );
+ total_diff_nrg_fx = Mpy_32_32( eneBand_fx, hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] ); // total_diff_nrg_e
total_diff_nrg_e = add( eneBand_e, 1 );
/* criterion is mean of ISM ratio and new ratio */
@@ -3842,6 +3846,7 @@ void ivas_merge_masa_metadata_fx(
ELSE
{
hMeta->directional_meta[merge_dest].energy_ratio_fx[sf][band] = hOMasaMeta->directional_meta[0].energy_ratio_fx[sf][band]; /*q30*/
+ move32();
}
/* clip with original ISM dir */
hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_sub( ONE_IN_Q30, hMeta->directional_meta[merge_dest].energy_ratio_fx[sf][band] ); /*q30*/
@@ -3920,7 +3925,7 @@ static void quantize_ratio_ism_vector_ivas_fx(
IF( tmp < 0 )
{
/* take it out from quantize function */
- Copy( ratio_ism, ratio_ism_loc, idx_sep_object );
+ Copy( ratio_ism, ratio_ism_loc, idx_sep_object ); // Q(15 - ratio_ism_e)
Copy( &ratio_ism[idx_sep_object + 1], &ratio_ism_loc[idx_sep_object], nchan_ism - idx_sep_object - 1 );
no_ism_loc = sub( nchan_ism, 1 );
}
@@ -3980,7 +3985,7 @@ static void quantize_ratio_ism_vector_ivas_fx(
move16();
move16();
- WHILE( LT_16( part_idx_sum, max_sum_idx ) )
+ WHILE( ( part_idx_sum < max_sum_idx ) )
{
best_i = -1;
move16();
@@ -4183,7 +4188,7 @@ static Word16 try_differential_fx(
b_signif = 0;
move16();
- WHILE( LT_16( b_signif, numCodingBands ) && GE_32( masa_to_total_energy_ratio[b_signif], MASA2TOTAL_THR_Q30 ) )
+ WHILE( ( b_signif < numCodingBands ) && ( masa_to_total_energy_ratio[b_signif] >= MASA2TOTAL_THR_Q30 ) )
{
test();
b_signif = add( b_signif, 1 );
@@ -4471,7 +4476,7 @@ static Word16 encode_ratio_ism_subframe_fx(
move16();
move16();
move16();
- WHILE( LT_16( b_signif, numCodingBands ) && GE_32( masa_to_total_energy_ratio[b_signif], MASA2TOTAL_THR_Q30 ) )
+ WHILE( ( b_signif < numCodingBands ) && ( masa_to_total_energy_ratio[b_signif] >= MASA2TOTAL_THR_Q30 ) )
{
test();
b_signif = add( b_signif, 1 );
@@ -4735,8 +4740,8 @@ static void ivas_encode_masaism_metadata_fx(
{
FOR( band = 0; band < nbands_work; band++ )
{
- energy_ism = 0; /* ISM energy for current subband */
- energy_ism_e = 0; /* ISM energy for current subband */
+ energy_ism = 0; /* ISM energy for current subband */ // energy_ism_e
+ energy_ism_e = 0; /* ISM energy for current subband */
move32();
move16();
FOR( obj = 0; obj < nchan_ism; obj++ )
diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c
index 26a81c1330a574838d052a3e393cbe2297d5564d..ac99927571182be9f55ca186fc51ca33772dfd0f 100644
--- a/lib_enc/ivas_mc_param_enc.c
+++ b/lib_enc/ivas_mc_param_enc.c
@@ -52,13 +52,13 @@
* Local function prototypes
*------------------------------------------------------------------------*/
-static void ivas_param_mc_write_bs( const PARAM_MC_ENC_HANDLE hParamMC, int16_t *ILD_idx, int16_t *ICC_idx, uint16_t bit_buffer[PARAM_MC_MAX_BITS], int16_t *bit_pos );
+static void ivas_param_mc_write_bs_fx( const PARAM_MC_ENC_HANDLE hParamMC, Word16 *ILD_idx, Word16 *ICC_idx, UWord16 bit_buffer[PARAM_MC_MAX_BITS], Word16 *bit_pos );
-static void ivas_param_mc_dec2bin( const int16_t val, const int16_t N, uint16_t bits[PARAM_MC_MAX_BITS] );
+static void ivas_param_mc_dec2bin_fx( const Word16 val, const Word16 N, UWord16 bits[PARAM_MC_MAX_BITS] );
-static void ivas_param_mc_encode_parameter( int16_t *idx_in, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParameterCodingInfo, const int16_t nbands, const int16_t band_step, const int16_t map_size_wo_lfe, const int16_t map_size, uint16_t bit_buffer[PARAM_MC_MAX_BITS], int16_t *bit_pos );
+static void ivas_param_mc_encode_parameter_fx( Word16 *idx_in, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParameterCodingInfo, const Word16 nbands, const Word16 band_step, const Word16 map_size_wo_lfe, const Word16 map_size, UWord16 bit_buffer[PARAM_MC_MAX_BITS], Word16 *bit_pos );
-static void ivas_param_mc_range_encoder( const int16_t *seq_in, const int16_t num_symbols, const uint16_t *cum_freq, const uint16_t *sym_freq, const uint16_t tot_shift, const int16_t max_nb_bits, uint16_t *bit_buffer, int16_t *bit_pos );
+static void ivas_param_mc_range_encoder_fx( const Word16 *seq_in, const Word16 num_symbols, const UWord16 *cum_freq, const UWord16 *sym_freq, const UWord16 tot_shift, const Word16 max_nb_bits, UWord16 *bit_buffer, Word16 *bit_pos );
#define ATTACKTHRESHOLD_E 4
@@ -147,7 +147,7 @@ ivas_error ivas_param_mc_enc_open_fx(
}
/* get dmx factors */
- hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx;
+ hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx; // Q31
/* set FB config. */
IF( NE_32( ( error = ivas_fb_set_cfg( &fb_cfg, MC_FORMAT, nchan_inp, 0, 0, input_Fs, 0 ) ), IVAS_ERR_OK ) )
@@ -216,12 +216,12 @@ ivas_error ivas_param_mc_enc_open_fx(
move16();
/* Init total/dmx ener factors */
- set32_fx( hParamMC->ener_fac_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS );
+ set32_fx( hParamMC->ener_fac_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS ); // Q21
/* init previous ILDs */
FOR( i = 0; i < PARAM_MC_MAX_PARAMETER_BANDS; i++ )
{
- set32_fx( hParamMC->prev_ilds_fx[i], 0, PARAM_MC_SZ_ILD_MAP );
+ set32_fx( hParamMC->prev_ilds_fx[i], 0, PARAM_MC_SZ_ILD_MAP ); // Q21
}
st_ivas->hParamMC = hParamMC;
@@ -292,7 +292,7 @@ ivas_error ivas_param_mc_enc_reconfig_fx(
}
/* get dmx factors */
- hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx;
+ hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx; // Q31
/* open/init parameter coding */
ivas_param_mc_metadata_open_fx( mc_input_setup, ivas_total_brate, &hParamMC->hMetadataPMC );
@@ -349,7 +349,7 @@ ivas_error ivas_param_mc_enc_reconfig_fx(
move16();
/* Init total/dmx ener factors */
- set32_fx( hParamMC->ener_fac_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS );
+ set32_fx( hParamMC->ener_fac_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS ); // Q21
return error;
@@ -536,7 +536,7 @@ void ivas_param_mc_enc_fx(
/* just copy data_dmx generated above, contains already the downmix */
FOR( ch = 0; ch < st_ivas->nchan_transport; ch++ )
{
- Copy32( data_dmx_fx[ch], data_f_fx[ch], input_frame );
+ Copy32( data_dmx_fx[ch], data_f_fx[ch], input_frame ); // q_data_dmx_fx16
}
/* we have to run the transient detector on the second channel of the last CPE if we
@@ -547,15 +547,15 @@ void ivas_param_mc_enc_fx(
{
Word16 cpe_idx = shr( ch, 1 );
- set32_fx( data_f_fx[ch], 0, input_frame );
- set16_fx( data_f_fx16, 0, input_frame );
+ set32_fx( data_f_fx[ch], 0, input_frame ); // Q11
+ set16_fx( data_f_fx16, 0, input_frame ); // Q11
RunTransientDetection_ivas_fx( data_f_fx16, input_frame, st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet, 0 );
}
}
/* write Parametric MC side info bitstream into temporary buffer*/
- ivas_param_mc_write_bs( hParamMC, ILD_idx, ICC_idx, bit_buffer, &bit_pos );
+ ivas_param_mc_write_bs_fx( hParamMC, ILD_idx, ICC_idx, bit_buffer, &bit_pos );
/* push the Parametric MC side info from the temporary buffer into the medatdata bitstream*/
push_next_bits( hMetaData, bit_buffer, bit_pos );
@@ -606,7 +606,7 @@ static void ivas_param_mc_dmx_fx(
move16();
FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ )
{
- ( *dmx_sample_fx ) = Madd_32_32( ( *dmx_sample_fx ), data_f_fx[idx[inp_ch]][i], ( *( p_dmx_fac_fx++ ) ) );
+ ( *dmx_sample_fx ) = Madd_32_32( ( *dmx_sample_fx ), data_f_fx[idx[inp_ch]][i], ( *( p_dmx_fac_fx++ ) ) ); // Q_x - 11
move16();
}
}
@@ -626,9 +626,9 @@ static void ivas_param_mc_dmx_fx(
static void ivas_param_mc_param_est_enc_fx(
PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */
Word32 *data_f_fx[], /* i : Input frame in the time domain Q11 */
- Word32 Cy_sum_fx[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */
+ Word32 Cy_sum_fx[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame Cy_sum_e*/
Word16 Cy_sum_e[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */
- Word32 Cx_sum_fx[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */
+ Word32 Cx_sum_fx[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame Cx_sum_e*/
Word16 Cx_sum_e[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */
const Word16 input_frame, /* i : Input frame length */
const Word16 nchan_input, /* i : number of input channels */
@@ -1009,7 +1009,7 @@ static void ivas_param_mc_param_est_enc_fx(
{
ref_channel_idx = h_ild_mapping->ref_channel_idx[k][ref_channel_cnt];
move16();
- ref_ener_fx = BASOP_Util_Add_Mant32Exp( ref_ener_fx, ref_ener_e, Cx_sum_fx[cur_param_band][ref_channel_idx][ref_channel_idx],
+ ref_ener_fx = BASOP_Util_Add_Mant32Exp( ref_ener_fx, ref_ener_e, Cx_sum_fx[cur_param_band][ref_channel_idx][ref_channel_idx], // ref_ener_e
Cx_sum_e[cur_param_band][ref_channel_idx][ref_channel_idx], &ref_ener_e );
ref_ener_e = Cx_sum_e[cur_param_band][ref_channel_idx][ref_channel_idx];
move16();
@@ -1633,8 +1633,8 @@ static void ivas_param_mc_transient_detection_fx(
push_wmops( "param_mc_trn_det" );
attackRatioThreshold_fx = hTranDet->transientDetector.attackRatioThreshold;
- pSubblockNrg_fx = &hTranDet->subblockEnergies.subblockNrg[hParamMC->transient_detector_delay];
- pAccSubblockNrg_fx = &hTranDet->subblockEnergies.accSubblockNrg[hParamMC->transient_detector_delay];
+ pSubblockNrg_fx = &hTranDet->subblockEnergies.subblockNrg[hParamMC->transient_detector_delay]; // Q0
+ pAccSubblockNrg_fx = &hTranDet->subblockEnergies.accSubblockNrg[hParamMC->transient_detector_delay]; // Q0
bIsAttackPresent = FALSE;
move16();
@@ -1680,7 +1680,7 @@ return;
* Write the metadata bitstream
*------------------------------------------------------------------------*/
-static void ivas_param_mc_write_bs(
+static void ivas_param_mc_write_bs_fx(
const PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder Handle */
Word16 *ILD_idx, /* i : ILD quantizer indices sequence */
Word16 *ICC_idx, /* i : ICC quantizer indices sequence */
@@ -1762,11 +1762,11 @@ static void ivas_param_mc_write_bs(
}
}
- ivas_param_mc_encode_parameter( ICC_idx, &hParamMC->hMetadataPMC, &hParamMC->hMetadataPMC.icc_coding,
- nbands, band_step, icc_map_size_wo_lfe, icc_map_size, bit_buffer, bit_pos );
+ ivas_param_mc_encode_parameter_fx( ICC_idx, &hParamMC->hMetadataPMC, &hParamMC->hMetadataPMC.icc_coding,
+ nbands, band_step, icc_map_size_wo_lfe, icc_map_size, bit_buffer, bit_pos );
- ivas_param_mc_encode_parameter( ILD_idx, &hParamMC->hMetadataPMC, &hParamMC->hMetadataPMC.ild_coding,
- nbands, band_step, ild_map_size_wo_lfe, ild_map_size, bit_buffer, bit_pos );
+ ivas_param_mc_encode_parameter_fx( ILD_idx, &hParamMC->hMetadataPMC, &hParamMC->hMetadataPMC.ild_coding,
+ nbands, band_step, ild_map_size_wo_lfe, ild_map_size, bit_buffer, bit_pos );
pop_wmops();
return;
@@ -1774,13 +1774,13 @@ static void ivas_param_mc_write_bs(
/*-------------------------------------------------------------------------
- * ivas_param_mc_encode_parameter()
+ * ivas_param_mc_encode_parameter_fx()
*
* (entropy) encode a sequence of parameter indices
*------------------------------------------------------------------------*/
-static void ivas_param_mc_encode_parameter(
- int16_t *quant_idx, /* i : indices sequence to encode */
+static void ivas_param_mc_encode_parameter_fx(
+ Word16 *quant_idx, /* i : indices sequence to encode */
HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, /* i : Parametric MC metadata handle */
HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParameterCodingInfo, /* i : parameter quantization and coding info */
const Word16 nbands, /* i : number of parameter bands to encode */
@@ -1867,10 +1867,10 @@ static void ivas_param_mc_encode_parameter(
bit_cnt_uni = sub( i_mult( sz_seq, hParameterCodingInfo->uni_bits ), 1 ); /* -1 for the additional diff/direct signaling bit for the range encoder*/
/* code the direct index sequence */
- ivas_param_mc_range_encoder( seq, sz_seq, hParameterCodingInfo->cum_freq, hParameterCodingInfo->sym_freq, PARAM_MC_RANGE_CODER_TOT_SHIFT, bit_cnt_uni, &tmp_bit_buffer[0], &bit_cnt_range );
+ ivas_param_mc_range_encoder_fx( seq, sz_seq, hParameterCodingInfo->cum_freq, hParameterCodingInfo->sym_freq, PARAM_MC_RANGE_CODER_TOT_SHIFT, bit_cnt_uni, &tmp_bit_buffer[0], &bit_cnt_range );
/* Coding the delta index sequence */
- ivas_param_mc_range_encoder( seq_delta, sz_seq, hParameterCodingInfo->cum_freq_delta, hParameterCodingInfo->sym_freq_delta, PARAM_MC_RANGE_CODER_TOT_SHIFT, bit_cnt_uni, &tmp_bit_buffer_diff[0], &bit_cnt_range_diff );
+ ivas_param_mc_range_encoder_fx( seq_delta, sz_seq, hParameterCodingInfo->cum_freq_delta, hParameterCodingInfo->sym_freq_delta, PARAM_MC_RANGE_CODER_TOT_SHIFT, bit_cnt_uni, &tmp_bit_buffer_diff[0], &bit_cnt_range_diff );
bit_cnt_range_min = s_min( bit_cnt_range, bit_cnt_range_diff );
@@ -1885,7 +1885,7 @@ static void ivas_param_mc_encode_parameter(
FOR( i = 0; i < sz_seq; ++i )
{
- ivas_param_mc_dec2bin( seq[i], hParameterCodingInfo->uni_bits, &bit_buffer[*( bit_pos ) + bit_pos_tmp] );
+ ivas_param_mc_dec2bin_fx( seq[i], hParameterCodingInfo->uni_bits, &bit_buffer[*( bit_pos ) + bit_pos_tmp] );
bit_pos_tmp = add( bit_pos_tmp, hParameterCodingInfo->uni_bits );
}
*bit_pos = add( *bit_pos, bit_pos_tmp );
@@ -1927,7 +1927,7 @@ static void ivas_param_mc_encode_parameter(
* Decimal to binary routine
*------------------------------------------------------------------------*/
-static void ivas_param_mc_dec2bin(
+static void ivas_param_mc_dec2bin_fx(
const Word16 val, /* i : value to encode */
const Word16 N, /* i : number of bits for encoding the value */
UWord16 bits[PARAM_MC_MAX_BITS] ) /* o : encoded bits buffer */
@@ -1953,7 +1953,7 @@ static void ivas_param_mc_dec2bin(
* Parametric MC Range encoder
*-------------------------------------------------------------------*/
-static void ivas_param_mc_range_encoder(
+static void ivas_param_mc_range_encoder_fx(
const Word16 *seq_in, /* i : input sequence */
const Word16 num_symbols, /* i : Number of symbole to encode */
const UWord16 *cum_freq, /* i : cumulated frequencies */
@@ -1992,10 +1992,10 @@ static void ivas_param_mc_range_encoder(
/* Push range coded bits from byte_buffer to bitstream */
/* 1) Push all complete bytes, one byte at a time */
- FOR( i = 0; i < shr( rc_tot_bits, 3 ); ++i )
+ FOR( i = 0; i < ( rc_tot_bits >> 3 ); ++i )
{
/* use rc_st_enc.byte_buffer */
- bits = &bit_buffer[shl( i, 3 )];
+ bits = &bit_buffer[i << 3];
byte = rc_st_enc.byte_buffer[i];
move16();
@@ -2023,7 +2023,7 @@ static void ivas_param_mc_range_encoder(
{
UWord8 rem_bits = (UWord8) s_and( rc_tot_bits, 7 );
- bits = &bit_buffer[shl( i, 3 )];
+ bits = &bit_buffer[( i << 3 )];
byte = rc_st_enc.byte_buffer[i];
move16();
diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c
index e51703ea359608ca3a18edf3a73ed76816b56a47..61f817b2f0d93edadfe1eb1d366f4afe838afcaf 100644
--- a/lib_enc/ivas_mc_paramupmix_enc.c
+++ b/lib_enc/ivas_mc_paramupmix_enc.c
@@ -80,7 +80,7 @@ static void quantize_pars_fx( const Word32 *v_fx, Word16 exp_v, const Word16 nq,
void ivas_mc_paramupmix_enc_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */
BSTR_ENC_HANDLE hBStr, /* i/o: IVAS Metadata bitstream handle */
- Word32 *data_fx[],
+ Word32 *data_fx[], // st_ivas->q_data_fx
const Word16 input_frame /* i : input frame length */
)
{
@@ -95,8 +95,8 @@ void ivas_mc_paramupmix_enc_fx(
bit_pos = 0;
/* Parameter estimation */
- Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS];
- Word32 betas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS];
+ Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; // exp_alphas
+ Word32 betas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; // exp_betas
Word16 exp_alphas = 31, exp_betas = 31;
move16();
move16();
@@ -126,7 +126,7 @@ void ivas_mc_paramupmix_enc_fx(
*
* Initialize MC ParamUpmix encoder handle
*------------------------------------------------------------------------*/
-ivas_error ivas_mc_paramupmix_enc_open(
+ivas_error ivas_mc_paramupmix_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
)
{
@@ -270,7 +270,7 @@ ivas_error ivas_mc_paramupmix_enc_open(
*
* Close MC Param-Upmix encoder handle
*------------------------------------------------------------------------*/
-void ivas_mc_paramupmix_enc_close(
+void ivas_mc_paramupmix_enc_close_fx(
MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */
const Word32 input_Fs /* i : input sampling rate */
)
@@ -465,12 +465,12 @@ static void huffman_encode_fx(
}
static void quantize_pars_fx(
- const Word32 *v_fx,
+ const Word32 *v_fx, // exp_v
Word16 exp_v,
const Word16 nq,
- const Word32 *data_fx,
+ const Word32 *data_fx, // Q28
Word32 vq[IVAS_MAX_NUM_BANDS],
- Word32 *vdeq_fx,
+ Word32 *vdeq_fx, // exp_vdeq
Word16 *exp_vdeq )
{
Word16 iv, iq, iq0, iq1;
@@ -480,7 +480,7 @@ static void quantize_pars_fx(
iq0 = 0;
iq1 = sub( nq, 1 );
- WHILE( GT_16( sub( iq1, iq0 ), 1 ) )
+ WHILE( ( iq1 - iq0 ) > 1 )
{
iq = shr( add( iq0, iq1 ), 1 );
Word16 cmp_1 = BASOP_Util_Cmp_Mant32Exp( v_fx[iv], exp_v, data_fx[iq], 31 - Q28 );
@@ -527,17 +527,17 @@ static void quantize_pars_fx(
}
static void quantize_alpha_fx(
- const Word32 *alpha_fx,
+ const Word32 *alpha_fx, // 31 - exp_alpha
Word16 exp_alpha,
Word16 *pnq,
Word32 aq[IVAS_MAX_NUM_BANDS],
- Word32 *adeq_fx,
+ Word32 *adeq_fx, // 31 - exp_adeq
Word16 *exp_adeq )
{
Word16 nq;
const Word32 *data_fx;
- nq = ivas_mc_paramupmix_alpha_quant_table_fx.nquant;
+ nq = ivas_mc_paramupmix_alpha_quant_table_fx.nquant; // Q0
move16();
data_fx = ivas_mc_paramupmix_alpha_quant_table_fx.data; // Q28
@@ -566,13 +566,13 @@ static void quantize_beta_fx(
FOR( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ )
{
- quant_table_fx = tables_fx[ivas_param_upmx_mx_qmap[aq[iv]]];
+ quant_table_fx = tables_fx[ivas_param_upmx_mx_qmap[aq[iv]]]; // Q28
iq0 = 0;
move16();
iq1 = sub( quant_table_fx.nquant, 1 );
- WHILE( GT_16( sub( iq1, iq0 ), 1 ) )
+ WHILE( ( ( iq1 - iq0 ) > 1 ) )
{
iq = shr( add( iq0, iq1 ), 1 );
@@ -604,12 +604,12 @@ static void quantize_beta_fx(
IF( EQ_16( cmp_2, negate( 1 ) ) )
{
bq[iv] = iq0;
- bdeq_fx[iv] = quant_table_fx.data[iq0];
+ bdeq_fx[iv] = quant_table_fx.data[iq0]; // Q28
}
ELSE
{
bq[iv] = iq1;
- bdeq_fx[iv] = quant_table_fx.data[iq1];
+ bdeq_fx[iv] = quant_table_fx.data[iq1]; // Q28
}
move16();
move32();
@@ -625,9 +625,9 @@ static void quantize_beta_fx(
static void put_ec_data_fx(
MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix,
const Word16 ch,
- const Word32 pars_fx[IVAS_MAX_NUM_BANDS],
+ const Word32 pars_fx[IVAS_MAX_NUM_BANDS], // Q(31 - exp_paras)
Word16 exp_paras,
- const Word32 alphas_fx[IVAS_MAX_NUM_BANDS],
+ const Word32 alphas_fx[IVAS_MAX_NUM_BANDS], // Q(31 - exp_alphas)
Word16 exp_alphas,
const PAR_TYPE parType,
UWord16 bit_buffer[MC_PARAMUPMIX_MAX_BITS],
@@ -636,8 +636,8 @@ static void put_ec_data_fx(
Word16 nq;
Word32 alphaQuant[IVAS_MAX_NUM_BANDS];
Word32 betaQuant[IVAS_MAX_NUM_BANDS];
- Word32 alphaDequant_fx[IVAS_MAX_NUM_BANDS];
- Word32 betaDequant_fx[IVAS_MAX_NUM_BANDS];
+ Word32 alphaDequant_fx[IVAS_MAX_NUM_BANDS]; // 31 - exp_alphaDequant
+ Word32 betaDequant_fx[IVAS_MAX_NUM_BANDS]; // 31 - exp_betaDequant
Word16 exp_alphaDequant = 31, exp_betaDequant = 31;
@@ -760,12 +760,12 @@ static void ivas_mc_paramupmix_dmx_fx(
static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */
- Word32 *data_f_fx[],
+ Word32 *data_f_fx[], // Q_data_f
Word16 Q_data_f,
- const Word16 input_frame, /* i : Input frame length */
- Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS],
+ const Word16 input_frame, /* i : Input frame length */
+ Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], // 31 - exp_alphas
Word16 *exp_alphas,
- Word32 betas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS],
+ Word32 betas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], // 31 - exp_betas
Word16 *exp_betas )
{
@@ -775,11 +775,11 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
Word32 fr_imagbuffer_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH][L_FRAME48k];
Word32 *p_fr_realbuffer_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH];
Word32 *p_fr_imagbuffer_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH];
- Word32 *cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
- Word32 *cov_dtx_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
+ Word32 *cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; // q_cov_real
+ Word32 *cov_dtx_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; // q_cov_dtx_real
Word16 *q_cov_real[IVAS_SPAR_MAX_CH];
Word16 *q_cov_dtx_real[IVAS_SPAR_MAX_CH];
- Word32 *pp_in_fr_real_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH], *pp_in_fr_imag_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH];
+ Word32 *pp_in_fr_real_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH], *pp_in_fr_imag_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH]; // q_ppIn_FR
Word16 q_ppIn_FR;
Word32 rxy_fx, ryy_fx;
@@ -822,8 +822,8 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
pcm_in_fx[2 * i] = data_f_fx[chan1s[i]];
pcm_in_fx[2 * i + 1] = data_f_fx[chan2s[i]];
- Scale_sig32( pcm_in_fx[2 * i], input_frame, sub( Q14, Q_data_f ) );
- Scale_sig32( pcm_in_fx[2 * i + 1], input_frame, sub( Q14, Q_data_f ) );
+ Scale_sig32( pcm_in_fx[2 * i], input_frame, sub( Q14, Q_data_f ) ); // Q14
+ Scale_sig32( pcm_in_fx[2 * i + 1], input_frame, sub( Q14, Q_data_f ) ); // Q14
}
/*-----------------------------------------------------------------------------------------*
@@ -898,10 +898,10 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
FOR( b = 0; b < MC_PARAMUPMIX_COMBINATIONS; b++ )
{
- pp_in_fr_real_fx[0] = p_fr_realbuffer_fx[2 * b];
- pp_in_fr_imag_fx[0] = p_fr_imagbuffer_fx[2 * b];
- pp_in_fr_real_fx[1] = FR_Real_Mid_fx;
- pp_in_fr_imag_fx[1] = FR_Imag_Mid_fx;
+ pp_in_fr_real_fx[0] = p_fr_realbuffer_fx[2 * b]; // q_ppIn_FR
+ pp_in_fr_imag_fx[0] = p_fr_imagbuffer_fx[2 * b]; // q_ppIn_FR
+ pp_in_fr_real_fx[1] = FR_Real_Mid_fx; // q_ppIn_FR
+ pp_in_fr_imag_fx[1] = FR_Imag_Mid_fx; // q_ppIn_FR
v_add_fx( pp_in_fr_real_fx[0], p_fr_realbuffer_fx[2 * b + 1], pp_in_fr_real_fx[1], L_FRAME48k );
v_add_fx( pp_in_fr_imag_fx[0], p_fr_imagbuffer_fx[2 * b + 1], pp_in_fr_imag_fx[1], L_FRAME48k );
@@ -910,9 +910,9 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
{
FOR( j = 0; j < MC_PARAMUPMIX_NCH; j++ )
{
- cov_real_fx[i][j] = hMCParamUpmix->cov_real_fx[b][i][j];
+ cov_real_fx[i][j] = hMCParamUpmix->cov_real_fx[b][i][j]; // q_cov_real
move32();
- cov_dtx_real_fx[i][j] = hMCParamUpmix->cov_dtx_real_fx[b][i][j];
+ cov_dtx_real_fx[i][j] = hMCParamUpmix->cov_dtx_real_fx[b][i][j]; // q_cov_dtx_real
move32();
}
IF( ( q_cov_real[i] = (Word16 *) malloc( sizeof( Word16 ) * MC_PARAMUPMIX_NCH ) ) == NULL )
@@ -1042,10 +1042,12 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
IF( LT_16( maxbands, IVAS_MAX_NUM_BANDS ) )
{
+#ifndef FIX_1133_IMPROVE_MC_MLD
*exp_alphas = 0;
move16();
*exp_betas = 0;
move16();
+#endif
FOR( b = 0; b < MC_PARAMUPMIX_COMBINATIONS; b++ )
{
FOR( bnd = maxbands; bnd < IVAS_MAX_NUM_BANDS; bnd++ )
diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c
index b2be23e73418436b4c9d7a0bc627ad6cb8ab7bed..34d43d366023159a03d6568fc82bd376e248623d 100644
--- a/lib_enc/ivas_mcmasa_enc.c
+++ b/lib_enc/ivas_mcmasa_enc.c
@@ -191,7 +191,7 @@ ivas_error ivas_mcmasa_enc_open_fx(
{
IF( GE_32( hMcMasa->band_grouping[i], maxBin ) )
{
- hMcMasa->band_grouping[i] = maxBin;
+ hMcMasa->band_grouping[i] = maxBin; // Q0
move16();
hMcMasa->nbands = i;
move16();
@@ -346,7 +346,7 @@ ivas_error ivas_mcmasa_enc_open_fx(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) );
}
- set_zero_fx( hMcMasa->buffer_intensity_real_fx[i][j], hMcMasa->nbands );
+ set_zero_fx( hMcMasa->buffer_intensity_real_fx[i][j], hMcMasa->nbands ); // hMcMasa->buffer_intensity_real_q
}
}
set16_fx( hMcMasa->buffer_intensity_real_q, 31, DIRAC_NO_COL_AVG_DIFF );
@@ -358,7 +358,7 @@ ivas_error ivas_mcmasa_enc_open_fx(
FOR( j = 0; j < hMcMasa->no_col_avg_diff; j++ )
{
- IF( ( hMcMasa->buffer_intensity_real_vert_fx[j] = (Word32 *) malloc( hMcMasa->nbands * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hMcMasa->buffer_intensity_real_vert_fx[j] = (Word32 *) malloc( hMcMasa->nbands * sizeof( Word32 ) ) ) == NULL ) // hMcMasa->buffer_intensity_real_vert_q
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) );
}
@@ -369,7 +369,7 @@ ivas_error ivas_mcmasa_enc_open_fx(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) );
}
- set_zero_fx( hMcMasa->buffer_energy_fx, imult1616( hMcMasa->nbands, hMcMasa->no_col_avg_diff ) );
+ set_zero_fx( hMcMasa->buffer_energy_fx, imult1616( hMcMasa->nbands, hMcMasa->no_col_avg_diff ) ); // hMcMasa->buffer_energy_q
set16_fx( hMcMasa->buffer_intensity_real_vert_q, 31, DIRAC_NO_COL_AVG_DIFF );
set16_fx( hMcMasa->buffer_energy_q, 31, DIRAC_NO_COL_AVG_DIFF );
@@ -402,8 +402,8 @@ ivas_error ivas_mcmasa_enc_open_fx(
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->mc_input_setup, MC_LS_SETUP_5_1_4 ) )
{
- Copy32( ls_azimuth_CICP16_fx, ls_azimuth, sub( nchan_inp, 1 ) );
- Copy32( ls_elevation_CICP16_fx, ls_elevation, sub( nchan_inp, 1 ) );
+ Copy32( ls_azimuth_CICP16_fx, ls_azimuth, sub( nchan_inp, 1 ) ); // Q22
+ Copy32( ls_elevation_CICP16_fx, ls_elevation, sub( nchan_inp, 1 ) ); // Q22
hMcMasa->numHorizontalChannels = 5;
move16();
hMcMasa->isHorizontalSetup = 0;
@@ -411,8 +411,8 @@ ivas_error ivas_mcmasa_enc_open_fx(
}
ELSE
{
- Copy32( ls_azimuth_CICP19_fx, ls_azimuth, sub( nchan_inp, 1 ) );
- Copy32( ls_elevation_CICP19_fx, ls_elevation, sub( nchan_inp, 1 ) );
+ Copy32( ls_azimuth_CICP19_fx, ls_azimuth, sub( nchan_inp, 1 ) ); // Q22
+ Copy32( ls_elevation_CICP19_fx, ls_elevation, sub( nchan_inp, 1 ) ); // Q22
hMcMasa->numHorizontalChannels = 7;
move16();
hMcMasa->isHorizontalSetup = 0;
@@ -421,8 +421,8 @@ ivas_error ivas_mcmasa_enc_open_fx(
IF( hMcMasa->separateChannelEnabled )
{
- Copy32( &ls_azimuth[hMcMasa->separateChannelIndex + 1], &ls_azimuth[hMcMasa->separateChannelIndex], numAnalysisChannels - hMcMasa->separateChannelIndex );
- Copy32( &ls_elevation[hMcMasa->separateChannelIndex + 1], &ls_elevation[hMcMasa->separateChannelIndex], numAnalysisChannels - hMcMasa->separateChannelIndex );
+ Copy32( &ls_azimuth[hMcMasa->separateChannelIndex + 1], &ls_azimuth[hMcMasa->separateChannelIndex], numAnalysisChannels - hMcMasa->separateChannelIndex ); // Q22
+ Copy32( &ls_elevation[hMcMasa->separateChannelIndex + 1], &ls_elevation[hMcMasa->separateChannelIndex], numAnalysisChannels - hMcMasa->separateChannelIndex ); // Q22
hMcMasa->numHorizontalChannels = sub( hMcMasa->numHorizontalChannels, 1 );
move16();
}
@@ -457,12 +457,12 @@ ivas_error ivas_mcmasa_enc_open_fx(
hMcMasa->combineRatios = hMasa->config.mergeRatiosOverSubframes;
move16();
- Copy32( ls_azimuth, hMcMasa->ls_azimuth_fx, numAnalysisChannels );
+ Copy32( ls_azimuth, hMcMasa->ls_azimuth_fx, numAnalysisChannels ); // Q22
FOR( i = 0; i < hMcMasa->numHorizontalChannels; i++ )
{
- left_min = L_shl( 360, 22 );
- right_min = L_negate( L_shl( 360, 22 ) );
+ left_min = ( 360 << 22 );
+ right_min = -( ( 360 << 22 ) );
FOR( j = 0; j < hMcMasa->numHorizontalChannels; j++ )
{
@@ -546,14 +546,14 @@ ivas_error ivas_mcmasa_enc_reconfig_fx(
/* bitrate changed, may need to do something */
/* brute-force solution: close McMASA and re-instantiate with new settings */
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
ivas_mcmasa_enc_close_fx( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs );
/* Determine if to separate some channels from the analysis */
ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->hEncoderConfig->element_mode_init ), ivas_total_brate );
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_masa_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -674,21 +674,21 @@ void ivas_mcmasa_enc_fx(
move16();
UWord8 fixedDistance = 0;
move16();
- Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
+ Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q22
+ Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q22
+ Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q31
+ Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q30
+ Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q31
Word32 separatedChannelSignal[L_FRAME48k];
/* Compute low frequency energy */
computeLfeEnergy_fx( hMcMasa, data_fx, input_frame, q_inp );
/* Sum center and LFE, move surround channels */
- v_add_32( data_fx[2], data_fx[3], data_fx[2], input_frame );
+ v_add_32( data_fx[2], data_fx[3], data_fx[2], input_frame ); // q_inp
FOR( i = 4; i < nchan_inp; i++ )
{
- Copy32( data_fx[i], data_fx[i - 1], input_frame );
+ Copy32( data_fx[i], data_fx[i - 1], input_frame ); // q_inp
}
IF( hMcMasa->separateChannelEnabled )
@@ -698,12 +698,12 @@ void ivas_mcmasa_enc_fx(
move16();
/* Separate the identified channel */
- Copy32( data_fx[i], separatedChannelSignal, input_frame );
+ Copy32( data_fx[i], separatedChannelSignal, input_frame ); // q_inp
/* Move the remaining channels in order to perform the analysis without the separated channel */
FOR( i = ( hMcMasa->separateChannelIndex + 1 ); i < ( nchan_inp - 1 ); i++ )
{
- Copy32( data_fx[i], data_fx[i - 1], input_frame );
+ Copy32( data_fx[i], data_fx[i - 1], input_frame ); // q_inp
}
}
@@ -713,7 +713,7 @@ void ivas_mcmasa_enc_fx(
/* Determine LFE-to-total energy ratio */
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- hMasa->data.lfeToTotalEnergyRatio_fx[i] = BASOP_Util_Divide3232_Scale( hMcMasa->lfeLfEne[i], L_add( EPSILON_FX, hMcMasa->totalLfEne[i] ), &hMasa->data.lfeToTotalEnergyRatio_e[i] );
+ hMasa->data.lfeToTotalEnergyRatio_fx[i] = L_deposit_h( BASOP_Util_Divide3232_Scale( hMcMasa->lfeLfEne[i], L_add( EPSILON_FX, hMcMasa->totalLfEne[i] ), &hMasa->data.lfeToTotalEnergyRatio_e[i] ) ); // hMasa->data.lfeToTotalEnergyRatio_e[i]
hMasa->data.lfeToTotalEnergyRatio_e[i] = add( sub( hMcMasa->lfeLfEne_e[i], hMcMasa->totalLfEne_e[i] ), hMasa->data.lfeToTotalEnergyRatio_e[i] );
move32();
move16();
@@ -735,18 +735,18 @@ void ivas_mcmasa_enc_fx(
move16();
}
- hQMeta->q_direction[0].band_data[i].azimuth_fx[j] = azimuth_m_values_fx[j][i];
+ hQMeta->q_direction[0].band_data[i].azimuth_fx[j] = azimuth_m_values_fx[j][i]; // Q22
move32();
- hQMeta->q_direction[0].band_data[i].elevation_fx[j] = elevation_m_values_fx[j][i];
+ hQMeta->q_direction[0].band_data[i].elevation_fx[j] = elevation_m_values_fx[j][i]; // Q22
move32();
- hQMeta->q_direction[0].band_data[i].energy_ratio_fx[j] = energyRatio_fx[k][i];
+ hQMeta->q_direction[0].band_data[i].energy_ratio_fx[j] = energyRatio_fx[k][i]; // Q30
move32();
hQMeta->q_direction[0].band_data[i].distance[j] = fixedDistance;
move16();
IF( hQMeta->surcoh_band_data != NULL )
{
- hQMeta->q_direction[0].coherence_band_data[i].spread_coherence[j] = (UWord8) round_fx( Mpy_32_32( spreadCoherence_fx[j][i], L_shl( UINT8_MAX, Q16 ) ) ); // Q0
+ hQMeta->q_direction[0].coherence_band_data[i].spread_coherence[j] = (UWord8) round_fx( Mpy_32_32( spreadCoherence_fx[j][i], L_shl( UINT8_MAX, Q17 ) ) ); // Q0
hQMeta->surcoh_band_data[i].surround_coherence[j] = (UWord8) round_fx( Mpy_32_32( surroundingCoherence_fx[k][i], L_shl( UINT8_MAX, Q16 ) ) ); // Q0
move16();
move16();
@@ -761,11 +761,11 @@ void ivas_mcmasa_enc_fx(
{
FOR( j = 0; j < nBlocks; j++ )
{
- hQMeta->q_direction[0].band_data[i].azimuth_fx[j] = 0;
+ hQMeta->q_direction[0].band_data[i].azimuth_fx[j] = 0; // Q22
move32();
- hQMeta->q_direction[0].band_data[i].elevation_fx[j] = 0;
+ hQMeta->q_direction[0].band_data[i].elevation_fx[j] = 0; // Q22
move32();
- hQMeta->q_direction[0].band_data[i].energy_ratio_fx[j] = 0;
+ hQMeta->q_direction[0].band_data[i].energy_ratio_fx[j] = 0; // Q30
move32();
hQMeta->q_direction[0].band_data[i].distance[j] = 0;
move16();
@@ -805,7 +805,7 @@ void ivas_mcmasa_enc_fx(
i = 0;
move16();
test();
- WHILE( LT_16( i, nBlocks ) && hQMeta->all_coherence_zero )
+ WHILE( ( i < nBlocks ) && hQMeta->all_coherence_zero )
{
test();
j = 0;
@@ -814,7 +814,7 @@ void ivas_mcmasa_enc_fx(
WHILE( LT_16( j, nBands ) && hQMeta->all_coherence_zero )
{
test();
- IF( GT_32( spreadCoherence_fx[i][j], MASA_COHERENCE_THRESHOLD_FX ) )
+ IF( GT_32( spreadCoherence_fx[i][j], MASA_COHERENCE_THRESHOLD_FX >> 1 ) )
{
hQMeta->all_coherence_zero = 0;
move16();
@@ -873,11 +873,11 @@ void ivas_mcmasa_enc_fx(
void ivas_mcmasa_param_est_enc_fx(
MCMASA_ENC_HANDLE hMcMasa, /* i : McMASA encoder structure */
MASA_ENCODER_HANDLE hMasa, /* i : MASA encoder structure */
- Word32 *data_f[], /* i : Audio frame in MC-format */
+ Word32 *data_f[], /* i : Audio frame in MC-format Q(q_inp) */
Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated elevation Q22 */
Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated azimuth Q22 */
Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated direct-to-total ratio Q31 */
- Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated spread coherence Q31 */
+ Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated spread coherence Q30 */
Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated surround coherence Q31 */
const Word16 input_frame, /* i : Input frame size */
const Word16 nchan_inp, /* i : Number of input channels */
@@ -904,13 +904,13 @@ void ivas_mcmasa_param_est_enc_fx(
Word32 intensity_even_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS];
- Word32 vertical_diffuseness_vector_fx[MASA_FREQUENCY_BANDS];
- Word32 diffuseness_m_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
+ Word32 vertical_diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; // q_vdv
+ Word32 diffuseness_m_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // diffuseness_e
Word16 diffuseness_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 coherentEnergyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
+ Word32 coherentEnergyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // coherentEnergyRatio_e
Word16 coherentEnergyRatio_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word16 band_m_idx, block_m_idx;
- Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS];
+ Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_diff_e
Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS];
Word32 norm_tmp_fx;
Word16 mrange[2], brange[2];
@@ -918,7 +918,7 @@ void ivas_mcmasa_param_est_enc_fx(
CovarianceMatrix COVls[MASA_FREQUENCY_BANDS];
Word32 absCOVls_fx[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS];
Word16 absCOVls_e[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS];
- Word32 lsEnergy_fx[MCMASA_MAX_ANA_CHANS];
+ Word32 lsEnergy_fx[MCMASA_MAX_ANA_CHANS]; // lsEnergy_e
Word16 lsEnergy_e[MCMASA_MAX_ANA_CHANS];
Word32 lsEnergySum_fx, maxEne_fx;
Word16 lsEnergySum_e = 0, maxEne_e;
@@ -929,15 +929,15 @@ void ivas_mcmasa_param_est_enc_fx(
Word16 i1, i2, i3;
Word32 angleDist_fx, minAngleDist_fx;
Word32 currentAzi_fx;
- Word32 lsEnergyRelation_fx;
+ Word32 lsEnergyRelation_fx; // lsEnergyRelation_e
Word16 lsEnergyRelation_e;
- Word32 tempLsEnergyRelation_fx;
+ Word32 tempLsEnergyRelation_fx; // tempLsEnergyRelation_e
Word16 tempLsEnergyRelation_e;
Word32 stereoness_fx, cohwideness_fx, spreadCoh_fx;
Word32 stereoRatio_fx, cohPanRatio_fx;
Word32 stereoCoh_fx, cohPanCoh_fx, cohRatio_fx;
Word16 stereoCoh_e, cohPanCoh_e, spreadCoh_e, stereoness_e;
- Word32 renormalization_factor_coh_fx[MASA_FREQUENCY_BANDS];
+ Word32 renormalization_factor_coh_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_coh_e
Word16 renormalization_factor_coh_e[MASA_FREQUENCY_BANDS];
Word16 surroundingCoherence_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word16 numAnalysisChannels;
@@ -967,24 +967,24 @@ void ivas_mcmasa_param_est_enc_fx(
IF( hMcMasa->combineRatios )
{
/* Need to initialize renormalization_factors, and variables to be normalized */
- set_zero_fx( renormalization_factor_diff_fx, hMcMasa->nbands );
+ set_zero_fx( renormalization_factor_diff_fx, hMcMasa->nbands ); // renormalization_factor_diff_e
set16_fx( renormalization_factor_diff_e, 0, hMcMasa->nbands );
- set_zero_fx( &diffuseness_m_fx[0][0], MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES );
+ set_zero_fx( &diffuseness_m_fx[0][0], MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES ); // diffuseness_e
set16_fx( &diffuseness_e[0][0], 31, MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES );
- set_zero_fx( renormalization_factor_coh_fx, hMcMasa->nbands );
+ set_zero_fx( renormalization_factor_coh_fx, hMcMasa->nbands ); // renormalization_factor_coh_e
set16_fx( renormalization_factor_coh_e, 31, hMcMasa->nbands );
- set_zero_fx( surroundingCoherence_fx[0], hMcMasa->nbands );
+ set_zero_fx( surroundingCoherence_fx[0], hMcMasa->nbands ); // surroundingCoherence_e
set16_fx( &surroundingCoherence_e[0][0], 31, MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES );
- set_zero_fx( coherentEnergyRatio_fx[0], hMcMasa->nbands );
+ set_zero_fx( coherentEnergyRatio_fx[0], hMcMasa->nbands ); // coherentEnergyRatio_e
set16_fx( &coherentEnergyRatio_e[0][0], 0, MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES );
}
/* Copy current frame to memory for delay compensation */
FOR( i = 0; i < numAnalysisChannels; i++ )
{
- pcm_in[i] = data_f[i];
- p_Chnl_RealBuffer_fx[i] = &Chnl_RealBuffer_fx[i][0];
- p_Chnl_ImagBuffer_fx[i] = &Chnl_ImagBuffer_fx[i][0];
+ pcm_in[i] = data_f[i]; // q_inp
+ p_Chnl_RealBuffer_fx[i] = &Chnl_RealBuffer_fx[i][0]; // q_inp
+ p_Chnl_ImagBuffer_fx[i] = &Chnl_ImagBuffer_fx[i][0]; // q_inp
}
/* initialising energy_fx */
@@ -992,7 +992,7 @@ void ivas_mcmasa_param_est_enc_fx(
{
FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ )
{
- hMasa->data.energy_fx[block_m_idx][i] = 0;
+ hMasa->data.energy_fx[block_m_idx][i] = 0; // hMasa->data.energy_e
move32();
hMasa->data.energy_e[block_m_idx][i] = 31;
move16();
@@ -1024,8 +1024,8 @@ void ivas_mcmasa_param_est_enc_fx(
{
FOR( j = 0; j < numAnalysisChannels; j++ )
{
- set_zero_fx( COVls[i].xr_fx[j], numAnalysisChannels );
- set_zero_fx( COVls[i].xi_fx[j], numAnalysisChannels );
+ set_zero_fx( COVls[i].xr_fx[j], numAnalysisChannels ); // COVls[i].xr_e[j]
+ set_zero_fx( COVls[i].xi_fx[j], numAnalysisChannels ); // COVls[i].xi_e[j]
set16_fx( COVls[i].xr_e[j], 0, numAnalysisChannels );
set16_fx( COVls[i].xi_e[j], 0, numAnalysisChannels );
}
@@ -1094,21 +1094,21 @@ void ivas_mcmasa_param_est_enc_fx(
/* Compute standard FOA */
/* W */
- v_add_32( Chnl_RealBuffer_fx[0], Chnl_RealBuffer_fx[1], Foa_RealBuffer_fx[0], num_freq_bins );
- v_add_32( Chnl_ImagBuffer_fx[0], Chnl_ImagBuffer_fx[1], Foa_ImagBuffer_fx[0], num_freq_bins );
+ v_add_32( Chnl_RealBuffer_fx[0], Chnl_RealBuffer_fx[1], Foa_RealBuffer_fx[0], num_freq_bins ); // inp_q
+ v_add_32( Chnl_ImagBuffer_fx[0], Chnl_ImagBuffer_fx[1], Foa_ImagBuffer_fx[0], num_freq_bins ); // inp_q
FOR( i = 2; i < numAnalysisChannels; i++ )
{
- v_add_32( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins );
- v_add_32( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins );
+ v_add_32( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins ); // inp_q
+ v_add_32( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins ); // inp_q
}
/* Y */
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_ImagBuffer_fx[1], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_ImagBuffer_fx[1], num_freq_bins ); // inp_q
}
/* Z */
@@ -1120,49 +1120,49 @@ void ivas_mcmasa_param_est_enc_fx(
}
ELSE
{
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins ); // inp_q
}
}
/* X */
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins ); // inp_q
}
/* Compute even FOA */
/* W */
- Copy32( Foa_RealBuffer_fx[0], FoaEven_RealBuffer_fx[0], num_freq_bins );
- Copy32( Foa_ImagBuffer_fx[0], FoaEven_ImagBuffer_fx[0], num_freq_bins );
+ Copy32( Foa_RealBuffer_fx[0], FoaEven_RealBuffer_fx[0], num_freq_bins ); // inp_q
+ Copy32( Foa_ImagBuffer_fx[0], FoaEven_ImagBuffer_fx[0], num_freq_bins ); // inp_q
/* Y */
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_RealBuffer_fx[1], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_ImagBuffer_fx[1], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_RealBuffer_fx[1], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_ImagBuffer_fx[1], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_RealBuffer_fx[1], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_ImagBuffer_fx[1], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_RealBuffer_fx[1], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_ImagBuffer_fx[1], num_freq_bins ); // inp_q
}
/* Z (even setups are handled as horizontal) */
- set_zero_fx( FoaEven_RealBuffer_fx[2], num_freq_bins );
- set_zero_fx( FoaEven_ImagBuffer_fx[2], num_freq_bins );
+ set_zero_fx( FoaEven_RealBuffer_fx[2], num_freq_bins ); // inp_q
+ set_zero_fx( FoaEven_ImagBuffer_fx[2], num_freq_bins ); // inp_q
/* X */
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_RealBuffer_fx[3], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_ImagBuffer_fx[3], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_RealBuffer_fx[3], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_ImagBuffer_fx[3], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_RealBuffer_fx[3], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_ImagBuffer_fx[3], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_RealBuffer_fx[3], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_ImagBuffer_fx[3], num_freq_bins ); // inp_q
}
/* Direction estimation */
@@ -1182,7 +1182,12 @@ void ivas_mcmasa_param_est_enc_fx(
num_freq_bands,
direction_vector_fx[0],
direction_vector_fx[1],
- direction_vector_fx[2], c_e );
+ direction_vector_fx[2], c_e
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ NULL
+#endif
+ );
/* Power and intensity estimation for diffuseness */
computeIntensityVector_enc_fx(
@@ -1212,16 +1217,20 @@ void ivas_mcmasa_param_est_enc_fx(
FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
{
/* only real part needed */
- Copy32( intensity_even_real_fx[i], &( hMcMasa->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands );
+ Copy32( intensity_even_real_fx[i], &( hMcMasa->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands ); // hMcMasa->buffer_intensity_real_q
}
hMcMasa->buffer_intensity_real_q[index - 1] = sub( shl( inp_q, 1 ), 31 );
move16();
- Copy32( reference_power_fx[ts], &( hMcMasa->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands );
+ Copy32( reference_power_fx[ts], &( hMcMasa->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); // ref_e
hMcMasa->buffer_energy_q[index - 1] = sub( Q31, ref_e );
move16();
- computeDiffuseness_mdft_fx( hMcMasa->buffer_intensity_real_fx, hMcMasa->buffer_energy_fx, num_freq_bands, hMcMasa->no_col_avg_diff, diffuseness_vector_fx, hMcMasa->buffer_intensity_real_q, hMcMasa->buffer_energy_q, out_exp );
-
+ computeDiffuseness_mdft_fx( hMcMasa->buffer_intensity_real_fx, hMcMasa->buffer_energy_fx, num_freq_bands, hMcMasa->no_col_avg_diff, diffuseness_vector_fx, hMcMasa->buffer_intensity_real_q, hMcMasa->buffer_energy_q, &out_exp[0] );
+ FOR( i = 1; i < num_freq_bands; i++ )
+ {
+ out_exp[i] = out_exp[0];
+ move16();
+ }
/* Compute vertical diffuseness, and tune original diffuseness if needed */
IF( !hMcMasa->isHorizontalSetup )
{
@@ -1243,9 +1252,9 @@ void ivas_mcmasa_param_est_enc_fx(
move32();
IF( hMcMasa->combineRatios )
{
- diffuseness_m_fx[0][band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[0][band_m_idx], diffuseness_e[0][band_m_idx], Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), sub( 31, sub( shl( inp_q, 1 ), 31 ) ), &diffuseness_e[0][band_m_idx] );
+ diffuseness_m_fx[0][band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[0][band_m_idx], diffuseness_e[0][band_m_idx], Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), ref_e, &diffuseness_e[0][band_m_idx] );
move32();
- renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( 31, sub( shl( inp_q, 1 ), 31 ) ), &renormalization_factor_diff_e[band_m_idx] );
+ renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], ref_e, &renormalization_factor_diff_e[band_m_idx] );
move32();
}
ELSE
@@ -1274,8 +1283,6 @@ void ivas_mcmasa_param_est_enc_fx(
}
Word16 div_q = sub( 31, max_e );
ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v_fx, div_q, &azimuth_m_values_fx[block_m_idx][band_m_idx], &elevation_m_values_fx[block_m_idx][band_m_idx] );
- elevation_m_values_fx[block_m_idx][band_m_idx] = L_add( elevation_m_values_fx[block_m_idx][band_m_idx], L_shr( elevation_m_values_fx[block_m_idx][band_m_idx], 5 ) );
- move32();
}
/* Coherence processing */
@@ -1354,7 +1361,7 @@ void ivas_mcmasa_param_est_enc_fx(
}
}
}
- surrCoh_fx = L_shl( surrCoh_fx, surrCoh_e );
+ surrCoh_fx = L_shl( surrCoh_fx, surrCoh_e ); // Q31
surrCoh_e = 0;
move16();
surrCoh_fx = Mult_32_32( surrCoh_fx, surrCoh_fx );
@@ -1458,11 +1465,11 @@ void ivas_mcmasa_param_est_enc_fx(
cohPanCoh_e = tempCoh2_e;
move16();
}
- IF( GT_32( cohPanCoh_fx, ONE_IN_Q30 ) )
- {
- cohPanCoh_fx = ONE_IN_Q30;
- move32();
- }
+ /* IF( GT_32( cohPanCoh_fx, ONE_IN_Q30 ) )
+ {
+ cohPanCoh_fx = ONE_IN_Q30;
+ move32();
+ }*/
cohPanCoh_fx = L_shl_sat( cohPanCoh_fx, cohPanCoh_e ); /*Q31*/
cohPanCoh_e = 0;
move16();
@@ -1524,18 +1531,18 @@ void ivas_mcmasa_param_est_enc_fx(
tempCoh_fx = BASOP_Util_Add_Mant32Exp( stereoness_fx, stereoness_e, L_negate( L_sub( cohwideness_fx, L_shl( 1, sub( 30, cohPanCoh_e ) ) ) ), cohPanCoh_e, &tempCoh_e );
IF( ( tempCoh_e < 0 ) )
{
- tempCoh_fx = L_shl( tempCoh_fx, tempCoh_e );
+ tempCoh_fx = L_shl( tempCoh_fx, tempCoh_e ); // Q31
tempCoh_e = 0;
move16();
}
IF( GT_32( tempCoh_fx, L_shl_sat( 1, sub( 30, tempCoh_e ) ) ) )
{
- spreadCoh_fx = tempCoh_fx;
+ spreadCoh_fx = tempCoh_fx; // tempCoh_e
move32();
}
ELSE
{
- spreadCoh_fx = L_shl_sat( 1, sub( 30, tempCoh_e ) );
+ spreadCoh_fx = L_shl_sat( 1, sub( 30, tempCoh_e ) ); // Q30
}
spreadCoh_e = tempCoh_e;
move16();
@@ -1543,21 +1550,21 @@ void ivas_mcmasa_param_est_enc_fx(
}
IF( ( spreadCoh_e < 0 ) )
{
- spreadCoh_fx = L_shl( spreadCoh_fx, spreadCoh_e );
+ spreadCoh_fx = L_shl( spreadCoh_fx, spreadCoh_e ); // Q31
spreadCoh_e = 0;
move16();
}
IF( ( GE_32( spreadCoh_fx, L_shl_sat( 1, sub( 31, spreadCoh_e ) ) ) ) )
{
- spreadCoh_fx = L_shl_sat( 1, sub( 31, spreadCoh_e ) );
+ spreadCoh_fx = L_shl_sat( 1, sub( 31, spreadCoh_e ) ); // Q31
}
IF( ( spreadCoh_fx <= 0 ) )
{
spreadCoh_fx = 0;
move32();
}
- spreadCoh_fx = L_shl( spreadCoh_fx, spreadCoh_e ); /*Q31*/
+ spreadCoh_fx = L_shl( spreadCoh_fx, sub( spreadCoh_e, 1 ) ); /*Q30*/
/* Compute energy ratio tuning parameter */
lsEnergySum_fx = 0;
@@ -1592,7 +1599,7 @@ void ivas_mcmasa_param_est_enc_fx(
IF( GE_32( cohRatio_fx, ONE_IN_Q31 ) )
{
- cohRatio_fx = ONE_IN_Q31;
+ cohRatio_fx = ONE_IN_Q31; // Q31
move32();
}
IF( cohRatio_fx <= 0 )
@@ -1617,7 +1624,7 @@ void ivas_mcmasa_param_est_enc_fx(
}
/* Store values */
- spreadCoherence_fx[block_m_idx][band_m_idx] = spreadCoh_fx; /*Q31*/
+ spreadCoherence_fx[block_m_idx][band_m_idx] = spreadCoh_fx; /*Q30*/
move32();
IF( hMcMasa->combineRatios )
@@ -1727,6 +1734,7 @@ void ivas_mcmasa_param_est_enc_fx(
void ivas_mcmasa_dmx_modify_fx(
const Word16 n_samples, /* i : input frame length in samples */
Word32 dmx_fx[][L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS )], /* i/o: downmix signal to be transformed into another format Qx*/
+ Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/
const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */
const Word16 n_chnls_dmx_new ) /* i : number of downmix channels in the target format Q0*/
{
@@ -1742,6 +1750,11 @@ void ivas_mcmasa_dmx_modify_fx(
return;
}
+ Word16 Q_min_1_2, Q_min_0_1_2;
+
+ Q_min_1_2 = s_min( dmx_Q[1], dmx_Q[2] );
+ Q_min_0_1_2 = s_min( dmx_Q[1], s_min( dmx_Q[2], dmx_Q[0] ) );
+
IF( EQ_16( n_chnls_dmx_old, 1 ) )
{
/* split mono energy into identical channels */
@@ -1768,14 +1781,24 @@ void ivas_mcmasa_dmx_modify_fx(
IF( EQ_16( n_chnls_dmx_new, 1 ) )
{
/* sum l and r */
- dmx_fx[0][i] = L_add( dmx_fx[1][i], dmx_fx[2][i] );
+ dmx_fx[1][i] = L_shl( dmx_fx[1][i], sub( Q_min_1_2, dmx_Q[1] ) );
+ dmx_fx[2][i] = L_shl( dmx_fx[2][i], sub( Q_min_1_2, dmx_Q[2] ) );
+ move32();
+ move32();
+
+ dmx_fx[0][i] = L_add( dmx_fx[1][i], dmx_fx[2][i] ); // dmx_q
move32();
}
ELSE IF( EQ_16( n_chnls_dmx_new, 3 ) )
{
+ dmx_fx[1][i] = L_shl( dmx_fx[1][i], sub( Q_min_1_2, dmx_Q[1] ) );
+ dmx_fx[2][i] = L_shl( dmx_fx[2][i], sub( Q_min_1_2, dmx_Q[2] ) );
+ move32();
+ move32();
+
dmx_fx[0][i] = L_shr( L_add( dmx_fx[1][i], dmx_fx[2][i] ), 1 );
- dmx_fx[1][i] = L_sub( dmx_fx[1][i], dmx_fx[0][i] );
- dmx_fx[2][i] = L_sub( dmx_fx[2][i], dmx_fx[0][i] );
+ dmx_fx[1][i] = L_sub( dmx_fx[1][i], dmx_fx[0][i] ); // dmx_q
+ dmx_fx[2][i] = L_sub( dmx_fx[2][i], dmx_fx[0][i] ); // dmx_q
move32();
move32();
move32();
@@ -1789,15 +1812,31 @@ void ivas_mcmasa_dmx_modify_fx(
IF( EQ_16( n_chnls_dmx_new, 1 ) )
{
/* sum all channels */
+
+ dmx_fx[0][i] = L_shl( dmx_fx[0][i], sub( Q_min_0_1_2, dmx_Q[1] ) );
+ dmx_fx[1][i] = L_shl( dmx_fx[1][i], sub( Q_min_0_1_2, dmx_Q[1] ) );
+ dmx_fx[2][i] = L_shl( dmx_fx[2][i], sub( Q_min_0_1_2, dmx_Q[2] ) );
+ move32();
+ move32();
+ move32();
+
dmx_fx[0][i] = L_add( L_add( dmx_fx[0][i], dmx_fx[1][i] ), dmx_fx[2][i] );
move32();
}
ELSE IF( EQ_16( n_chnls_dmx_new, 2 ) )
{
+
+ dmx_fx[0][i] = L_shl( dmx_fx[0][i], sub( Q_min_0_1_2, dmx_Q[1] ) );
+ dmx_fx[1][i] = L_shl( dmx_fx[1][i], sub( Q_min_0_1_2, dmx_Q[1] ) );
+ dmx_fx[2][i] = L_shl( dmx_fx[2][i], sub( Q_min_0_1_2, dmx_Q[2] ) );
+ move32();
+ move32();
+ move32();
+
/* mix center into sides */
dmx_fx[0][i] = Mpy_32_16_1( dmx_fx[0][i], INV_SQRT2_FX_Q15 );
- dmx_fx[1][i] = L_add( dmx_fx[1][i], dmx_fx[0][i] );
- dmx_fx[2][i] = L_add( dmx_fx[2][i], dmx_fx[0][i] );
+ dmx_fx[1][i] = L_add( dmx_fx[1][i], dmx_fx[0][i] ); // dmx_q
+ dmx_fx[2][i] = L_add( dmx_fx[2][i], dmx_fx[0][i] ); // dmx_q
move32();
move32();
move32();
@@ -1805,6 +1844,39 @@ void ivas_mcmasa_dmx_modify_fx(
}
}
+ // Q updation for different channels
+
+ IF( EQ_16( n_chnls_dmx_old, 1 ) )
+ {
+ /* split mono energy into identical channels */
+ IF( EQ_16( n_chnls_dmx_new, 2 ) )
+ {
+ dmx_Q[1] = dmx_Q[0];
+ move16();
+ dmx_Q[2] = dmx_Q[0];
+ move16();
+ }
+ }
+ ELSE IF( EQ_16( n_chnls_dmx_old, 2 ) )
+ {
+ dmx_Q[0] = Q_min_1_2;
+ move16();
+ dmx_Q[1] = Q_min_1_2;
+ move16();
+ dmx_Q[2] = Q_min_1_2;
+ move16();
+ }
+ ELSE IF( EQ_16( n_chnls_dmx_old, 3 ) )
+ {
+ dmx_Q[0] = Q_min_0_1_2;
+ move16();
+ dmx_Q[1] = Q_min_0_1_2;
+ move16();
+ dmx_Q[2] = Q_min_0_1_2;
+ move16();
+ }
+
+
return;
}
@@ -1815,7 +1887,7 @@ void ivas_mcmasa_dmx_modify_fx(
/* Compute downmix */
static void ivas_mcmasa_dmx_fx(
MCMASA_ENC_HANDLE hMcMasa,
- Word32 *data_fx[],
+ Word32 *data_fx[], // Q(31 - data_e)
Word16 data_e,
const Word16 input_frame,
const Word16 nchan_transport,
@@ -1873,7 +1945,7 @@ static void ivas_mcmasa_dmx_fx(
FOR( i = 0; i < input_frame; i++ )
{
- data_fx[0][i] = L_add( data_fx[0][i], data_fx[leftIndex][i] );
+ data_fx[0][i] = L_add( data_fx[0][i], data_fx[leftIndex][i] ); // data_e
move32();
data_fx[1][i] = L_add( data_fx[1][i], data_fx[rightIndex][i] );
move32();
@@ -1886,9 +1958,9 @@ static void ivas_mcmasa_dmx_fx(
{
dmx_c_fx = W_extract_h( W_mult_32_32( INV_SQRT2_FX, data_fx[2][i] ) );
move32();
- data_fx[0][i] = L_add( dmx_c_fx, data_fx[0][i] );
+ data_fx[0][i] = L_add( dmx_c_fx, data_fx[0][i] ); // data_e
move32();
- data_fx[1][i] = L_add( dmx_c_fx, data_fx[1][i] );
+ data_fx[1][i] = L_add( dmx_c_fx, data_fx[1][i] ); // data_e
move32();
}
}
@@ -1952,10 +2024,10 @@ static void ivas_mcmasa_dmx_fx(
FOR( j = 0; j < nchan_transport; j++ )
{
- data_fx[j][i] = Mpy_32_32( instEQ_fx, data_fx[j][i] );
+ data_fx[j][i] = Mpy_32_32( instEQ_fx, data_fx[j][i] ); // data_e + instEQ_e - 31
move32();
move32();
- data_fx[j][i] = L_shl( data_fx[j][i], instEQ_e );
+ data_fx[j][i] = L_shl( data_fx[j][i], instEQ_e ); // data_e + 2*instEQ_e - 31
}
}
@@ -2136,8 +2208,8 @@ static void computeVerticalDiffuseness_fx(
return;
}
static void computeEvenLayout_fx(
- const Word32 *ls_azimuth,
- Word32 *ls_azimuth_even,
+ const Word32 *ls_azimuth, // Q22
+ Word32 *ls_azimuth_even, // Q22
const Word16 numChannels )
{
Word16 i;
@@ -2206,7 +2278,7 @@ static void computeEvenLayout_fx(
}
static void computeLfeEnergy_fx(
MCMASA_ENC_HANDLE hMcMasa,
- Word32 *data_fx[],
+ Word32 *data_fx[], // q_inp
const Word16 input_frame,
Word16 q_inp )
{
@@ -2227,8 +2299,8 @@ static void computeLfeEnergy_fx(
IF( hMcMasa->separateChannelEnabled )
{
- Copy32( data_fx[lfeChannelIndex], &( hMcMasa->delay_buffer_lfe[0][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp );
- Copy32( data_fx[separateChannelIndex], &( hMcMasa->delay_buffer_lfe[1][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp );
+ Copy32( data_fx[lfeChannelIndex], &( hMcMasa->delay_buffer_lfe[0][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp ); // q_inp
+ Copy32( data_fx[separateChannelIndex], &( hMcMasa->delay_buffer_lfe[1][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp ); // q_inp
}
ELSE
{
@@ -2250,10 +2322,10 @@ static void computeLfeEnergy_fx(
Word32 delayedInputSignal[2][L_FRAME48k];
Word32 lowPassSignal[2][L_FRAME48k];
- Copy32( &( hMcMasa->delay_buffer_lfe[0][0] ), &( delayedInputSignal[0][0] ), hMcMasa->num_slots_delay_comp * l_ts );
- Copy32( data_fx[lfeChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[0][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts );
- Copy32( &( hMcMasa->delay_buffer_lfe[1][0] ), &( delayedInputSignal[1][0] ), hMcMasa->num_slots_delay_comp * l_ts );
- Copy32( data_fx[separateChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[1][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts );
+ Copy32( &( hMcMasa->delay_buffer_lfe[0][0] ), &( delayedInputSignal[0][0] ), hMcMasa->num_slots_delay_comp * l_ts ); // q_inp
+ Copy32( data_fx[lfeChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[0][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts ); // q_inp
+ Copy32( &( hMcMasa->delay_buffer_lfe[1][0] ), &( delayedInputSignal[1][0] ), hMcMasa->num_slots_delay_comp * l_ts ); // q_inp
+ Copy32( data_fx[separateChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[1][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts ); // q_inp
lowpassCoef = L_shl( div_w( 1, (Word32) hMcMasa->ringBufferSize ), Q6 ); // Q.37(31+6)
@@ -2340,8 +2412,8 @@ static void computeLfeEnergy_fx(
IF( hMcMasa->separateChannelEnabled )
{
- Copy32( data_fx[lfeChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[0][0] ), sub( hMcMasa->num_samples_delay_comp, hMcMasa->offset_comp ) );
- Copy32( data_fx[separateChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[1][0] ), sub( hMcMasa->num_samples_delay_comp, hMcMasa->offset_comp ) );
+ Copy32( data_fx[lfeChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[0][0] ), sub( hMcMasa->num_samples_delay_comp, hMcMasa->offset_comp ) ); // q_in
+ Copy32( data_fx[separateChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[1][0] ), sub( hMcMasa->num_samples_delay_comp, hMcMasa->offset_comp ) ); // q_in
}
return;
diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c
index db8ca015496e2fac9d6fba4059527925140ac78e..f5f179778178b46b5b42d2037eecd9d79b3c7b87 100644
--- a/lib_enc/ivas_mct_core_enc.c
+++ b/lib_enc/ivas_mct_core_enc.c
@@ -78,11 +78,11 @@ static void FindChannelRatio_fx(
IF( NE_32( sts[i]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
// sum_nrg += nrg[i];
- sum_nrg = BASOP_Util_Add_Mant32Exp( sum_nrg, sum_e, nrg[i], nrg_e[i], &sum_e );
+ sum_nrg = BASOP_Util_Add_Mant32Exp( sum_nrg, sum_e, nrg[i], nrg_e[i], &sum_e ); // sum_e
}
}
// sum_nrg = 1.0f / max( sum_nrg, EPSILON );
- sum_nrg = BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_add_sat( sum_nrg, EPSILON_FX ), &inv_e );
+ sum_nrg = BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_add_sat( sum_nrg, EPSILON_FX ), &inv_e ); // inv_e
inv_e = add( inv_e, sub( 0, sum_e ) );
FOR( i = 0; i < nChannels; i++ )
@@ -137,7 +137,7 @@ static void AdjustChannelRatios_fx(
move32();
FOR( i = 0; i < nChannels; i++ )
{
- sum_ratio = L_add( sum_ratio, temp_brs[i] );
+ sum_ratio = L_add( sum_ratio, temp_brs[i] ); // Q0
}
FOR( i = 0; i < nChannels; i++ )
{
@@ -145,7 +145,7 @@ static void AdjustChannelRatios_fx(
// force_ch_bit_ratios[i] = min( BITRATE_MCT_RATIO_RANGE - 1, max( 1, (uint16_t) ( BITRATE_MCT_RATIO_RANGE * cur_ratio + 0.5f ) ) );
cur_ratio = BASOP_Util_Divide3232_Scale( temp_brs[i], sum_ratio, &cur_ratio_e );
- cur_ratio = shr_r( cur_ratio, sub( 11, cur_ratio_e ) );
+ cur_ratio = shr_r( cur_ratio, sub( 11, cur_ratio_e ) ); // Q11
force_ch_bit_ratios[i] = s_min( BITRATE_MCT_RATIO_RANGE - 1, s_max( 1, (UWord16) ( cur_ratio ) ) );
move16();
}
@@ -207,8 +207,8 @@ static void AdjustChannelRatios_fx(
// cur_ratio = chBitRatios[i] / sum_ratio;
// chBitRatios[i] = min( BITRATE_MCT_RATIO_RANGE - 1, max( 1, (uint16_t) ( BITRATE_MCT_RATIO_RANGE * cur_ratio + 0.5f ) ) );
- cur_ratio = div_s( chBitRatios[i], extract_l( sum_ratio ) );
- chBitRatios[i] = s_min( BITRATE_MCT_RATIO_RANGE - 1, s_max( 1, (UWord16) mult_r( BITRATE_MCT_RATIO_RANGE, cur_ratio ) ) );
+ cur_ratio = div_s( chBitRatios[i], extract_l( sum_ratio ) ); // Q15
+ chBitRatios[i] = s_min( BITRATE_MCT_RATIO_RANGE - 1, s_max( 1, (UWord16) mult_r( BITRATE_MCT_RATIO_RANGE, cur_ratio ) ) ); // Q0
move16();
}
@@ -237,12 +237,13 @@ void ivas_mct_core_enc_fx(
Word16 nCPE;
Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */
Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k];
+ Word16 exp_powerSpec[MCT_MAX_CHANNELS][N_MAX + L_MDCT_OVLP_MAX];
Word32 mdst_fx;
Word32 powerSpecMsInv_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */
Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][2];
Word32 *inv_mdst_spectrum_fx[MCT_MAX_CHANNELS][2];
Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][2];
- Word32 *mdst_spectrum_fx[MCT_MAX_CHANNELS][2] = { NULL };
+ Word32 *mdst_spectrum_fx[MCT_MAX_CHANNELS][2] = { { NULL } };
Word32 inv_spectrum_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */
Word16 total_side_bits;
Word16 chBitRatios[MCT_MAX_CHANNELS];
@@ -277,13 +278,15 @@ void ivas_mct_core_enc_fx(
{
set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k );
q_powSpec[ch] = 0;
+ move16();
+ set16_fx( exp_powerSpec[ch], 0, N_MAX + L_MDCT_OVLP_MAX );
}
#endif // MSAN_FIX
FOR( ch = 0; ch < nChannels; ch++ )
{
set32_fx( inv_spectrum_long_fx[ch], 0, L_FRAME48k );
- set32_fx( powerSpec_fx[ch], 0, L_FRAME48k );
- set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k );
+ set32_fx( powerSpec_fx[ch], 0, L_FRAME48k ); // tmp_q_powSpec
+ set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k ); // tmp_q_powSpecInv
inv_mdst_spectrum_fx[ch][0] = powerSpecMsInv_fx[ch][0] = powerSpecMsInv_long_fx[ch];
inv_mdst_spectrum_fx[ch][1] = powerSpecMsInv_fx[ch][1] = powerSpecMsInv_long_fx[ch] + N_TCX10_MAX;
@@ -310,7 +313,7 @@ void ivas_mct_core_enc_fx(
mdst_spectrum_fx[i][0] = hMCT->p_mdst_spectrum_long_fx[cpe_id][ch];
mdst_spectrum_fx[i][1] = hMCT->p_mdst_spectrum_long_fx[cpe_id][ch] + N_TCX10_MAX;
- orig_spectrum_fx[i][0] = hMCT->p_orig_spectrum_long_fx[cpe_id][ch];
+ orig_spectrum_fx[i][0] = hMCT->p_orig_spectrum_long_fx[cpe_id][ch]; // q_origSpec
orig_spectrum_fx[i][1] = hMCT->p_orig_spectrum_long_fx[cpe_id][ch] + N_TCX10_MAX;
sp_aud_decision0[i] = hCPE[cpe_id]->hCoreCoder[0]->sp_aud_decision0;
@@ -436,8 +439,8 @@ void ivas_mct_core_enc_fx(
W_tmp = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] );
tmp_s = sub( W_norm( W_tmp ), 1 );
W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp );
- tmp_q_powSpec[add( i, imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
@@ -496,13 +499,15 @@ void ivas_mct_core_enc_fx(
FOR( i = 1; i < L_subframeTCX - 1; i++ )
{
- mdst_fx = L_sub( L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i - 1], 1 ) ); /* An MDST estimate */
+ mdst_fx = L_sub( L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i - 1], 1 ) ); /* An MDST estimate, Q = q_spec - 1 */
- W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ) );
+ W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ) ); // Q = 2 * (q_spec - 1) + 1
tmp_s = W_norm( W_tmp );
W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp );
- tmp_q_powSpec[add( i, imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+
+ powerSpec_fx[ch][i + ( n * L_subframeTCX )] = W_extract_h( W_tmp );
+ tmp_q_powSpec[i + ( n * L_subframeTCX )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 33 ); // Q = 2 * (q_spec - 1) + 1 + tmp_s - 32
+
move32();
move16();
}
@@ -510,8 +515,8 @@ void ivas_mct_core_enc_fx(
W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1] );
tmp_s = sub( W_norm( W_tmp ), 1 );
W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][add( sub( L_subframeTCX, 1 ), imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp );
- tmp_q_powSpec[add( sub( L_subframeTCX, 1 ), imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ powerSpec_fx[ch][( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ tmp_q_powSpec[( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
}
@@ -543,7 +548,7 @@ void ivas_mct_core_enc_fx(
FOR( i = 0; i < L_subframeTCX; i++ )
{
powerSpecMsInv_fx[ch][n][i] = L_shr( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powSpec[ch] ) );
- powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) );
+ powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) );
move32();
move32();
}
@@ -636,8 +641,9 @@ void ivas_mct_core_enc_fx(
FOR( n = 0; n < nSubframes; n++ )
{
q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );
+ set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powSpec[ch], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
+ ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
st->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec );
st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum );
diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c
index 510f94cf1ea88f4b481431db810af5089f4a2548..4d032cee87854a5cfce40268a34bff9b2700ab87 100644
--- a/lib_enc/ivas_mct_enc.c
+++ b/lib_enc/ivas_mct_enc.c
@@ -58,7 +58,7 @@ static ivas_error ivas_mc_enc_reconfig_fx( Encoder_Struct *st_ivas, const Word16
* Set hMCT handle parameters
*-------------------------------------------------------------------*/
-static void set_mct_enc_params(
+static void set_mct_enc_params_fx(
MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
const Word32 ivas_total_brate, /* i : IVAS total bitrate */
const IVAS_FORMAT ivas_format, /* i : IVAS_format */
@@ -79,7 +79,7 @@ static void set_mct_enc_params(
FOR( n = 0; n < MCT_MAX_CHANNELS; n++ )
{
- set32_fx( hMCT->lastxCorrMatrix_fx[n], 0, MCT_MAX_CHANNELS );
+ set32_fx( hMCT->lastxCorrMatrix_fx[n], 0, MCT_MAX_CHANNELS ); // hMCT->lastxCorrMatrix_e
}
hMCT->lastxCorrMatrix_e = 0;
move16();
@@ -129,7 +129,7 @@ static void map_input_to_cpe_channels_ivas_fx(
FOR( n = 0; n < LFE_CHANNEL - 1; n++ )
{
- pdata[i] = data[n];
+ pdata[i] = data[n]; // Qx
i = add( i, 1 );
}
test();
@@ -138,7 +138,7 @@ static void map_input_to_cpe_channels_ivas_fx(
{
FOR( n = LFE_CHANNEL + 1; n < nchan_transport; n++ )
{
- pdata[i] = data[n];
+ pdata[i] = data[n]; // Qx
i = add( i, 1 );
}
pdata[i] = data[LFE_CHANNEL - 1];
@@ -147,7 +147,7 @@ static void map_input_to_cpe_channels_ivas_fx(
{
FOR( ; n < nchan_transport; n++ )
{
- pdata[i] = data[n];
+ pdata[i] = data[n]; // Qx
i = add( i, 1 );
}
}
@@ -273,37 +273,59 @@ ivas_error ivas_mct_enc_fx(
map_input_to_cpe_channels_ivas_fx( st_ivas, pdata_fx, data_fx );
/* pre-processing */
+ Word16 Q_new_out[MCT_MAX_BLOCKS][CPE_CHANNELS];
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- IF( ( error = ivas_cpe_enc_fx( st_ivas, cpe_id, pdata_fx[cpe_id * CPE_CHANNELS], pdata_fx[cpe_id * CPE_CHANNELS + 1], q_data_fx, input_frame, nb_bits_metadata ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, cpe_id, pdata_fx[cpe_id * CPE_CHANNELS], pdata_fx[cpe_id * CPE_CHANNELS + 1], q_data_fx, input_frame, nb_bits_metadata, Q_new_out[cpe_id] ) ) != IVAS_ERR_OK )
{
return error;
}
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS // Float to Fixed, to be removed
Word16 q_spec = Q31;
Word16 q_origSpec = Q31;
Word16 q_com = Q31, q_com_spec = Q31;
move16();
move16();
+ move16();
+ move16();
Word16 length, ch, nCPE;
- nCPE = ( hMCT->nchan_out_woLFE % 2 ) == 0 ? ( hMCT->nchan_out_woLFE / 2 ) : ( hMCT->nchan_out_woLFE / 2 ) + 1;
+ IF( ( hMCT->nchan_out_woLFE % 2 ) == 0 )
+ {
+ nCPE = idiv1616( hMCT->nchan_out_woLFE, 2 );
+ }
+ ELSE
+ {
+ nCPE = add( idiv1616( hMCT->nchan_out_woLFE, 2 ), 1 );
+ }
- for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
+ IF( EQ_32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
- continue;
+ CONTINUE;
}
- length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV );
- if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE )
+
+ // length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV );
+
+ IF( EQ_16( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode, TCX_20 ) )
{
- length += length / 4;
+ length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX;
+ move16();
}
- for ( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
+ ELSE
+ {
+ length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / NB_DIV
+ }
+
+ IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE )
+ {
+ length = add( length, idiv1616( length, 4 ) );
+ }
+
+ FOR( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
{
IF( hMCT->p_mdst_spectrum_long_fx[cpe_id][ch] )
{
@@ -331,7 +353,7 @@ ivas_error ivas_mct_enc_fx(
}
IF( hMCT->p_orig_spectrum_long_fx[cpe_id][ch] )
{
- Scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][ch], L_FRAME48k, sub( q_origSpec, hMCT->q_orig_spectrum_long_fx[cpe_id][ch] ) );
+ Scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][ch], L_FRAME48k, sub( q_origSpec, hMCT->q_orig_spectrum_long_fx[cpe_id][ch] ) ); // q_origSpec
hMCT->q_orig_spectrum_long_fx[cpe_id][ch] = q_origSpec;
move16();
}
@@ -339,33 +361,39 @@ ivas_error ivas_mct_enc_fx(
}
hMCT->q_orig_spectrum_long_com = q_origSpec;
move16();
- for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV );
- if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE )
+ // length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV );
+
+ IF( EQ_16( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode, TCX_20 ) )
{
- length += length / 4;
+ length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX;
+ move16();
}
- for ( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
+ ELSE
+ {
+ length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / NB_DIV
+ }
+
+ IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE )
+ {
+ length = add( length, idiv1616( length, 4 ) );
+ }
+
+ FOR( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
{
- /*if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum[0] )
- {
- floatToFixed_arrL32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum[k], st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[k], q_spec, length );
- st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0] = sub( Q31, q_spec );
- st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[1] = sub( Q31, q_spec );
- }*/
IF( hMCT->p_mdst_spectrum_long_fx[cpe_id][ch] )
{
- Scale_sig32( &hMCT->p_mdst_spectrum_long_fx[cpe_id][ch][k * N_TCX10_MAX], length, sub( q_spec, hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] ) );
+ Scale_sig32( &hMCT->p_mdst_spectrum_long_fx[cpe_id][ch][k * N_TCX10_MAX], length, sub( q_spec, hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] ) ); // q_spec
hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] = q_spec;
move16();
}
}
}
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
+
Encoder_State *sts_tmp[MCT_MAX_CHANNELS];
Encoder_State *st;
Word16 i;
@@ -386,12 +414,9 @@ ivas_error ivas_mct_enc_fx(
i = add( i, 1 );
CONTINUE;
}
- i++;
+ i = add( i, 1 );
}
}
-#endif
-#endif // 1
-
FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
@@ -416,7 +441,7 @@ ivas_error ivas_mct_enc_fx(
{
length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV );
}
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX, sub( q_spec, sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ) ) );
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX, sub( q_spec, sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ) ) ); // q_spec
st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0] = sub( 31, q_spec );
move16();
@@ -455,10 +480,10 @@ ivas_error ivas_mct_enc_fx(
}
ELSE
{
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[0], length, sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], e_spec ) );
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[0] + length, sub( N_TCX10_MAX, length ), sub( sub( 31, q_spec ), e_spec ) );
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[1], length, sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], e_spec ) );
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[1] + length, sub( N_MAX - N_TCX10_MAX, length ), sub( sub( 31, q_spec ), e_spec ) );
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[0], length, sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], e_spec ) ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0]
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[0] + length, sub( N_TCX10_MAX, length ), sub( sub( 31, q_spec ), e_spec ) ); // 31 - q_spec
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[1], length, sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], e_spec ) ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0]
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[1] + length, sub( N_MAX - N_TCX10_MAX, length ), sub( sub( 31, q_spec ), e_spec ) ); // 31 - q_spec
st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e = e_spec;
move16();
}
@@ -469,45 +494,54 @@ ivas_error ivas_mct_enc_fx(
}
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
q_spec = 31;
move16();
- for ( ch = 0; ch < hMCT->nchan_out_woLFE; ch++ )
+ FOR( ch = 0; ch < hMCT->nchan_out_woLFE; ch++ )
{
- length = sts_tmp[ch]->hTcxEnc->L_frameTCX / ( ( sts_tmp[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV );
- if ( sts_tmp[ch]->last_core == ACELP_CORE )
+ // length = sts_tmp[ch]->hTcxEnc->L_frameTCX / ( ( sts_tmp[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV );
+
+ IF( EQ_16( sts_tmp[ch]->hTcxEnc->tcxMode, TCX_20 ) )
+ {
+ length = sts_tmp[ch]->hTcxEnc->L_frameTCX;
+ move16();
+ }
+ ELSE
+ {
+ length = idiv1616( sts_tmp[ch]->hTcxEnc->L_frameTCX, NB_DIV ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / NB_DIV
+ }
+
+ IF( sts_tmp[ch]->last_core == ACELP_CORE )
{
- length += length / 4;
+ length = add( length, idiv1616( length, 4 ) );
}
}
-#endif
+
/* Spectrum quantization and coding */
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
hCPE = st_ivas->hCPE[cpe_id];
- if ( cpe_id > 0 )
+ IF( cpe_id > 0 )
{
hCPE->hCoreCoder[0]->hBstr->ind_list = st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->ind_list + st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->nb_ind_tot;
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
+
Encoder_State /**st,*/ **sts;
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts = hCPE->hCoreCoder;
st = sts[ch];
}
-#endif
+
ivas_mdct_quant_coder_fx( hCPE, hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 );
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts = hCPE->hCoreCoder;
st = sts[ch];
}
-#endif
+
/* update input samples buffer (as done in ivas_cpe_enc() for other than MCT coding) */
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -515,22 +549,9 @@ ivas_error ivas_mct_enc_fx(
hCPE->hCoreCoder[n]->q_old_inp = hCPE->hCoreCoder[n]->q_inp;
move16();
/* common encoder updates */
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- st = hCPE->hCoreCoder[n];
- IF( st->hTcxEnc != NULL )
- {
- st->hTcxEnc->exp_buf_speech_ltp = 31; /*Q0*/
- }
-#endif
-
- updt_enc_common_ivas_fx( st );
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- IF( st->hTcxEnc != NULL )
- {
- Scale_sig( st->hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->hTcxEnc->exp_buf_speech_ltp );
- }
-#endif
+ st = hCPE->hCoreCoder[n];
+ updt_enc_common_ivas_fx( st, Q_new_out[cpe_id][n] );
}
}
@@ -544,7 +565,7 @@ ivas_error ivas_mct_enc_fx(
* Create, allocate and initialize IVAS encoder MCT handle
*-------------------------------------------------------------------------*/
-ivas_error create_mct_enc(
+ivas_error create_mct_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
@@ -676,7 +697,7 @@ ivas_error create_mct_enc(
* Initializations
*-----------------------------------------------------------------*/
- set_mct_enc_params( hMCT, ivas_total_brate, ivas_format, 1 );
+ set_mct_enc_params_fx( hMCT, ivas_total_brate, ivas_format, 1 );
st_ivas->hMCT = hMCT;
@@ -868,7 +889,7 @@ ivas_error mct_enc_reconfigure_fx(
* Initializations
*-----------------------------------------------------------------*/
- set_mct_enc_params( hMCT, ivas_total_brate, ivas_format, b_nchan_change );
+ set_mct_enc_params_fx( hMCT, ivas_total_brate, ivas_format, b_nchan_change );
return error;
}
@@ -880,7 +901,7 @@ ivas_error mct_enc_reconfigure_fx(
* Close MCT
*-------------------------------------------------------------------------*/
-void ivas_mct_enc_close(
+void ivas_mct_enc_close_fx(
MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */
)
{
@@ -1012,11 +1033,11 @@ static ivas_error ivas_mc_enc_reconfig_fx(
IF( st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
/* create LFE handle */
- IF( NE_32( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1024,12 +1045,12 @@ static ivas_error ivas_mc_enc_reconfig_fx(
/*De-allocate handles for other MC modes*/
ivas_param_mc_enc_close_fx( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs );
- ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_mc_paramupmix_enc_close_fx( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
/* De-allocate McMasa-related handles */
ivas_mcmasa_enc_close_fx( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs );
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
}
@@ -1048,11 +1069,11 @@ static ivas_error ivas_mc_enc_reconfig_fx(
IF( st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
/* create LFE handle */
- IF( NE_32( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1060,7 +1081,7 @@ static ivas_error ivas_mc_enc_reconfig_fx(
IF( NE_32( last_mc_mode, MC_MODE_PARAMUPMIX ) )
{
- IF( NE_32( ( error = ivas_mc_paramupmix_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_mc_paramupmix_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1071,7 +1092,7 @@ static ivas_error ivas_mc_enc_reconfig_fx(
/* De-allocate McMasa-related handles */
ivas_mcmasa_enc_close_fx( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs );
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
}
@@ -1097,17 +1118,17 @@ static ivas_error ivas_mc_enc_reconfig_fx(
IF( st_ivas->hMasa != NULL )
{
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
st_ivas->hMasa = NULL;
}
- ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_mc_paramupmix_enc_close_fx( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
test();
IF( EQ_32( last_mc_mode, MC_MODE_PARAMUPMIX ) && st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
@@ -1116,14 +1137,14 @@ static ivas_error ivas_mc_enc_reconfig_fx(
test();
IF( EQ_32( last_mc_mode, MC_MODE_MCT ) && LE_16( st_ivas->nchan_transport, CPE_CHANNELS ) )
{
- ivas_mct_enc_close( &( st_ivas->hMCT ) );
+ ivas_mct_enc_close_fx( &( st_ivas->hMCT ) );
}
test();
IF( EQ_32( last_mc_mode, MC_MODE_MCT ) && st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
}
ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
@@ -1137,7 +1158,7 @@ static ivas_error ivas_mc_enc_reconfig_fx(
return error;
}
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_masa_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1157,21 +1178,21 @@ static ivas_error ivas_mc_enc_reconfig_fx(
ivas_param_mc_enc_close_fx( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs );
- ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_mc_paramupmix_enc_close_fx( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
test();
IF( EQ_32( last_mc_mode, MC_MODE_PARAMUPMIX ) && st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
IF( EQ_32( last_mc_mode, MC_MODE_MCT ) )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
- ivas_mct_enc_close( &( st_ivas->hMCT ) );
+ ivas_mct_enc_close_fx( &( st_ivas->hMCT ) );
}
}
diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c
index db6d8916cef61c38c87ca125eb505a6af97d9d55..863e39b84022453f6f2e3f4c8c5cf21135c0f598 100644
--- a/lib_enc/ivas_mct_enc_mct.c
+++ b/lib_enc/ivas_mct_enc_mct.c
@@ -959,7 +959,7 @@ void write_mct_bitstream_fx(
p_st[1] = sts[hBlock->ch2];
/*then business as usual for each block pair */
- write_stereo_to_bitstream( hMCT->hBlockData[pair]->hStereoMdct, p_st, hBlock->mask, 1, hBstr );
+ write_stereo_to_bitstream_fx( hMCT->hBlockData[pair]->hStereoMdct, p_st, hBlock->mask, 1, hBstr );
}
hMCT->nBitsMCT = sub( hBstr->nb_bits_tot, nbits_start );
@@ -997,6 +997,7 @@ void mctStereoIGF_enc_fx(
Encoder_State *st;
Word16 singleChEle[MCT_MAX_CHANNELS];
Word16 q_spectrum;
+ Word16 exp_powerSpec[MCT_MAX_CHANNELS][N_MAX + L_MDCT_OVLP_MAX];
L_subframeTCX = 0; /* to avoid compilation warning */
move16();
@@ -1085,13 +1086,8 @@ void mctStereoIGF_enc_fx(
move16();
}
- p_st[0]->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec );
- p_st[1]->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec );
- move16();
- move16();
-
ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask,
- p_orig_spectrum_fx,
+ p_orig_spectrum_fx, q_origSpec, q_origSpec,
p_powerSpec_fx, p_powerSpecMsInv_fx, p_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate );
}
ELSE
@@ -1109,7 +1105,8 @@ void mctStereoIGF_enc_fx(
q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &q_powerSpec[p_ch[ch]], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
+ set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), N_MAX + L_MDCT_OVLP_MAX );
+ ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum );
move16();
@@ -1149,7 +1146,8 @@ void mctStereoIGF_enc_fx(
{
q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powerSpec[ch], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
+ set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX );
+ ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum );
move16();
diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c
index 1313ba4f33bfef47235d49d5bdfc84d7f25df203..5b80bce975908f0c5de924fe66a94550b07d4e20 100644
--- a/lib_enc/ivas_mdct_core_enc.c
+++ b/lib_enc/ivas_mdct_core_enc.c
@@ -81,15 +81,15 @@ static void enc_prm_pre_mdct_fx(
* Header
*--------------------------------------------------------------------------------*/
- writeTCXMode( st, hBstr, MCT_flag, &nbits_start );
+ writeTCXMode_fx( st, hBstr, MCT_flag, &nbits_start );
/* write last_core for core switching and error concealment */
push_next_indice( hBstr, st->last_core != ACELP_CORE, 1 );
- writeTCXWindowing( hBstr, st->hTcxCfg->tcx_curr_overlap_mode );
+ writeTCXWindowing_fx( hBstr, st->hTcxCfg->tcx_curr_overlap_mode );
IF( EQ_16( st->core, TCX_10_CORE ) )
{
- writeTCXWindowing( hBstr, st->hTcxCfg->tcx_last_overlap_mode );
+ writeTCXWindowing_fx( hBstr, st->hTcxCfg->tcx_last_overlap_mode );
}
IF( st->last_core != ACELP_CORE )
@@ -434,13 +434,13 @@ static void kernel_switch_update_transforms_fx(
#ifdef MSAN_FIX
Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), -Q1 ); // Q0 -> Q-1
#else
- Scale_sig( &tcxTimeSignal[n - s], shl( s, 1 ), -Q1 ); // Q0 -> Q-1
+ Scale_sig( &tcxTimeSignal[n - s], shl( s, 1 ), -Q1 ); // Q0 -> Q-1
#endif
wtda_ext_fx( tcxTimeSignal, windowedTimeSignal_16, extract_l( windowedTimeSignal[0] ), extract_l( windowedTimeSignal[1] ), s, kernelType ); // Q-1
#ifdef MSAN_FIX
Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), Q1 ); // Q-1 -> Q0
#else
- Scale_sig( &tcxTimeSignal[n - s], shl( s, 1 ), Q1 ); // Q-1 -> Q0
+ Scale_sig( &tcxTimeSignal[n - s], shl( s, 1 ), Q1 ); // Q-1 -> Q0
#endif
Copy_Scale_sig_16_32_no_sat( windowedTimeSignal_16, windowedTimeSignal, s, Q16 ); // Q15
scale_sig32( windowedTimeSignal, s, -Q8 /* guard bits */ ); // Q7
@@ -905,9 +905,13 @@ static uint16_t enc_ste_pre_mdct(
absMagnR_fx = Sqrt32( L_add( Mpy_32_32( sigR1_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI1_fx[s], sigI1_fx[s] ) ), &absMagnR_e );
corr_fx = L_add( corr_fx, L_add( Mpy_32_32( sigR0_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI0_fx[s], sigI1_fx[s] ) ) ); // q_com*2 - 31
- sumL_fx = L_add( sumL_fx, L_add( sigR0_fx[s], sigI0_fx[s] ) ); // q_com
- sumR_fx = L_add( sumR_fx, L_add( sigR1_fx[s], sigI1_fx[s] ) ); // q_com
-
+#ifdef FIX_ISSUE_1092
+ sumL_fx = L_add( sumL_fx, L_add( L_shr( sigR0_fx[s], 1 ), L_shr( sigI0_fx[s], 1 ) ) ); // q_com -1
+ sumR_fx = L_add( sumR_fx, L_add( L_shr( sigR1_fx[s], 1 ), L_shr( sigI1_fx[s], 1 ) ) ); // q_com - 1
+#else
+ sumL_fx = L_add( sumL_fx, L_add( sigR0_fx[s], sigI0_fx[s] ) ); // q_com
+ sumR_fx = L_add( sumR_fx, L_add( sigR1_fx[s], sigI1_fx[s] ) ); // q_com
+#endif
sumMagnL_fx = BASOP_Util_Add_Mant32Exp( sumMagnL_fx, sumMagnL_e, absMagnL_fx, absMagnL_e, &sumMagnL_e );
sumMagnR_fx = BASOP_Util_Add_Mant32Exp( sumMagnR_fx, sumMagnR_e, absMagnR_fx, absMagnR_e, &sumMagnR_e );
sumPrdLR_fx = BASOP_Util_Add_Mant32Exp( sumPrdLR_fx, sumPrdLR_e, Mpy_32_32( absMagnL_fx, absMagnR_fx ), add( absMagnL_e, absMagnR_e ), &sumPrdLR_e );
@@ -919,8 +923,11 @@ static uint16_t enc_ste_pre_mdct(
temp1 = L_shl( preproLen, x1 );
corr_fx = Mpy_32_32( corr_fx, temp1 );
x1 = sub( 62, add( shl( *q_com, 1 ), x1 ) );
+#ifdef FIX_ISSUE_1092
+ corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, shl( sub( *q_com, 1 ), 1 ) ), &x1 );
+#else
corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, shl( *q_com, 1 ) ), &x1 );
-
+#endif
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( corr_fx, x1, -maxSqrValue_fx, 52 ), -1 ) )
{
diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c
index 750db361656d286e532e28ff776d6362bbae1646..bf87179a3766c474821a04b040c385f17b036d38 100644
--- a/lib_enc/ivas_omasa_enc.c
+++ b/lib_enc/ivas_omasa_enc.c
@@ -1115,7 +1115,12 @@ static void ivas_omasa_param_est_enc_fx(
{
q = q_data;
move16();
- cldfbAnalysis_ts_fx_fixed_q( &( data[i][l_ts * ts] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &q ); /*q_data-5*/
+#if 0
+ scale_sig32( hOMasa->cldfbAnaEnc[i]->cldfb_state_fx, hOMasa->cldfbAnaEnc[i]->cldfb_state_length, sub( q, hOMasa->cldfbAnaEnc[i]->Q_cldfb_state ) );
+ hOMasa->cldfbAnaEnc[i]->Q_cldfb_state = q;
+ move16();
+#endif
+ cldfbAnalysis_ts_fx_var_q( &( data[i][l_ts * ts] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &q ); /*q_data-5*/
norm_buff = s_min( norm_buff, L_norm_arr( Chnl_RealBuffer_fx[i], 60 ) );
norm_buff = s_min( norm_buff, L_norm_arr( Chnl_ImagBuffer_fx[i], 60 ) );
}
@@ -1197,7 +1202,12 @@ static void ivas_omasa_param_est_enc_fx(
computeIntensityVector_enc_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, guard_bits );
intensity_real_e = sub( add( 62, guard_bits ), shl( q, 1 ) );
- computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], intensity_real_e );
+ computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], intensity_real_e
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ NULL
+#endif
+ );
/* Power estimation for diffuseness */
@@ -1222,17 +1232,20 @@ static void ivas_omasa_param_est_enc_fx(
FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ )
{
- norm_tmp_fx = Mpy_32_32( reference_power_fx[ts][band_m_idx], L_sub( L_shl( 1, q_diffuseness_vector ), diffuseness_vector_fx[band_m_idx] ) ); /*30+(31-ref_exp)-31*/
+ temp_e = norm_l( reference_power_fx[ts][band_m_idx] );
+ reference_power_fx[ts][band_m_idx] = L_shl( reference_power_fx[ts][band_m_idx], temp_e );
+ move32();
+ norm_tmp_fx = Mpy_32_32( reference_power_fx[ts][band_m_idx], L_sub( L_shl( 1, q_diffuseness_vector ), diffuseness_vector_fx[band_m_idx] ) ); /*30+(31-(ref_exp-temp_e))-31*/
- hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hOMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), ref_exp + 2, &hOMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); /*q_diffuseness_vector+(31-ref_exp)-31-1*/
- hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hOMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), ref_exp + 2, &hOMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); /*q_diffuseness_vector+(31-ref_exp)-31-1*/
- hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hOMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), ref_exp + 2, &hOMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); /*q_diffuseness_vector+(31-ref_exp)-31-1*/
+ hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hOMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), sub( add( ref_exp, 2 ), temp_e ), &hOMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); /*hOMasa->direction_vector_e[0][block_m_idx][band_m_idx]*/
+ hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hOMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), sub( add( ref_exp, 2 ), temp_e ), &hOMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); /*hOMasa->direction_vector_e[1][block_m_idx][band_m_idx]*/
+ hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hOMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), sub( add( ref_exp, 2 ), temp_e ), &hOMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); /*hOMasa->direction_vector_e[2][block_m_idx][band_m_idx]*/
move32();
move32();
move32();
- diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], W_extract_l( W_shr( W_mult0_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 30 ) ), ref_exp, &diffuseness_e[band_m_idx] ); /*(30-ref_exp)*/
- renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], ref_exp, &renormalization_factor_diff_e[band_m_idx] );
+ diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], W_extract_l( W_shr( W_mult0_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 30 ) ), sub( ref_exp, temp_e ), &diffuseness_e[band_m_idx] ); /*diffuseness_e[band_m_idx]*/
+ renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( ref_exp, temp_e ), &renormalization_factor_diff_e[band_m_idx] ); /*renormalization_factor_diff_e[band_m_idx]*/
move32();
move32();
}
diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c
index 28218d70d4752d444463a6a490574e85054484ba..df92d4e7687103f42345b74da3115494c4998274 100644
--- a/lib_enc/ivas_qmetadata_enc.c
+++ b/lib_enc/ivas_qmetadata_enc.c
@@ -6542,7 +6542,6 @@ void ivas_omasa_encode_masa_to_total_fx(
Word16 q_idx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS];
Word32 dct_data_tmp[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS];
Word32 dct_data[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS];
- Word16 dct_data_e = 0, dct_data_tmp_e, q_dct_data_e;
Word16 bits_pos, nb_bits;
Word16 n_streams, len_stream, tmp_e;
Word32 L_tmp;
@@ -6558,7 +6557,7 @@ void ivas_omasa_encode_masa_to_total_fx(
{
FOR( j = 0; j < nblocks; j++ )
{
- data[k] = masa_to_total_energy_ratio[j][i];
+ data[k] = L_shr( masa_to_total_energy_ratio[j][i], Q5 );
move32();
k = add( k, 1 );
}
@@ -6571,42 +6570,42 @@ void ivas_omasa_encode_masa_to_total_fx(
SWITCH( len_stream )
{
case 4:
- matrix_product_mant_exp_fx( dct4_fx, 0 /* Q31 */, nblocks, nblocks, 0, data, 1 /* Q30*/, 1, nblocks, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct4_fx, nblocks, nblocks, 0, data, 1, nblocks, 1, dct_data );
n_streams = 1;
len_stream = 4;
move16();
BREAK;
case 5:
- matrix_product_mant_exp_fx( dct5_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, 1, nbands, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct5_fx, nbands, nbands, 0, data, 1, nbands, 1, dct_data );
n_streams = 1;
len_stream = nbands;
move16();
move16();
BREAK;
case 8:
- matrix_product_mant_exp_fx( dct8_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, 1, nbands, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct8_fx, nbands, nbands, 0, data, 1, nbands, 1, dct_data );
n_streams = 1;
len_stream = nbands;
move16();
BREAK;
case 12:
- matrix_product_mant_exp_fx( dct12_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, 1, nbands, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct12_fx, nbands, nbands, 0, data, 1, nbands, 1, dct_data );
n_streams = 1;
len_stream = nbands;
move16();
move16();
BREAK;
case 20:
- matrix_product_mant_exp_fx( dct5_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, nblocks, nbands, 1, dct_data_tmp, &dct_data_e );
- matrix_product_mant_exp_fx( dct_data_tmp, dct_data_e, nbands, nblocks, 0, dct4_fx, 0 /* Q31 */, nblocks, nblocks, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct5_fx, nbands, nbands, 0, data, nblocks, nbands, 1, dct_data_tmp );
+ matrix_product_fx( dct_data_tmp, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 1, dct_data );
n_streams = 1;
len_stream = imult1616( nbands, nblocks );
move16();
move16();
BREAK;
case 32:
- matrix_product_mant_exp_fx( dct8_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, nblocks, nbands, 1, dct_data_tmp, &dct_data_e );
- matrix_product_mant_exp_fx( dct_data_tmp, dct_data_e, nbands, nblocks, 0, dct4_fx, 0 /* Q31 */, nblocks, nblocks, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct8_fx, nbands, nbands, 0, data, nblocks, nbands, 1, dct_data_tmp );
+ matrix_product_fx( dct_data_tmp, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 1, dct_data );
n_streams = nblocks;
len_stream = nbands;
move16();
@@ -6622,7 +6621,7 @@ void ivas_omasa_encode_masa_to_total_fx(
j = imult1616( k, len_stream );
/* quantize with fixed common step */
L_tmp = BASOP_Util_Divide3232_Scale_cadence( dct_data[j], step, &tmp_e );
- tmp_e = add( tmp_e, dct_data_e );
+ tmp_e = add( tmp_e, Q6 );
q_idx[j] = rint_new_fx( L_shr( L_tmp, sub( 15, tmp_e ) ) /* Q16 */ ); // Q0
move16();
@@ -6645,7 +6644,7 @@ void ivas_omasa_encode_masa_to_total_fx(
FOR( i = 1; i < len_stream; i++ )
{
L_tmp = BASOP_Util_Divide3232_Scale_cadence( dct_data[j + i], step, &tmp_e );
- tmp_e = add( tmp_e, dct_data_e );
+ tmp_e = add( tmp_e, Q6 );
q_idx[j + i] = rint_new_fx( L_shr( L_tmp, sub( 15, tmp_e ) ) );
move16();
q_dct_data[j + i] = Mpy_32_16_1( step, shl( q_idx[j + i], 9 ) /* Q9 */ ); // Q25
@@ -6689,50 +6688,38 @@ void ivas_omasa_encode_masa_to_total_fx(
}
}
- q_dct_data_e = 6; // Q25
- move16();
/* inverse DCT2 transform */
SWITCH( len_stream )
{
case 4:
- matrix_product_mant_exp_fx( dct4_fx, 0 /* Q31 */, nblocks, nblocks, 1, q_dct_data, q_dct_data_e, nblocks, 1, 0, dct_data_tmp, &dct_data_tmp_e );
+ matrix_product_q30_fx( dct4_fx, nblocks, nblocks, 1, q_dct_data, nblocks, 1, 0, dct_data_tmp );
Copy32( dct_data_tmp, q_dct_data, nblocks );
- q_dct_data_e = dct_data_tmp_e;
- move16();
BREAK;
case 5:
- matrix_product_mant_exp_fx( dct5_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, 1, 0, dct_data_tmp, &dct_data_tmp_e );
+ matrix_product_q30_fx( dct5_fx, nbands, nbands, 1, q_dct_data, nbands, 1, 0, dct_data_tmp );
Copy32( dct_data_tmp, q_dct_data, nbands );
- q_dct_data_e = dct_data_tmp_e;
- move16();
BREAK;
case 8:
- matrix_product_mant_exp_fx( dct8_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, 1, 0, dct_data_tmp, &dct_data_tmp_e );
+ matrix_product_q30_fx( dct8_fx, nbands, nbands, 1, q_dct_data, nbands, 1, 0, dct_data_tmp );
Copy32( dct_data_tmp, q_dct_data, nbands );
- q_dct_data_e = dct_data_tmp_e;
- move16();
BREAK;
case 12:
- matrix_product_mant_exp_fx( dct12_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, 1, 0, dct_data_tmp, &dct_data_tmp_e );
+ matrix_product_q30_fx( dct12_fx, nbands, nbands, 1, q_dct_data, nbands, 1, 0, dct_data_tmp );
Copy32( dct_data_tmp, q_dct_data, nbands );
- q_dct_data_e = dct_data_tmp_e;
- move16();
BREAK;
case 20:
- matrix_product_mant_exp_fx( dct5_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, nblocks, 0, dct_data_tmp, &dct_data_tmp_e );
- matrix_product_mant_exp_fx( dct_data_tmp, dct_data_tmp_e, nbands, nblocks, 0, dct4_fx, 0 /* Q31 */, nblocks, nblocks, 0, q_dct_data, &q_dct_data_e ); /* reuse of variable*/
+ matrix_product_fx( dct5_fx, nbands, nbands, 1, q_dct_data, nbands, nblocks, 0, dct_data_tmp );
+ matrix_product_q30_fx( dct_data_tmp, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data ); /* reuse of variable*/
BREAK;
case 32:
- matrix_product_mant_exp_fx( dct8_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, nblocks, 0, dct_data_tmp, &dct_data_tmp_e );
- matrix_product_mant_exp_fx( dct_data_tmp, dct_data_tmp_e, nbands, nblocks, 0, dct4_fx, 0 /* Q31 */, nblocks, nblocks, 0, q_dct_data, &q_dct_data_e );
+ matrix_product_fx( dct8_fx, nbands, nbands, 1, q_dct_data, nbands, nblocks, 0, dct_data_tmp );
+ matrix_product_q30_fx( dct_data_tmp, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data );
BREAK;
default:
printf( "Incorrect number of coefficients for OMASA.\n" );
BREAK;
}
- scale_sig32( q_dct_data, MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS, sub( Q30, sub( 31, q_dct_data_e ) ) ); // Scaling to Q30
-
k = 0;
move16();
FOR( i = 0; i < nblocks; i++ )
diff --git a/lib_enc/ivas_qspherical_enc.c b/lib_enc/ivas_qspherical_enc.c
index f0596bab37af46d6d6b18a61349d7678047f8417..4bf3650e60d7be1cd50da97914d95849eef64d1d 100644
--- a/lib_enc/ivas_qspherical_enc.c
+++ b/lib_enc/ivas_qspherical_enc.c
@@ -749,7 +749,7 @@ static Word32 quantize_theta_phi_fx( // Q22
/* Note: (id_th % 2 == 1) must be equal to id_th % 2 */
IF( NE_32( mc_format, MC_LS_SETUP_INVALID ) )
{
- id_ph = quantize_phi_chan_compand_fx( phi, phi_hat, no_phi_loc[id_th], (Word16) GT_32( theta_cb[id_th], MC_MASA_THR_ELEVATION ), mc_format );
+ id_ph = quantize_phi_chan_compand_fx( phi, phi_hat, no_phi_loc[id_th], (Word16) GT_32( L_shr( theta_cb[id_th], Q22 ), MC_MASA_THR_ELEVATION ), mc_format );
*id_phi_remap = id_ph;
move16();
}
diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h
index e859dc5e69e75bc0cf2f39d98479c15b3f753862..501965bfa9d90f3e6f7bb510d1a06704df2407b1 100644
--- a/lib_enc/ivas_rom_enc.h
+++ b/lib_enc/ivas_rom_enc.h
@@ -48,16 +48,16 @@ extern const Word32 unclr_mean_td[];
extern const Word32 unclr_scale_td[];
extern const Word32 unclr_coef_td[];
-extern const int16_t xtalk_isel_td[];
+extern const Word16 xtalk_isel_td[];
extern const Word32 xtalk_mean_td[];
extern const Word32 xtalk_scale_td[];
extern const Word32 xtalk_coef_td[];
-extern const int16_t xtalk_isel_dft[];
+extern const Word16 xtalk_isel_dft[];
extern const Word32 xtalk_mean_dft_q15[];
extern const Word32 xtalk_scale_dft_q15[];
extern const Word32 xtalk_coef_dft_q30[];
-extern const int16_t unclr_isel_dft[];
+extern const Word16 unclr_isel_dft[];
extern const Word32 unclr_mean_dft_Q15[];
extern const Word32 unclr_scale_dft_Q15[];
extern const Word32 unclr_coef_dft_Q28[];
@@ -75,9 +75,8 @@ extern const Word32 icbwe_regressionValuesDFT_fx[];
* DFT stereo ROM tables
*----------------------------------------------------------------------------------*/
-extern const int16_t itd_vad_band_tbl[];
+extern const Word16 itd_vad_band_tbl[];
extern const Word32 ild_q_Q25[16];
-extern const int16_t ild_q[];
extern const Word32 Wn_table_fx[50];
extern const Word16 win_ana_8k_fx[STEREO_DFT_OVL_8k];
@@ -101,12 +100,12 @@ extern const Word32 ari_bit_estimate_s17_LC_fx[RANGE_N_CONTEXT][RANGE_N_SYMBOLS]
/*----------------------------------------------------------------------------------*
* ECLVQ Stereo ROM tables
*----------------------------------------------------------------------------------*/
-extern const int16_t log2_1px_table[65];
+extern const Word16 log2_1px_table[65];
extern const Word32 log2TB_Q31[ECSQ_log2TB_SIZE];
extern const Word16 ECSQ_log2_fact_Q10[1 + ECSQ_SEGMENT_SIZE];
-extern const uint16_t ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT];
-extern const uint16_t *const ECSQ_tab_abs_lsbs[1 + 4];
-extern const uint16_t ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE];
+extern const UWord16 ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT];
+extern const UWord16 *const ECSQ_tab_abs_lsbs[1 + 4];
+extern const UWord16 ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE];
/*----------------------------------------------------------------------------------*
@@ -123,7 +122,7 @@ extern const Word32 Stereo_dmx_wnd_coef_48k_fx[L_FRAME48k];
extern const HUFF_TABLE huff_alpha_table;
extern const HUFF_TABLE huff_beta_table;
-extern const int16_t mc_paramupmix_fb_remix_order[4];
+extern const Word16 mc_paramupmix_fb_remix_order[4];
/*----------------------------------------------------------------------------------*
* ParamMC ROM tables
diff --git a/lib_enc/ivas_rom_enc.c b/lib_enc/ivas_rom_enc_fx.c
similarity index 98%
rename from lib_enc/ivas_rom_enc.c
rename to lib_enc/ivas_rom_enc_fx.c
index 2326c5c8c8822d3e95dd114e3c50445dbc0f7201..e4361b933b537ecf40fe8aaaccb51f6a6b5c9fba 100644
--- a/lib_enc/ivas_rom_enc.c
+++ b/lib_enc/ivas_rom_enc_fx.c
@@ -67,7 +67,7 @@ const Word32 unclr_coef_td[SIZE_UNCLR_ISEL_TD] = /*Q15*/
};
/* UNCLR classifier in DFT stereo: list of selected features */
-const int16_t unclr_isel_dft[SIZE_UNCLR_ISEL_DFT] =
+const Word16 unclr_isel_dft[SIZE_UNCLR_ISEL_DFT] =
{
E_gainILD, E_gainIPD, E_angle_rot, E_g_pred, E_cohSNR, E_d_prodL_prodR, E_sum_xcorr, E_xcorr_itd_value
};
@@ -90,7 +90,7 @@ const Word32 unclr_coef_dft_Q28[SIZE_UNCLR_ISEL_DFT] =
};
/* xtalk clasifier in TD stereo: list of selected features */
-const int16_t xtalk_isel_td[SIZE_XTALK_ISEL_TD] =
+const Word16 xtalk_isel_td[SIZE_XTALK_ISEL_TD] =
{
E_d_clas, E_d_voicing, E_sum_d_LSF, E_d_lepsP_13, E_d_cor_map_sum, E_d_nchar, E_d_non_sta, E_d_sp_div, E_sum_prod, E_tdm_es_em, E_m_corrL_corrR, E_corrEst0, E_corrEst_ncorr, E_corrLagStats0, E_ica_corr_value0, E_diff_corrLM_corrRM, E_tdm_LT_es_em
};
@@ -108,7 +108,7 @@ const Word32 xtalk_coef_td[SIZE_XTALK_ISEL_TD] = /*Q15*/
{
1841, 4353, 3322, -5411, 1061, 2716, -2453, 1046, 45199, -51474, -2431, -2245, 2194, -542, -135853, 99, 18138
};
-const int16_t xtalk_isel_dft[SIZE_XTALK_ISEL_DFT] =
+const Word16 xtalk_isel_dft[SIZE_XTALK_ISEL_DFT] =
{
E_clas, E_gainILD, E_gainIPD, E_angle_rot, E_g_pred, E_d_prodL_prodR, E_sum_xcorr, E_xcorr_itd_value, E_gphat_d_itd2, E_gphat_ratio_m1_m2, E_gphat_m2_m2
};
@@ -127,8 +127,6 @@ const Word32 xtalk_coef_dft_q30[SIZE_XTALK_ISEL_DFT] =
/*----------------------------------------------------------------------------------*
* Stereo IC-BWE ROM tables
*----------------------------------------------------------------------------------*/
-#define FLOAT_2_FIX_Q30(a) ((Word32)(a * 1024.0 * 1024.0 * 1024.0))
-#define FLOAT_2_FIX_Q31(a) ((Word32)(a * 1024.0 * 1024.0 * 1024.0 * 2.0))
/* Q30Value >> Q5 */
const Word32 icbwe_thr_TDM_fx[7] = {-1318855552 >> 5, -1667671424 >> 5, -1072553216 >> 5,
920192448 >> 5, 897910144 >> 5, 936654016 >> 5,
@@ -148,8 +146,8 @@ const Word32 icbwe_regressionValuesDFT_fx[8] = {65221224, 333933696, 1127643648,
* DFT stereo ROM tables
*----------------------------------------------------------------------------------*/
-/* DFT stereo ITD ROM table */
-const int16_t itd_vad_band_tbl[STEREO_DFT_ITD_VAD_BAND_NUM+1] =
+/* DFT stereo ITD ROM table Q0*/
+const Word16 itd_vad_band_tbl[STEREO_DFT_ITD_VAD_BAND_NUM+1] =
{
5, 8, 11, 16, 21, 26, 30, 37, 43, 51, 59,
69, 80, 93, 107, 126, 147, 176, 211, 254, 320
@@ -159,10 +157,6 @@ const Word32 ild_q_Q25[16] =
{
0, 67108864, 134217728, 201326592, 268435456, 335544320, 436207616, 536870912, 637534208, 738197504, 838860800, 1006632960, 1174405120, 1342177280, 1509949440, 1677721600
};
-const int16_t ild_q[16] =
-{
- 0,2,4,6,8,10,13,16,19,22,25,30,35,40,45,50
-};
/* table of values of the analysis window cross-correlation function at 32kHz (stride 8) */
const Word32 Wn_table_fx[50] = /*Q31*/
@@ -176,14 +170,14 @@ const Word32 Wn_table_fx[50] = /*Q31*/
1208316416, 1184339328
};
-
+//Q15
const Word16 win_ana_8k_fx[STEREO_DFT_OVL_8k] = {
3471, 6011, 7759, 9178, 10404, 11497, 12492, 13411, 14268, 15072, 15832, 16554, 17241, 17898, 18527, 19131, 19711, 20271,
20810, 21331, 21834, 22320, 22790, 23245, 23686, 24113, 24526, 24927, 25315, 25691, 26055, 26407, 26749, 27079, 27399,
27708, 28007, 28295, 28574, 28843, 29102, 29352, 29592, 29823, 30045, 30257, 30461, 30656, 30841, 31018, 31186, 31345,
31496, 31638, 31772, 31897, 32013, 32121, 32221, 32312, 32395, 32470, 32536, 32594, 32643, 32684, 32717, 32742, 32759, 32767
};
-
+//Q15
const Word16 win_ana_12k8_fx[STEREO_DFT_OVL_12k8] = {
2744, 4753, 6135, 7259, 8229, 9096, 9887, 10618, 11300, 11943, 12552, 13131, 13685, 14216, 14726, 15218, 15693, 16152,
16598, 17030, 17449, 17857, 18255, 18642, 19019, 19388, 19747, 20098, 20441, 20777, 21105, 21426, 21741, 22048, 22350,
@@ -193,7 +187,7 @@ const Word16 win_ana_12k8_fx[STEREO_DFT_OVL_12k8] = {
31714, 31796, 31874, 31949, 32020, 32088, 32153, 32215, 32273, 32328, 32380, 32429, 32474, 32516, 32555, 32590, 32622,
32652, 32677, 32700, 32719, 32735, 32748, 32758, 32764, 32767
};
-
+//Q15
const Word16 win_ana_16k_fx[STEREO_DFT_OVL_16k] = {
2454, 4251, 5488, 6493, 7361, 8137, 8845, 9500, 10112, 10688, 11234, 11754, 12251, 12729, 13188, 13631, 14059, 14473,
14875, 15266, 15646, 16016, 16377, 16729, 17072, 17408, 17736, 18057, 18372, 18680, 18982, 19278, 19568, 19853, 20133,
@@ -205,7 +199,7 @@ const Word16 win_ana_16k_fx[STEREO_DFT_OVL_16k] = {
32375, 32414, 32452, 32487, 32520, 32551, 32580, 32607, 32632, 32654, 32675, 32693, 32710, 32724, 32737, 32747, 32755,
32762, 32766, 32767
};
-
+//Q15
const Word16 win_ana_32k_fx[STEREO_DFT_OVL_32k] = {
1735, 3006, 3881, 4591, 5206, 5755, 6257, 6720, 7154, 7563, 7951, 8320, 8674, 9013, 9341, 9657, 9962, 10259, 10547,
10827, 11100, 11366, 11626, 11881, 12129, 12373, 12611, 12845, 13075, 13300, 13521, 13739, 13953, 14164, 14371, 14575,
@@ -225,7 +219,7 @@ const Word16 win_ana_32k_fx[STEREO_DFT_OVL_32k] = {
32637, 32649, 32660, 32670, 32680, 32689, 32698, 32706, 32714, 32721, 32728, 32734, 32740, 32745, 32749, 32753, 32757,
32760, 32763, 32765, 32766, 32767, 32767,
};
-
+//Q15
const Word16 win_ana_48k_fx[STEREO_DFT_OVL_MAX] = {
1417, 2454, 3168, 3749, 4251, 4699, 5109, 5488, 5842, 6176, 6493, 6795, 7084, 7361, 7629, 7887, 8137, 8380, 8616, 8845,
9069, 9287, 9500, 9708, 9912, 10112, 10307, 10500, 10688, 10873, 11055, 11234, 11410, 11583, 11754, 11922, 12088, 12251,
@@ -253,6 +247,7 @@ const Word16 win_ana_48k_fx[STEREO_DFT_OVL_MAX] = {
32699, 32705, 32710, 32715, 32720, 32724, 32729, 32733, 32737, 32740, 32744, 32747, 32750, 32753, 32755, 32758, 32760,
32762, 32763, 32765, 32766, 32767, 32767, 32767, 32767
};
+//Q31
const Word32 win_syn_8k_fx[STEREO_DFT_OVL_8k] = {
2552069, 13257920, 28512140, 47194820, 68734296, 92758192, 118992928, 147223104, 177270272, 208980864, 242218768, 276861760, 312796896, 349919776, 388131456,
427338304, 467450272, 508381120, 550047232, 592367232, 635262144, 678654848, 722469312, 766631488, 811068480, 855708672, 900481344, 945317568, 990149120,
@@ -261,7 +256,7 @@ const Word32 win_syn_8k_fx[STEREO_DFT_OVL_8k] = {
1980701440, 2002483840, 2022827776, 2041707136, 2059098624, 2074979712, 2089330176, 2102132224, 2113369344, 2123027840, 2131095296, 2137561472, 2142418176,
2145659392, 2147280896
};
-
+//Q31
const Word32 win_syn_12k8_fx[STEREO_DFT_OVL_12k8] = {
1261002, 6551972, 14094794, 23341214, 34014852, 45938972, 58986220, 73058896, 88077968, 103977504, 120700824, 138198304, 156425504, 175342256, 194911840,
215100336, 235876160, 257209056, 279070880, 301434752, 324274976, 347566784, 371285952, 395409728, 419915296, 444781024, 469985376, 495507360, 521326560,
@@ -273,7 +268,7 @@ const Word32 win_syn_12k8_fx[STEREO_DFT_OVL_12k8] = {
2062192000, 2072117888, 2081447424, 2090175872, 2098299008, 2105812608, 2112713344, 2118997504, 2124662144, 2129704192, 2134121728, 2137912064, 2141073664,
2143604608, 2145504128, 2146770944, 2147404416
};
-
+//Q31
const Word32 win_syn_16k_fx[STEREO_DFT_OVL_16k] = {
902372, 4688386, 10086516, 16705275, 24347740, 32888712, 42238640, 52328808, 63104236, 74519400, 86535432, 99118824, 112239520, 125870888, 139988880, 154570928,
169597088, 185047600, 200904832, 217152048, 233772928, 250752224, 268075536, 285728512, 303697792, 321970304, 340533344, 359374528, 378481760, 397843456,
@@ -287,7 +282,7 @@ const Word32 win_syn_16k_fx[STEREO_DFT_OVL_16k] = {
2092676480, 2099077632, 2105088640, 2110707584, 2115932544, 2120762112, 2125194240, 2129228160, 2132862336, 2136095360, 2138926592, 2141355136, 2143379968,
2145000704, 2146216576, 2147027584, 2147432960
};
-
+//Q31
const Word32 win_syn_32k_fx[STEREO_DFT_OVL_32k] = {
319116, 1657642, 3566755, 5907942, 8612268, 11636355, 14948419, 18525698, 22348862, 26402882, 30674656, 35153448, 39829380, 44694072, 49740016, 54960336, 60348800,
65899616, 71607840, 77468328, 83476984, 89629312, 95921440, 102349712, 108910496, 115600336, 122416448, 129355608, 136415040, 143591712, 150883056, 158286720,
@@ -311,7 +306,7 @@ const Word32 win_syn_32k_fx[STEREO_DFT_OVL_32k] = {
2126240128, 2128257280, 2130174336, 2131991296, 2133708160, 2135324800, 2136840960, 2138256512, 2139571712, 2140785920, 2141899136, 2142911616, 2143823104,
2144633472, 2145342592, 2145950592, 2146457344, 2146862848, 2147166848, 2147369600, 2147470976
};
-
+//Q31
const Word32 win_syn_48k_fx[STEREO_DFT_OVL_MAX] = {
173731, 902372, 1941540, 3216071, 4688386, 6334862, 8138533, 10086516, 12168931, 14377618, 16705275, 19146106, 21695168, 24347740, 27099956, 29947948, 32888712,
35919240, 39036744, 42238640, 45522788, 48886820, 52328808, 55846816, 59439128, 63104236, 66840212, 70645768, 74519400, 78459600, 82465520, 86535432, 90668480,
@@ -345,7 +340,7 @@ const Word32 win_syn_48k_fx[STEREO_DFT_OVL_MAX] = {
2133984512, 2135062400, 2136095360, 2137083776, 2138027648, 2138926592, 2139780992, 2140590464, 2141355136, 2142075008, 2142749952, 2143379968, 2143965184,
2144505344, 2145000704, 2145451008, 2145856256, 2146216576, 2146531840, 2146802304, 2147027584, 2147207680, 2147342720, 2147432960, 2147478016
};
-
+//Q31
const Word32 win_mdct_8k_fx[STEREO_DFT_OVL_8k] = {
24094122, 72270552, 120410264, 168489632, 216483968, 264369408, 312121728, 359716832, 407130912, 454339904, 501320192, 548047936, 594499712, 640652160, 686482048,
731966336, 777081984, 821806336, 866117120, 909991488, 953407808, 996343936, 1038778432, 1080689792, 1122057216, 1162859392, 1203076224, 1242687104, 1281672320,
@@ -360,7 +355,7 @@ const Word32 win_mdct_8k_fx[STEREO_DFT_OVL_8k] = {
*----------------------------------------------------------------------------------*/
/* approximation table for log2(1 + x) in Q10 format, with x in [0, 1] in Q6 format */
-const int16_t log2_1px_table[65] =
+const Word16 log2_1px_table[65] =
{
0, 23, 45, 68, 90, 111, 132, 153, 174, 194, 214, 234, 254, 273, 292, 311,
330, 348, 366, 384, 402, 419, 436, 454, 470, 487, 504, 520, 536, 552, 568, 584,
@@ -376,7 +371,8 @@ const Word16 ECSQ_log2_fact_Q10[1 + ECSQ_SEGMENT_SIZE] =
{
0, 0, 1024, 2647, 4695, 7072, 9719, 12594, 15666
};
-const uint16_t ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] =
+//Q0
+const UWord16 ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] =
{
{ 16384, 15360, 14336, 13312, 12288, 11264, 10240, 9216, 8192, 7168, 6144, 5120, 4096, 3072, 2048, 1024, 0 }, /* un-optimized (reserved) */
{ 16384, 7090, 365, 171, 73, 38, 21, 13, 9, 7, 6, 5, 4, 3, 2, 1, 0 }, /* 34 kbps target SNR */
@@ -386,8 +382,8 @@ const uint16_t ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] =
{ 16384, 6940, 633, 186, 74, 38, 21, 13, 9, 7, 6, 5, 4, 3, 2, 1, 0 }, /* 56 kbps target SNR */
{ 16384, 10548, 1936, 774, 117, 41, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } /* 56 kbps target bits */
};
-
-const uint16_t ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] =
+//Q0
+const UWord16 ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] =
{
{ 16384, 9939, 3659, 1349, 499, 186, 71, 29, 14, 8, 6, 5, 4, 3, 2, 1, 0 }, /* param = 0 */
{ 16384, 12760, 7739, 4694, 2847, 1727, 1048, 636, 386, 234, 142, 86, 52, 32, 20, 12, 0 }, /* param = 1 */
@@ -407,31 +403,32 @@ const uint16_t ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] =
};
/* table for uniform coding of absolute values in {0, +-1} */
-static const uint16_t ECSQ_tab_abs_1bit[1 + 2] =
+//Q0
+static const UWord16 ECSQ_tab_abs_1bit[1 + 2] =
{
16384, 10922, 0
};
/* table for uniform coding of absolute values in {0, +-1, +-2, +-3} */
-static const uint16_t ECSQ_tab_abs_2bit[1 + 4] =
+static const UWord16 ECSQ_tab_abs_2bit[1 + 4] =
{
16384, 14046, 9364, 4682, 0
};
/* table for uniform coding of absolute values in {0, +-1, ..., +-7} */
-static const uint16_t ECSQ_tab_abs_3bit[1 + 8] =
+static const UWord16 ECSQ_tab_abs_3bit[1 + 8] =
{
16384, 15288, 13104, 10920, 8736, 6552, 4368, 2184, 0
};
/* table for uniform coding of absolute values in {0, +-1, ..., +-15} */
-static const uint16_t ECSQ_tab_abs_4bit[1 + 16] =
+static const UWord16 ECSQ_tab_abs_4bit[1 + 16] =
{
16384, 15870, 14812, 13754, 12696, 11638, 10580, 9522, 8464, 7406, 6348, 5290, 4232, 3174, 2116, 1058, 0
};
/* array of tables for uniform coding of absolute values */
-const uint16_t * const ECSQ_tab_abs_lsbs[1 + 4] =
+const UWord16 * const ECSQ_tab_abs_lsbs[1 + 4] =
{
NULL, ECSQ_tab_abs_1bit, ECSQ_tab_abs_2bit, ECSQ_tab_abs_3bit, ECSQ_tab_abs_4bit
};
@@ -747,7 +744,7 @@ const HUFF_TABLE huff_beta_table =
}
};
-const int16_t mc_paramupmix_fb_remix_order[4] = {0, 1, 2, 3};
+const Word16 mc_paramupmix_fb_remix_order[4] = {0, 1, 2, 3};
/*----------------------------------------------------------------------------------*
* ParamMC ROM tables
diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c
index ca56a64077189170ecef21dcb7ec06e953ba7214..d43ed74385f381091a49b835836edf37ec8461fd 100644
--- a/lib_enc/ivas_sce_enc.c
+++ b/lib_enc/ivas_sce_enc.c
@@ -90,21 +90,23 @@ ivas_error ivas_sce_enc_fx(
Word32 fr_bands_fx[1][2 * NB_BANDS]; /* energy in frequency bands */
Word32 lf_E_fx[1][2 * VOIC_BINS]; /* per bin spectrum energy in lf */
- Word16 old_inp_12k8_fx[1][L_INP_12k8]; /* buffer of input signal @ 12k8 Q-1 */
- Word16 old_inp_16k_fx[1][L_INP]; /* buffer of input signal @ 12k8 Q-1 */
- Word16 vad_hover_flag[1]; /* VAD hangover flag */
- Word16 attack_flag[1]; /* attack flag (GSC or TC) */
- Word16 loc_harm[1]; /* harmonicity flag */
- Word16 vad_flag_dtx[1]; /* HE-SAD flag with additional DTX HO */
- Word16 fft_buff_fx[1][2 * L_FFT]; /* FFT buffer */
- Word16 fft_buff_fx_q[1]; /* FFT buffer */
- Word16 localVAD_HE_SAD[1]; /* local HE SAD */
+ Word16 old_inp_12k8_fx[1][L_INP_12k8]; /* buffer of input signal @ 12k8 Q_new-1 */
+ Word16 old_inp_16k_fx[1][L_INP]; /* buffer of input signal @ 12k8 Q_new-1 */
+ Word16 Q_new[1] = { 0 };
+ Word16 vad_hover_flag[1]; /* VAD hangover flag */
+ Word16 attack_flag[1]; /* attack flag (GSC or TC) */
+ Word16 loc_harm[1]; /* harmonicity flag */
+ Word16 vad_flag_dtx[1]; /* HE-SAD flag with additional DTX HO */
+ Word16 fft_buff_fx[1][2 * L_FFT]; /* FFT buffer */
+ Word16 fft_buff_fx_q[1]; /* FFT buffer */
+ Word16 localVAD_HE_SAD[1]; /* local HE SAD */
SCE_ENC_HANDLE hSCE;
Encoder_State *st;
IVAS_FORMAT ivas_format;
ivas_error error;
Word16 flag_16k_smc;
Word16 q_input; /*stores q for input_fx*/
+ move16(); // Q_new
push_wmops( "ivas_sce_enc" );
@@ -243,19 +245,16 @@ ivas_error ivas_sce_enc_fx(
/*----------------------------------------------------------------*
* Front Pre-processing
*----------------------------------------------------------------*/
- FOR( Word16 i = 0; i < hSCE->hCoreCoder[0]->nb_subfr; i++ )
- {
- Scale_sig( &A_fx[0][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[0][i * ( M + 1 )] ), 2 ) ); // scaling to Q12
- }
set16_fx( old_wsp_fx[0], 0, L_WSP );
q_old_wsp = Q15;
move16();
+ Word16 q_fr_bands[2];
error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0],
&ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0],
realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0],
- fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, 31, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc,
- st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->ivas_total_brate
+ fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc,
+ st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0]
#ifdef DEBUG_MODE_INFO
,
st->id_element
@@ -353,7 +352,7 @@ ivas_error ivas_sce_enc_fx(
Scale_sig( old_wsp_fx[0], L_WSP, sub( e_old_wsp[0], Q16 ) );
e_old_wsp[0] = 16;
move16();
- IF( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8_fx, old_inp_16k_fx, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, &q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, 0, ivas_format, flag_16k_smc ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_core_enc_fx( hSCE, NULL, NULL, 1, old_inp_12k8_fx, old_inp_16k_fx, Q_new, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, &q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, 0, ivas_format, flag_16k_smc ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -431,7 +430,7 @@ ivas_error create_sce_enc_fx(
test();
IF( NE_16( st_ivas->hEncoderConfig->ivas_format, MONO_FORMAT ) && EQ_16( sce_id, sub( st_ivas->nSCE, 1 ) ) )
{
- IF( ( error = ivas_initialize_MD_bstr_enc( &( hSCE->hMetaData ), st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_initialize_MD_bstr_enc_fx( &( hSCE->hMetaData ), st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -522,7 +521,7 @@ ivas_error create_evs_sce_enc(
test();
IF( NE_32( st_ivas->hEncoderConfig->ivas_format, MONO_FORMAT ) && EQ_16( sce_id, sub( st_ivas->nSCE, 1 ) ) )
{
- IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( hSCE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_initialize_MD_bstr_enc_fx( &( hSCE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -644,7 +643,7 @@ void destroy_sce_enc(
}
}
- ivas_destroy_MD_bstr_enc( &( hSCE->hMetaData ) );
+ ivas_destroy_MD_bstr_enc_fx( &( hSCE->hMetaData ) );
free( hSCE );
diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c
index 21c876f565ee698627fd695c125579d7b356bf1d..ca209c66bfb548ad08aef2ebf26a63df125b16b7 100644
--- a/lib_enc/ivas_spar_md_enc.c
+++ b/lib_enc/ivas_spar_md_enc.c
@@ -1231,7 +1231,7 @@ static Word16 ivas_get_huffman_coded_bs_fx(
FOR( j = pred_offset; j < pred_coeff_dim; j++ )
{
- ivas_huffman_encode( &hMdEnc->huff_coeffs.pred_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].pred_index_re[j], &code, &len );
+ ivas_huffman_encode_fx( &hMdEnc->huff_coeffs.pred_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].pred_index_re[j], &code, &len );
IF( GT_16( ( add( hMetaData->nb_bits_tot, len ) ), hMdEnc->spar_md_cfg.max_bits_per_blk ) )
{
return -1;
@@ -1242,7 +1242,7 @@ static Word16 ivas_get_huffman_coded_bs_fx(
Word16 n = imult1616( ndec, sub( ndm, 1 ) );
FOR( j = 0; j < n; j++ )
{
- ivas_huffman_encode( &hMdEnc->huff_coeffs.drct_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].drct_index_re[j], &code, &len );
+ ivas_huffman_encode_fx( &hMdEnc->huff_coeffs.drct_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].drct_index_re[j], &code, &len );
IF( GT_16( ( add( hMetaData->nb_bits_tot, len ) ), hMdEnc->spar_md_cfg.max_bits_per_blk ) )
{
return -1;
@@ -1252,7 +1252,7 @@ static Word16 ivas_get_huffman_coded_bs_fx(
FOR( j = 0; j < ndec; j++ )
{
- ivas_huffman_encode( &hMdEnc->huff_coeffs.decd_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].decd_index_re[j], &code, &len );
+ ivas_huffman_encode_fx( &hMdEnc->huff_coeffs.decd_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].decd_index_re[j], &code, &len );
IF( GT_16( ( add( hMetaData->nb_bits_tot, len ) ), hMdEnc->spar_md_cfg.max_bits_per_blk ) )
{
return -1;
@@ -1393,8 +1393,8 @@ static Word16 ivas_get_arith_coded_bs_fx(
ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, symbol_arr_old_re, pred_cell_dims, PRED_COEFF );
}
- arith_result = ivas_arith_encode_cmplx_cell_array( &hMdEnc->arith_coeffs.pred_arith_re[qsi], &hMdEnc->arith_coeffs.pred_arith_re_diff[qsi], pDo_diff, nB,
- symbol_arr_re, symbol_arr_old_re, pred_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
+ arith_result = ivas_arith_encode_cmplx_cell_array_fx( &hMdEnc->arith_coeffs.pred_arith_re[qsi], &hMdEnc->arith_coeffs.pred_arith_re_diff[qsi], pDo_diff, nB,
+ symbol_arr_re, symbol_arr_old_re, pred_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
move16();
IF( arith_result < 0 )
{
@@ -1431,8 +1431,8 @@ static Word16 ivas_get_arith_coded_bs_fx(
}
- arith_result = ivas_arith_encode_cmplx_cell_array( &hMdEnc->arith_coeffs.drct_arith_re[qsi], &hMdEnc->arith_coeffs.drct_arith_re_diff[qsi], pDo_diff, nB,
- symbol_arr_re, symbol_arr_old_re, drct_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
+ arith_result = ivas_arith_encode_cmplx_cell_array_fx( &hMdEnc->arith_coeffs.drct_arith_re[qsi], &hMdEnc->arith_coeffs.drct_arith_re_diff[qsi], pDo_diff, nB,
+ symbol_arr_re, symbol_arr_old_re, drct_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
move16();
IF( arith_result < 0 )
@@ -1447,8 +1447,8 @@ static Word16 ivas_get_arith_coded_bs_fx(
ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decd_cell_dims, DECD_COEFF );
}
- arith_result = ivas_arith_encode_cmplx_cell_array( &hMdEnc->arith_coeffs.decd_arith_re[qsi], &hMdEnc->arith_coeffs.decd_arith_re_diff[qsi], pDo_diff, nB,
- symbol_arr_re, symbol_arr_old_re, decd_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
+ arith_result = ivas_arith_encode_cmplx_cell_array_fx( &hMdEnc->arith_coeffs.decd_arith_re[qsi], &hMdEnc->arith_coeffs.decd_arith_re_diff[qsi], pDo_diff, nB,
+ symbol_arr_re, symbol_arr_old_re, decd_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
move16();
IF( arith_result < 0 )
diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h
index e9b06d77df8844c24b5fc3cffad5f54006ebbbbc..5e661f0f43cdd6bc92227ce3235bc1e877c7658c 100644
--- a/lib_enc/ivas_stat_enc.h
+++ b/lib_enc/ivas_stat_enc.h
@@ -85,9 +85,14 @@ typedef struct stereo_itd_data_struct
Word16 prev_sum_nrg_L_lb_fx_e;
Word32 prev_xcorr_lb_fx[STEREO_DFT_XCORR_LB_MAX];
Word16 prev_xcorr_lb_fx_e;
+#ifdef FIX_ISSUE_1092
+ Word32 E_band_n_fx[STEREO_DFT_ITD_VAD_BAND_NUM]; /*E_band_n_exp*/
+ Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM];
+#else
Word32 E_band_n_fx[STEREO_DFT_ITD_VAD_BAND_NUM]; /*Q0*/
+#endif
Word32 xcorr_smooth_fx[STEREO_DFT_N_32k_ENC];
- Word16 xcorr_smooth_fx_e;
+ Word16 xcorr_smooth_fx_e[STEREO_DFT_N_32k_ENC];
Word32 lp_phat_peak_fx; /* low-pass GCC PHAT peak value */ // Q31
// Word16 q_itd;
Word32 deltaItd_fx[STEREO_DFT_ENC_DFT_NB]; // Q16
@@ -116,15 +121,15 @@ typedef struct dft_ana_struct
/* State of the range encoder */
typedef struct
{
- uint32_t rc_low;
- uint32_t rc_range;
- int16_t rc_cache;
- int16_t rc_carry;
- int16_t rc_carry_count;
+ UWord32 rc_low;
+ UWord32 rc_range;
+ Word16 rc_cache;
+ Word16 rc_carry;
+ Word16 rc_carry_count;
- uint8_t byte_buffer[RANGE_UNI_BUFFER_BYTES_MAX];
- int16_t byte_count;
- int16_t last_byte_bit_count;
+ UWord8 byte_buffer[RANGE_UNI_BUFFER_BYTES_MAX];
+ Word16 byte_count;
+ Word16 last_byte_bit_count;
} RangeUniEncState;
@@ -272,7 +277,7 @@ typedef struct stereo_dft_enc_data_struct
const Word16 *dft_trigo_16k_fx;
const Word16 *dft_trigo_32k_fx;
- Word32 output_mem_res_8k_fx[STEREO_DFT_OVL_8k]; // Q16
+ Word32 output_mem_res_8k_fx[STEREO_DFT_OVL_8k]; // Q15
Word32 res_cod_NRG_M_fx[STEREO_DFT_BAND_MAX]; // Q(31 - res_cod_NRG_M_fx_e[])
Word16 res_cod_NRG_M_fx_e[STEREO_DFT_BAND_MAX];
@@ -289,11 +294,11 @@ typedef struct stereo_dft_enc_data_struct
Word16 past_dot_prod_real_fx_e[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX];
Word32 past_dot_prod_imag_fx[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX]; // Q(31 - past_dot_prod_imag_fx_e[])
Word16 past_dot_prod_imag_fx_e[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX];
- Word32 output_mem_dmx_fx[STEREO_DFT_OVL_MAX]; // Q16
- Word32 output_mem_dmx_12k8_fx[STEREO_DFT_OVL_12k8]; // Q16
- Word32 output_mem_dmx_16k_fx[STEREO_DFT_OVL_16k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q16
- Word32 output_mem_dmx_32k_fx[STEREO_DFT_OVL_32k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q16
- Word32 output_mem_dmx_16k_shb_fx[STEREO_DFT_OVL_16k]; // Q16
+ Word32 output_mem_dmx_fx[STEREO_DFT_OVL_MAX]; // Q15
+ Word32 output_mem_dmx_12k8_fx[STEREO_DFT_OVL_12k8]; // Q15
+ Word32 output_mem_dmx_16k_fx[STEREO_DFT_OVL_16k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q15
+ Word32 output_mem_dmx_32k_fx[STEREO_DFT_OVL_32k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q15
+ Word32 output_mem_dmx_16k_shb_fx[STEREO_DFT_OVL_16k]; // Q15
Word16 input_mem_itd_fx[CPE_CHANNELS][STEREO_DFT_OVL_MAX];
Word16 q_input_mem_itd[CPE_CHANNELS];
Word32 gipd_fx[STEREO_DFT_ENC_DFT_NB]; // Q13
@@ -313,23 +318,23 @@ typedef struct stereo_mdct_enc_data_structure
STEREO_MDCT_BAND_PARAMETERS stbParamsTCX20afterACELP; /* stereo frequency band parameters for transition frames */
/* only intraframe */
- int16_t mdct_stereo_mode[2]; /* mdct stereo mode: LR, MS, band-wise MS */
+ Word16 mdct_stereo_mode[2]; /* mdct stereo mode: LR, MS, band-wise MS */
#ifdef DEBUGGING
- int16_t mdct_stereo_mode_cmdl; /* MDCT stereo mode from command-line */
- int16_t fDualMono; /* force dual mono in MDCT stereo mode */
- int16_t fMSstereo; /* force full-band MS in MDCT stereo mode */
+ Word16 mdct_stereo_mode_cmdl; /* MDCT stereo mode from command-line */
+ Word16 fDualMono; /* force dual mono in MDCT stereo mode */
+ Word16 fMSstereo; /* force full-band MS in MDCT stereo mode */
#endif
- int16_t global_ild[2]; /* Quantized ILD for the whole spectrum */
- int16_t split_ratio; /* Ratio of bitrate (1 to 7), split_ratio = 8 * 1st chn bitrate / (1st + 2nd chn bitrate) */
+ Word16 global_ild[2]; /* Quantized ILD for the whole spectrum */
+ Word16 split_ratio; /* Ratio of bitrate (1 to 7), split_ratio = 8 * 1st chn bitrate / (1st + 2nd chn bitrate) */
- int16_t IGFStereoMode[2]; /* MDCT stereo mode for IGF */
+ Word16 IGFStereoMode[2]; /* MDCT stereo mode for IGF */
ITD_DATA_HANDLE hItd;
DFT_ANA_HANDLE hDft_ana;
- int16_t sw_uncorr;
+ Word16 sw_uncorr;
- int16_t isSBAStereoMode;
+ Word16 isSBAStereoMode;
} STEREO_MDCT_ENC_DATA, *STEREO_MDCT_ENC_DATA_HANDLE;
@@ -395,17 +400,16 @@ typedef struct stereo_td_enc_data_structure
Word16 tdm_SM_modi_flag; /* Flag that indicates to modify ratio */
Word16 tdm_SM_reset_flag; /* Flag that indicates to reset the parameters for SM mode */
- Word16 tdm_FD2LRTD_SW_cnt; /* Count the number of frames following a FD to LRTD switching */
- Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */
- Word16 prev_fr_LRTD_TD_dec; /* At the beginning of a frame, contains the previous LRTD decision that might have been modified during last frame */
- Word16 tdm_inst_ratio_idx; /* Instantaneous correlation ratio index */
- Word16 tdm_last_inst_ratio_idx; /* previous frame instantaneous correlation ratio index */
- Word16 tdm_vad_hangover_cnt; /* Count the number of frames where hangover_cnt >= 5 in both primary and secondary channel */
- Word16 tdm_ini_frame_cnt; /* Count the number of frame to decide how to evaluate the local VAD of primary and secondary channel */
- Word16 tdm_last_LRTD_frame_cnt; /* Count the number of frame since the last LRTD frame */
- Word16 tdm_last_LRTD_PriCh_cnt; /* Count the number of frame since the primary channel changed */
- Word16 flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */
- // Word32 tdm_Pri_pitch_buf_fx[NB_SUBFR];
+ Word16 tdm_FD2LRTD_SW_cnt; /* Count the number of frames following a FD to LRTD switching */
+ Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */
+ Word16 prev_fr_LRTD_TD_dec; /* At the beginning of a frame, contains the previous LRTD decision that might have been modified during last frame */
+ Word16 tdm_inst_ratio_idx; /* Instantaneous correlation ratio index */
+ Word16 tdm_last_inst_ratio_idx; /* previous frame instantaneous correlation ratio index */
+ Word16 tdm_vad_hangover_cnt; /* Count the number of frames where hangover_cnt >= 5 in both primary and secondary channel */
+ Word16 tdm_ini_frame_cnt; /* Count the number of frame to decide how to evaluate the local VAD of primary and secondary channel */
+ Word16 tdm_last_LRTD_frame_cnt; /* Count the number of frame since the last LRTD frame */
+ Word16 tdm_last_LRTD_PriCh_cnt; /* Count the number of frame since the primary channel changed */
+ Word16 flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */
Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; // Q6
} STEREO_TD_ENC_DATA, *STEREO_TD_ENC_DATA_HANDLE;
@@ -452,7 +456,6 @@ typedef struct stereo_tca_enc_data_structure
Word32 C_mem_fx[2 * L_NCSHIFT_DS + 1];
Word16 C_mem_exp[2 * L_NCSHIFT_DS + 1];
Word32 E1_mem_fx, E2_mem_fx;
- // Word16 E1_E2_mem_exp;
Word16 E1_mem_exp;
Word16 E2_mem_exp;
Word32 delay_0_mem_fx[MAX_DELAYREGLEN];
@@ -645,7 +648,6 @@ typedef struct front_vad_enc
Word16 buffer_12k8_fx[3 * L_FRAME / 2];
Word16 q_mem_decim;
Word16 q_buffer_12k8;
- // Word32 buffer_12k8_fx[3 * L_FRAME / 2]; /* 12k8 signal buffer */
} FRONT_VAD_ENC, *FRONT_VAD_ENC_HANDLE;
@@ -729,9 +731,9 @@ typedef struct ivas_enc_cov_handler_state_t
{
ivas_cov_smooth_state_t *pCov_state;
ivas_cov_smooth_state_t *pCov_dtx_state;
- int16_t num_bins;
- int16_t prior_dtx_present;
- int16_t prior_var_flag;
+ Word16 num_bins;
+ Word16 prior_dtx_present;
+ Word16 prior_var_flag;
Word32 bb_var_lt_fx[FOA_CHANNELS];
} ivas_enc_cov_handler_state_t;
@@ -785,10 +787,6 @@ typedef struct ivas_spar_enc_lib_t
Word32 core_nominal_brate; /* Nominal bitrate for core coding */
FRONT_VAD_ENC_HANDLE hFrontVad; /* front-VAD handle */
ENC_CORE_HANDLE hCoreCoderVAD; /* core-coder handle for front-VAD module */
-#ifndef EVS_FLOAT_ENC
- // ENC_CORE_HANDLE_FX hCoreCoderVAD_fx; /* core coder handle */
-#endif
-
Word16 spar_reconfig_flag;
Word16 front_vad_flag;
Word16 front_vad_dtx_flag;
@@ -859,23 +857,23 @@ typedef struct ivas_omasa_enc_state_structure
Word16 broadband_energy_prev_e; /*exponent for broadband_energy_prev_fx*/
Word16 fade_out_gain_fx[L_FRAME48k]; /*q15*/
Word16 fade_in_gain_fx[L_FRAME48k]; /*q15*/
- uint8_t nbands;
- uint8_t nCodingBands;
- uint8_t nSubframes;
+ UWord8 nbands;
+ UWord8 nCodingBands;
+ UWord8 nSubframes;
/* CLDFB analysis */
- int16_t num_Cldfb_instances;
+ Word16 num_Cldfb_instances;
HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[MAX_NUM_OBJECTS];
/* DirAC parameter estimation */
- int16_t band_grouping[MASA_FREQUENCY_BANDS + 1];
- int16_t block_grouping[5];
+ Word16 band_grouping[MASA_FREQUENCY_BANDS + 1];
+ Word16 block_grouping[5];
/* diffuseness */
- int16_t index_buffer_intensity;
+ Word16 index_buffer_intensity;
- int16_t prev_selected_object;
- uint8_t changing_object;
+ Word16 prev_selected_object;
+ UWord8 changing_object;
} OMASA_ENC_STATE, *OMASA_ENC_HANDLE;
@@ -912,8 +910,8 @@ typedef struct ivas_masa_dir_align_struct
typedef struct ivas_masa_sync_struct
{
MASA_METADATA_FRAME previous_metadata;
- uint8_t prev_sim_stop;
- uint8_t prev_offset;
+ UWord8 prev_sim_stop;
+ UWord8 prev_offset;
MASA_FRAME_MODE frame_mode;
} MASA_SYNC_STATE, *MASA_SYNC_HANDLE;
@@ -961,15 +959,15 @@ typedef struct ivas_masa_encoder_struct
typedef struct ivas_mcmasa_enc_data_structure
{
- int16_t nbands;
- int16_t nCodingBands;
+ Word16 nbands;
+ Word16 nCodingBands;
/* delay compensation */
Word32 *delay_buffer_lfe[2]; /* Delay buffer for LFE estimation */
- int16_t num_samples_delay_comp;
- int16_t num_slots_delay_comp;
- int16_t offset_comp;
+ Word16 num_samples_delay_comp;
+ Word16 num_slots_delay_comp;
+ Word16 offset_comp;
IVAS_FB_MIXER_HANDLE hFbMixer;
IVAS_FB_MIXER_HANDLE hFbMixerLfe;
@@ -977,12 +975,12 @@ typedef struct ivas_mcmasa_enc_data_structure
/* DirAC parameter estimation */
Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */
Word16 **direction_vector_e[DIRAC_NUM_DIMS]; /* Average direction vector */
- int16_t band_grouping[MASA_FREQUENCY_BANDS + 1];
- int16_t block_grouping[5];
+ Word16 band_grouping[MASA_FREQUENCY_BANDS + 1];
+ Word16 block_grouping[5];
/* diffuseness */
- int16_t index_buffer_intensity;
- int8_t no_col_avg_diff;
+ Word16 index_buffer_intensity;
+ Word8 no_col_avg_diff;
Word32 **buffer_intensity_real_fx[DIRAC_NUM_DIMS];
Word16 buffer_intensity_real_q[DIRAC_NO_COL_AVG_DIFF];
Word32 **buffer_intensity_real_vert_fx;
@@ -993,11 +991,11 @@ typedef struct ivas_mcmasa_enc_data_structure
Word32 chnlToFoaEvenMtx_fx[FOA_CHANNELS][MCMASA_MAX_ANA_CHANS];
Word32 ls_azimuth_fx[MCMASA_MAX_ANA_CHANS];
- int16_t leftNearest[MCMASA_MAX_ANA_CHANS];
- int16_t rightNearest[MCMASA_MAX_ANA_CHANS];
- int16_t numHorizontalChannels;
- uint8_t isHorizontalSetup;
- uint8_t combineRatios;
+ Word16 leftNearest[MCMASA_MAX_ANA_CHANS];
+ Word16 rightNearest[MCMASA_MAX_ANA_CHANS];
+ Word16 numHorizontalChannels;
+ UWord8 isHorizontalSetup;
+ UWord8 combineRatios;
Word32 prevMultiChEne_fx;
Word16 prevMultiChEne_e;
@@ -1007,8 +1005,8 @@ typedef struct ivas_mcmasa_enc_data_structure
Word16 prevEQ_e;
Word16 interpolator_fx[L_FRAME48k];
- uint8_t separateChannelEnabled;
- int16_t separateChannelIndex;
+ UWord8 separateChannelEnabled;
+ Word16 separateChannelIndex;
/* LFE coding */
Word32 lfeLfEne[MAX_PARAM_SPATIAL_SUBFRAMES];
@@ -1016,9 +1014,9 @@ typedef struct ivas_mcmasa_enc_data_structure
Word32 totalLfEne[MAX_PARAM_SPATIAL_SUBFRAMES];
Word16 totalLfEne_e[MAX_PARAM_SPATIAL_SUBFRAMES];
Word32 *lfeAnaRingBuffer[2];
- int16_t ringBufferPointer;
+ Word16 ringBufferPointer;
Word32 lowpassSum[2];
- int16_t ringBufferSize;
+ Word16 ringBufferSize;
} MCMASA_ENC_DATA, *MCMASA_ENC_HANDLE;
@@ -1033,7 +1031,7 @@ typedef struct ivas_osba_enc_data_structure
Word32 interpolator_fx[L_FRAME48k];
Word32 prev_object_dm_gains_fx[MAX_NUM_OBJECTS][MAX_INPUT_CHANNELS];
- int16_t nchan_ism;
+ Word16 nchan_ism;
Word32 *input_data_mem_fx[MAX_NUM_OBJECTS];
} OSBA_ENC_DATA, *OSBA_ENC_HANDLE;
@@ -1101,14 +1099,12 @@ typedef struct cpe_enc_data_structure
STEREO_CNG_ENC_HANDLE hStereoCng; /* Stereo CNG data structure */
FRONT_VAD_ENC_HANDLE hFrontVad[CPE_CHANNELS];
- // float *input_mem[CPE_CHANNELS]; /* input channels buffers memory; needed to be up-to-date for TD->DFT stereo switching */
-
Word32 brate_surplus; /* bitrate surplus for bitrate adaptation in combined format coding */
Word16 *input_mem_fx[CPE_CHANNELS]; /* input channels buffers memory; needed to be up-to-date for TD->DFT stereo switching */
Word16 q_input_mem[CPE_CHANNELS];
#ifdef DEBUGGING
- int16_t stereo_mode_cmdl; /* stereo mode forced from the commaand-line */
+ Word16 stereo_mode_cmdl; /* stereo mode forced from the commaand-line */
#endif
} CPE_ENC_DATA, *CPE_ENC_HANDLE;
@@ -1120,9 +1116,9 @@ typedef struct cpe_enc_data_structure
typedef struct mct_block_data_struct
{
- int16_t isActive;
- int16_t ch1, ch2;
- int16_t mask[2][MAX_SFB];
+ Word16 isActive;
+ Word16 ch1, ch2;
+ Word16 mask[2][MAX_SFB];
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct; /* MDCT stereo data handle */
} MCT_BLOCK_DATA, *MCT_BLOCK_DATA_HANDLE;
@@ -1131,16 +1127,16 @@ typedef struct mct_enc_data_structure
{
BSTR_ENC_HANDLE hBstr; /* bitstream handle for side bits - in MCT, side bits are written at the beginning of the bitstream */
- int16_t nchan_out_woLFE; /* number of active channels within multi-channel configuration */
- int16_t currBlockDataCnt;
- int16_t bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */
+ Word16 nchan_out_woLFE; /* number of active channels within multi-channel configuration */
+ Word16 currBlockDataCnt;
+ Word16 bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */
MCT_BLOCK_DATA_HANDLE hBlockData[MCT_MAX_BLOCKS];
Word32 lastxCorrMatrix_fx[MCT_MAX_CHANNELS][MCT_MAX_CHANNELS];
Word16 lastxCorrMatrix_e;
- int16_t lowE_ch[MCT_MAX_CHANNELS];
- uint16_t mc_global_ild[MCT_MAX_CHANNELS];
- int16_t nBitsMCT; /* number of bits spent on mct side info */
+ Word16 lowE_ch[MCT_MAX_CHANNELS];
+ UWord16 mc_global_ild[MCT_MAX_CHANNELS];
+ Word16 nBitsMCT; /* number of bits spent on mct side info */
/* pointers to local buffers */
Word32 *p_mdst_spectrum_long_fx[MCT_MAX_BLOCKS][CPE_CHANNELS];
Word32 *p_orig_spectrum_long_fx[MCT_MAX_BLOCKS][CPE_CHANNELS];
@@ -1148,11 +1144,11 @@ typedef struct mct_enc_data_structure
Word16 q_orig_spectrum_long_com;
Word16 q_mdst_spectrum_long_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
- int16_t tnsBits[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; /* number of tns bits in the frame */
- int16_t tnsSize[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; /* number of tns parameters put into prm */
- int16_t p_param[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
+ Word16 tnsBits[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; /* number of tns bits in the frame */
+ Word16 tnsSize[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; /* number of tns parameters put into prm */
+ Word16 p_param[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
- int16_t hbr_mct;
+ Word16 hbr_mct;
} MCT_ENC_DATA, *MCT_ENC_HANDLE;
@@ -1169,9 +1165,9 @@ typedef struct stereo_dmx_evs_phase_only_correlation_structure
Word32 peak_width_fx[CPE_CHANNELS]; // Q16
Word32 confidence_fx; // Q31
- int16_t ispeak[CPE_CHANNELS];
- int16_t itdLR[CPE_CHANNELS];
- int16_t shift_limit;
+ Word16 ispeak[CPE_CHANNELS];
+ Word16 itdLR[CPE_CHANNELS];
+ Word16 shift_limit;
const Word32 *wnd_fx;
@@ -1182,7 +1178,7 @@ typedef struct stereo_dmx_evs_phase_only_correlation_structure
typedef struct stereo_dmx_evs_correlation_filter_structure
{
- int16_t init_frmCntr;
+ Word16 init_frmCntr;
Word16 isd_rate_s_fx; // Q15
Word32 iccr_s_fx; // Q31
@@ -1191,8 +1187,8 @@ typedef struct stereo_dmx_evs_correlation_filter_structure
Word32 Pi_fx[STEREO_DMX_EVS_NB_SUBBAND_MAX]; // Q31
Word16 rfft_ipd_coef_fx[L_FRAME48k / 2 + 1];
- int16_t pha_len;
- int16_t fad_len;
+ Word16 pha_len;
+ Word16 fad_len;
Word16 win_fx[STEREO_DMX_EVS_PHA_LEN_MAX]; // Q14
@@ -1204,14 +1200,14 @@ typedef struct stereo_dmx_evs_correlation_filter_structure
STEREO_DMX_EVS_PHA curr_pha;
STEREO_DMX_EVS_PHA prev_pha;
- int16_t pha_hys_cnt;
+ Word16 pha_hys_cnt;
- int16_t prc_thres;
+ Word16 prc_thres;
STEREO_DMX_EVS_PRC curr_prc;
STEREO_DMX_EVS_PRC prev_prc;
- int16_t prc_hys_cnt;
+ Word16 prc_hys_cnt;
Word32 fad_g_prc_fx[L_FRAME48k]; // Q31
- int16_t fad_len_prc;
+ Word16 fad_len_prc;
Word32 trns_aux_energy_fx[CPE_CHANNELS];
@@ -1248,9 +1244,9 @@ typedef struct ivas_lfe_enc_data_structure
{
LFE_WINDOW_HANDLE pWindow_state;
BSTR_ENC_HANDLE hBstr; /* pointer to encoder bitstream handle */
- const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
- int16_t lfe_enc_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
- int16_t lfe_bits;
+ const UWord16 *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
+ Word16 lfe_enc_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
+ Word16 lfe_bits;
Word32 *old_wtda_audio_fx;
Word16 q_old_wtda_audio;
@@ -1298,9 +1294,9 @@ typedef struct encoder_config_structure
#ifdef DEBUGGING
/* debugging options */
- int16_t stereo_mode_cmdl; /* stereo mode forced from the command-line */
- int16_t force; /* parameter to force specific "core" of the Core-Coder*/
- int16_t mdct_stereo_mode_cmdl; /* mdct stereo mode forced from command-line, employed only when DEBUG_FORCE_MDCT_STEREO_MODE is activated */
+ Word16 stereo_mode_cmdl; /* stereo mode forced from the command-line */
+ Word16 force; /* parameter to force specific "core" of the Core-Coder*/
+ Word16 mdct_stereo_mode_cmdl; /* mdct stereo mode forced from command-line, employed only when DEBUG_FORCE_MDCT_STEREO_MODE is activated */
#endif
diff --git a/lib_enc/ivas_stereo_cng_enc.c b/lib_enc/ivas_stereo_cng_enc.c
index 0a3c84b1e77b3196498aa7765831a300a8c75356..059eb5b8ece1f40cdb757fd7ed2e23afbea72f35 100644
--- a/lib_enc/ivas_stereo_cng_enc.c
+++ b/lib_enc/ivas_stereo_cng_enc.c
@@ -109,11 +109,11 @@ void stereo_dft_enc_sid_calc_coh_fx(
xspec_scale = Sqrt32( L_tmp3, &L_tmp3_e );
// xspec_scale = L_shl(xspec_scale, L_tmp3_e);//Q31
- hStereoDft->xspec_smooth_fx[2 * k] = Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k], xspec_scale );
+ hStereoDft->xspec_smooth_fx[2 * k] = Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k], xspec_scale ); // Q(31-(xspec_smooth_fx_e+tmp3_e))
move32();
hStereoDft->xspec_smooth_fx_e[2 * k] = add( hStereoDft->xspec_smooth_fx_e[2 * k], L_tmp3_e );
move16();
- hStereoDft->xspec_smooth_fx[2 * k + 1] = Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k + 1], xspec_scale );
+ hStereoDft->xspec_smooth_fx[2 * k + 1] = Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k + 1], xspec_scale ); // Q(31-(xspec_smooth_fx_e+tmp3_e))
move32();
hStereoDft->xspec_smooth_fx_e[2 * k + 1] = add( hStereoDft->xspec_smooth_fx_e[2 * k + 1], L_tmp3_e );
move16();
@@ -231,10 +231,10 @@ void stereo_dft_enc_sid_calc_coh_fx(
void stereo_dft_enc_sid_coh_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word32 *mem_cohBand, /* i/o: Coherence memory */
+ Word32 *mem_cohBand, /* i/o: Coherence memory Q31 */
const Word16 nbands, /* i : number of DFT stereo bands */
Word16 *nb_bits, /* i/o: number of bits written */
- Word32 *cohBand /* i/o: Coherence per band */
+ Word32 *cohBand /* i/o: Coherence per band Q31 */
)
{
Word16 b, k;
@@ -384,7 +384,7 @@ void stereo_dft_enc_sid_coh_fx(
alphaptr = &dft_cng_alpha_bits_fx[alpha_step][alpha_level];
pptr = dft_cng_coh_pred_fx[coh_pred_index]; /* Set pointer to selected predictor */
pred = 3277 /*0.4f in Q13*/;
-
+ move16();
FOR( b = 0; b < nbands; b++ )
{
/* Intra-frame prediction using quantized values */
@@ -429,7 +429,7 @@ void stereo_dft_enc_sid_coh_fx(
move16();
}
- mem_cohBand[b] = L_deposit_h( cohBandq[b] ); /* Update memory for next frame */
+ mem_cohBand[b] = L_deposit_h( cohBandq[b] ); /* Update memory for next frame Q31*/
move32();
pred = 0;
move16();
@@ -658,7 +658,7 @@ void stereo_cng_upd_counters_fx(
STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */
const Word32 element_mode, /* i : element mode */
const Word16 nbands, /* i : Number of bands in active */
- const Word32 sidSideGain[], /* i : SID side gains */
+ const Word32 sidSideGain[], /* i : SID side gains Q31 */
const Word16 burst_ho_count, /* i : Hang-over count */
Word16 *coh_fade_counter /* i : Coherence fade counter */
)
diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c
index e2b4597653eaf9b59053312cffc747149fcfcc27..119dfc31349edcceace0e2edd33ccefdb55900c9 100644
--- a/lib_enc/ivas_stereo_dft_enc.c
+++ b/lib_enc/ivas_stereo_dft_enc.c
@@ -737,8 +737,7 @@ void stereo_enc_itd_init_fx(
set16_fx( hItd->td_itd_32k, 0, STEREO_DFT_ENC_DFT_NB );
set16_fx( hItd->itd_index, 0, STEREO_DFT_ENC_DFT_NB );
set32_fx( hItd->xcorr_smooth_fx, 0, STEREO_DFT_N_32k_ENC );
- hItd->xcorr_smooth_fx_e = 0;
- move16();
+ set16_fx( hItd->xcorr_smooth_fx_e, 0, STEREO_DFT_N_32k_ENC );
hItd->lp_phat_peak_fx = 0;
move32();
hItd->itd_hangover = 0;
@@ -753,6 +752,9 @@ void stereo_enc_itd_init_fx(
hItd->prev_xcorr_lb_fx_e = 0;
move16();
set32_fx( hItd->E_band_n_fx, ITD_VAD_E_BAND_N_INIT, STEREO_DFT_ITD_VAD_BAND_NUM );
+#ifdef FIX_ISSUE_1092
+ set16_fx( hItd->E_band_n_exp, Q31, STEREO_DFT_ITD_VAD_BAND_NUM );
+#endif
hItd->vad_frm_cnt = 0;
move16();
hItd->pre_vad = 0;
@@ -819,7 +821,7 @@ void stereo_dft_enc_update_fx(
move32();
/* Update the parameters and serial */
- FOR( i = 0; i < imult1616( k_offset, STEREO_DFT_BAND_MAX ); i++ )
+ FOR( i = 0; i < ( k_offset * STEREO_DFT_BAND_MAX ); i++ )
{
hStereoDft->side_gain_fx[i] = hStereoDft->side_gain_fx[STEREO_DFT_BAND_MAX + i];
move32();
@@ -937,9 +939,9 @@ void stereo_dft_enc_analyze_fx(
const Word16 input_frame, /* i : input frame length */
STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: encoder MDCT stereo handle */
- Word32 DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC], /* o : DFT buffers */
+ Word32 DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC], /* o : DFT buffers Q(31-DFT_e) */
Word16 DFT_e[CPE_CHANNELS], /* o : DFT buffers */
- Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory */
+ Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory Q(q_input_mem_ */
Word16 *q_input_mem )
{
Word16 i, n;
@@ -1011,10 +1013,10 @@ void stereo_dft_enc_analyze_fx(
{
trigo_enc[i] = pTrigo[i * trigo_step];
move16();
- trigo_enc[sub( shr( NFFT, 1 ), i )] = pTrigo[L_mult0( i, trigo_step )];
+ trigo_enc[( ( NFFT / 2 ) - i )] = pTrigo[L_mult0( i, trigo_step )];
move16();
}
- trigo_enc[shr( NFFT, 2 )] = pTrigo[L_mult0( shr( NFFT, 2 ), trigo_step )];
+ trigo_enc[NFFT / 4] = pTrigo[( ( NFFT / 4 ) * trigo_step )];
move16();
/*Forwards FFT: L and R*/
@@ -1023,42 +1025,42 @@ void stereo_dft_enc_analyze_fx(
{
pDFT_L[i] = 0;
move32();
- pDFT_L[sub( sub( NFFT, 1 ), i )] = 0;
+ pDFT_L[( ( NFFT - 1 ) - i )] = 0;
move32();
pDFT_R[i] = 0;
move32();
- pDFT_R[sub( sub( NFFT, 1 ), i )] = 0;
+ pDFT_R[( ( NFFT - 1 ) - i )] = 0;
move32();
}
FOR( n = 0; n < n_channels; n++ )
{
- Scale_sig( &mem[n][0], dft_ovl, sts[n]->q_inp - q_input_mem[n] );
+ Scale_sig( &mem[n][0], dft_ovl, sts[n]->q_inp - q_input_mem[n] ); // Q(sts[n]->q_inp)
q_input_mem[n] = sts[n]->q_inp;
move16();
}
/*overlapping parts*/
FOR( i = 0; i < dft_ovl; i++ )
{
- pDFT_L[add( dft_zp, i )] = L_mult0( mem[0][i], pWin[i] );
+ pDFT_L[( dft_zp + i )] = L_mult0( mem[0][i], pWin[i] );
move32();
- pDFT_L[sub( add( add( dft_zp, N ), dft_ovl ) - 1, i )] = L_mult0( input[0][sub( add( add( offset, N ), dft_ovl ) - 1, i )], pWin[i] );
+ pDFT_L[( ( ( dft_zp + N ) + dft_ovl ) - 1 - i )] = L_mult0( input[0][offset + N + dft_ovl - 1 - i], pWin[i] );
move32();
- pDFT_R[add( dft_zp, i )] = L_mult0( mem[1][i], pWin[i] );
+ pDFT_R[dft_zp + i] = L_mult0( mem[1][i], pWin[i] );
move32();
- pDFT_R[sub( add( add( dft_zp, N ), dft_ovl ) - 1, i )] = L_mult0( input[1][sub( add( add( offset, N ), dft_ovl ) - 1, i )], pWin[i] );
+ pDFT_R[( ( dft_zp + N ) + dft_ovl ) - 1 - i] = L_mult0( input[1][offset + N + dft_ovl - 1 - i], pWin[i] );
move32();
}
/*middle part*/
FOR( i = 0; i < N - dft_ovl; i++ )
{
- pDFT_L[add( add( dft_zp, dft_ovl ), i )] = L_shr( L_deposit_h( input[0][add( add( offset, dft_ovl ), i )] ), 1 );
+ pDFT_L[dft_zp + dft_ovl + i] = L_shr( L_deposit_h( input[0][offset + dft_ovl + i] ), 1 );
move32();
- pDFT_R[add( add( dft_zp, dft_ovl ), i )] = L_shr( L_deposit_h( input[1][add( add( offset, dft_ovl ), i )] ), 1 );
+ pDFT_R[dft_zp + dft_ovl + i] = L_shr( L_deposit_h( input[1][offset + dft_ovl + i] ), 1 );
move32();
}
DFT_e[0] = sub( 31, add( 15, sts[0]->q_inp ) );
@@ -1096,13 +1098,14 @@ void stereo_dft_enc_analyze_fx(
{
mem[n] = &input[n][sub( N, dft_ovl )];
}
-
+ test();
+ test();
IF( hStereoDft != NULL && hStereoDft->hConfig->hybrid_itd_flag && hStereoDft->hItd->td_itd[STEREO_DFT_OFFSET] )
{
FOR( n = 0; n < n_channels; n++ )
{
#ifdef MSAN_FIX
- Scale_sig( hStereoDft->input_mem_itd_fx[n], dft_ovl, sub( sts[n]->q_inp, hStereoDft->q_input_mem_itd[n] ) );
+ Scale_sig( hStereoDft->input_mem_itd_fx[n], dft_ovl, sub( sts[n]->q_inp, hStereoDft->q_input_mem_itd[n] ) ); // Q(sts[n]->q_inp)
#else
Scale_sig( hStereoDft->input_mem_itd_fx[n], STEREO_DFT_OVL_MAX, sts[n]->q_inp - hStereoDft->q_input_mem_itd[n] );
#endif // MSAN_FIX
@@ -1132,7 +1135,7 @@ void stereo_dft_enc_analyze_fx(
Word32 stereo_dft_enc_synthesize_fx(
STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */
// float *output, /* o : output synthesis */
- Word32 *output_fx, /* o : output synthesis Q16 */
+ Word32 *output_fx, /* o : output synthesis Q15 */
Word16 *output_start_index,
Word16 *output_end_index,
const Word16 chan, /* i : channel number */
@@ -1360,14 +1363,14 @@ Word32 stereo_dft_enc_synthesize_fx(
offset = 0;
move16();
- FOR( i = 0; i < shr( NFFT, 2 ); i++ )
+ FOR( i = 0; i < NFFT / 4; i++ )
{
- trigo_enc_fx[i] = trigo_fx[imult1616( i, trigo_step )];
+ trigo_enc_fx[i] = trigo_fx[i * trigo_step];
move16();
- trigo_enc_fx[sub( shr( NFFT, 1 ), i )] = trigo_fx[imult1616( i, trigo_step )];
+ trigo_enc_fx[( NFFT / 2 ) - i] = trigo_fx[i * trigo_step];
move16();
}
- trigo_enc_fx[shr( NFFT, 2 )] = trigo_fx[imult1616( shr( NFFT, 2 ), trigo_step )];
+ trigo_enc_fx[NFFT / 4] = trigo_fx[( NFFT / 4 ) * trigo_step];
move16();
/*-----------------------------------------------------------------*
@@ -1497,15 +1500,15 @@ Word32 stereo_dft_enc_synthesize_fx(
scal_fac = sub( 1, find_guarded_bits_fx( NFFT ) );
scale_sig32( tmp_fx, NFFT, scal_fac ); // Q16
rfft_fx( tmp_fx, trigo_enc_fx, NFFT, +1 );
- Scale_sig32( tmp_fx, NFFT, sub( sub( DFT_in_fx_e, scal_fac ), 15 ) ); // Q16
+ Scale_sig32( tmp_fx, NFFT, sub( sub( DFT_in_fx_e, scal_fac ), 16 ) ); // Q15
FOR( i = 0; i < ovl; i++ )
{
// output[offset + i] = mem[i] + tmp[zp + i] * win[i];
- output_fx[offset + i] = L_add_sat( mem_fx[i], Mpy_32_32( tmp_fx[zp + i], win_fx[i] ) );
+ output_fx[offset + i] = L_add_sat( mem_fx[i], Mpy_32_32( tmp_fx[zp + i], win_fx[i] ) ); // Q15
move32();
// mem[i] = tmp[zp + N + i] * win[ovl - 1 - i];
- mem_fx[i] = Mpy_32_32( tmp_fx[zp + N + i], win_fx[ovl - 1 - i] );
+ mem_fx[i] = Mpy_32_32( tmp_fx[zp + N + i], win_fx[ovl - 1 - i] ); // Q15
move32();
}
@@ -1513,7 +1516,7 @@ Word32 stereo_dft_enc_synthesize_fx(
FOR( i = 0; i < N - ovl; i++ )
{
// output_fx[offset + ovl + i] = tmp[zp + ovl + i];
- output_fx[offset + ovl + i] = tmp_fx[zp + ovl + i];
+ output_fx[offset + ovl + i] = tmp_fx[zp + ovl + i]; // Q15
move32();
}
@@ -1523,13 +1526,13 @@ Word32 stereo_dft_enc_synthesize_fx(
FOR( i = 0; i < ovl; i++ )
{
- Word32 ifft_deviation = tmp_fx[zp + N + ovl];
+ Word32 ifft_deviation = tmp_fx[zp + N + ovl]; // Q15
move32();
// output[offset + N + i] = ( tmp[zp + N + i] - ifft_deviation ) / win_ana[ovl - 1 - i] + ifft_deviation;
Word16 L_temp_e;
Word32 L_temp = BASOP_Util_Divide3232_Scale_cadence( L_sub_sat( tmp_fx[zp + N + i], ifft_deviation ), L_deposit_h( win_ana_fx[ovl - 1 - i] ), &L_temp_e );
L_temp = L_shl_sat( L_temp, L_temp_e );
- output_fx[offset + N + i] = L_add_sat( L_temp, ifft_deviation ); // Q16
+ output_fx[offset + N + i] = L_add_sat( L_temp, ifft_deviation ); // Q15
move32();
}
@@ -1859,8 +1862,8 @@ void stereo_dft_enc_process_fx(
IF( pgIpd[0] != 0 )
{
- c_fx = shl_sat( getCosWord16( (Word16) pgIpd[0] ), 1 ); // Q15 saturation expected
- s_fx = getSinWord16( (Word16) pgIpd[0] ); // Q15
+ c_fx = shl_sat( getCosWord16( extract_l( pgIpd[0] ) ), 1 ); // Q15 saturation expected
+ s_fx = getSinWord16( extract_l( pgIpd[0] ) ); // Q15
FOR( i = hStereoDft->band_limits_dmx[b]; i < hStereoDft->band_limits_dmx[b + 1]; i++ )
{
/*rotate L*/
@@ -2413,7 +2416,7 @@ void stereo_dft_enc_process_fx(
}
FOR( i = 0; i < STEREO_DFT_N_MAX_ENC; i++ )
{
- DFT_DMX[i] = L_shr_r( DFT_DMX[i], sub( max_exp, DFT_DMX_e[i] ) );
+ DFT_DMX[i] = L_shr_r( DFT_DMX[i], sub( max_exp, DFT_DMX_e[i] ) ); // Q(31-max_exp)
move32();
}
hStereoDft->DFT_fx_e[0] = max_exp;
@@ -2427,7 +2430,7 @@ void stereo_dft_enc_process_fx(
}
FOR( i = 0; i < STEREO_DFT_N_8k_ENC; i++ )
{
- DFT_RES[i] = L_shr_r( DFT_RES[i], sub( max_exp, DFT_RES_e[i] ) );
+ DFT_RES[i] = L_shr_r( DFT_RES[i], sub( max_exp, DFT_RES_e[i] ) ); // Q(31-max_exp)
move32();
}
hStereoDft->DFT_fx_e[1] = max_exp;
@@ -2866,7 +2869,7 @@ void stereo_dft_enc_write_BS_fx(
sp_aud_decision0 = 0;
move16();
- IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
+ if ( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
sp_aud_decision0 = hCPE->hCoreCoder[0]->sp_aud_decision0;
move16();
@@ -2881,7 +2884,7 @@ void stereo_dft_enc_write_BS_fx(
move16();
test();
- IF( EQ_32( core_brate, FRAME_NO_DATA ) || EQ_32( core_brate, SID_2k40 ) )
+ IF( ( core_brate == FRAME_NO_DATA ) || EQ_32( core_brate, SID_2k40 ) )
{
NFFT_inner = s_min( STEREO_DFT_N_32k_ENC, STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k );
hStereoDft->band_res[k_offset] = hStereoDft->hConfig->band_res;
@@ -2901,7 +2904,7 @@ void stereo_dft_enc_write_BS_fx(
hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC );
move16();
- IF( EQ_32( core_brate, FRAME_NO_DATA ) )
+ IF( core_brate == FRAME_NO_DATA )
{
/* No data frame */
( *nb_bits ) = 0;
@@ -3242,6 +3245,7 @@ ELSE
}
( *nb_bits ) = add( *nb_bits, nb );
+move16();
IF( EQ_32( core_brate, SID_2k40 ) )
{
@@ -3437,7 +3441,7 @@ static void stereo_dft_enc_compute_prm_fx(
sum_past_dpi_e = 0;
move16();
- WHILE( LT_16( hStereoDft->band_limits_dmx[b2], hStereoDft->band_limits[b + 1] ) )
+ WHILE( hStereoDft->band_limits_dmx[b2] < hStereoDft->band_limits[b + 1] )
{
pDFT_L = DFT_L_fx;
// DFT_L_e = hStereoDft->DFT_fx_e[0];
@@ -3796,7 +3800,7 @@ static void stereo_dft_enc_compute_prm_fx(
move32();
}
// dItd32 = (int16_t) floorf( conversion_factor * hStereoDft->hItd->deltaItd[k_offset] + 0.5f );
- dItd32 = (Word16) L_shr_r( Mpy_32_32( conversion_factor, hStereoDft->hItd->deltaItd_fx[k_offset] ), Q15 ); // Q0
+ dItd32 = extract_l( L_shr_r( Mpy_32_32( conversion_factor, hStereoDft->hItd->deltaItd_fx[k_offset] ), Q15 ) ); // Q0
gain_offset = stereo_dft_gain_offset_fx( c, c_e, dItd32 ); // Q31
pPredGain[b] = L_max( 0, L_sub( pPredGain[b], gain_offset ) );
@@ -3947,8 +3951,6 @@ static void stereo_dft_enc_compute_prm_fx(
ELSE
{
stereo_dft_enc_get_reverb_flag_fx( hStereoDft, pPredGain, sub_nrg_DMX, sub_nrg_DMX_e, sub_nrg_L, sub_nrg_L_e, sub_nrg_R, sub_nrg_R_e, k_offset, bin_nrgL_fx, bin_nrgL_fx_e, bin_nrgR_fx, bin_nrgR_fx_e );
- // printf( "\n%d ", hStereoDft->reverb_flag );
- // printf( "\n%f ", (float)hStereoDft->res_pred_gain_fx[18]/0x7fffffff);
}
@@ -4269,6 +4271,7 @@ static Word32 stereo_dft_calc_mean_bipd_fx(
{
ipd_buf[i] = L_add( ipd_buf[i], 2 * EVS_PI_FX );
}
+ move32();
}
// ipd_smooth = (i / (float)(i + 1)) * ipd_smooth + (1 / (float)(i + 1)) * ipd_buf[i];
ipd_smooth = L_add( Mpy_32_16_1( ipd_smooth, ipd_table1[i] ), Mpy_32_16_1( ipd_buf[i], ipd_table2[i] ) ); // Q13
@@ -4326,7 +4329,7 @@ static Word32 stereo_dft_calc_mean_ipd_change_fx(
// ipd_mean_change /= gipd_band_max;
ipd_mean_change = BASOP_Util_Divide3232_Scale_cadence( ipd_mean_change, gipd_band_max, &ipd_mean_change_e );
ipd_mean_change_e = add( ipd_mean_change_e, 18 - 31 );
- ipd_mean_change = L_shr( ipd_mean_change, sub( 18, ipd_mean_change_e ) );
+ ipd_mean_change = L_shr( ipd_mean_change, sub( 18, ipd_mean_change_e ) ); // Q13
return ipd_mean_change;
}
@@ -4434,6 +4437,7 @@ static void stereo_dft_enc_get_nipd_flag_fx(
hStereoDft->no_ipd_flag = hStereoDft->prev_no_ipd_flag;
move16();
hStereoDft->no_ipd_cnt = add( hStereoDft->no_ipd_cnt, 1 );
+ move16();
}
ELSE
{
@@ -4454,8 +4458,8 @@ static void stereo_dft_enc_get_nipd_flag_fx(
* ---------------------------------------------------------------*/
static void stereo_dft_enc_get_reverb_flag_fx(
STEREO_DFT_ENC_DATA_HANDLE hStereoDft,
- Word32 *pPredGain, // Q31
- Word32 *sub_nrg_DMX,
+ Word32 *pPredGain, // Q31
+ Word32 *sub_nrg_DMX, // Q(31-sub_nrg_DMX_e)
Word16 *sub_nrg_DMX_e,
const Word32 *sub_nrg_L, // Q(31-sub_nrg_L_e[])
const Word16 *sub_nrg_L_e,
diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c
index 45eb643a570256b33d5c65f990ac20f1608f26b7..d2873bdfe7e88bf25eb5895f58d9c713df02adc6 100644
--- a/lib_enc/ivas_stereo_dft_enc_itd.c
+++ b/lib_enc/ivas_stereo_dft_enc_itd.c
@@ -205,7 +205,12 @@ static void stereo_dft_quantize_itd_fx(
*-------------------------------------------------------------------------*/
static Word32 itd_vad_ms_snr_calc_fx(
+#ifdef FIX_ISSUE_1092
+ Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // E_band_n_exp
+ Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM],
+#else
Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0
+#endif
Word32 *Spd,
Word16 *Spd_e,
Word32 *E_band,
@@ -248,7 +253,11 @@ static Word32 itd_vad_ms_snr_calc_fx(
// snr[i] = E_band[i] / E_band_n[i];
snr[i] = BASOP_Util_Divide3232_Scale_cadence( E_band[i], E_band_n[i], &snr_e[i] );
move32();
+#ifdef FIX_ISSUE_1092
+ snr_e[i] = add( snr_e[i], sub( E_band_e[i], E_band_n_exp[i] ) );
+#else
snr_e[i] = add( snr_e[i], sub( E_band_e[i], 31 ) );
+#endif
move16();
// if ( snr[i] < 1 )
IF( BASOP_Util_Cmp_Mant32Exp( snr[i], snr_e[i], 1, 31 ) < 0 )
@@ -284,7 +293,12 @@ static Word32 itd_vad_ms_snr_calc_fx(
*
*-------------------------------------------------------------------------*/
static void itd_vad_background_update_fx(
+#ifdef FIX_ISSUE_1092
+ Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // E_band_n_exp
+ Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM],
+#else
Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0
+#endif
Word16 *vad_frm_cnt,
const Word32 ms_snr,
const Word16 ms_snr_e,
@@ -326,23 +340,21 @@ static void itd_vad_background_update_fx(
Word16 q_temp = norm_l( *vad_frm_cnt );
L_temp = L_shl( *vad_frm_cnt, q_temp );
L_temp_e = sub( 31, q_temp );
+#ifdef FIX_ISSUE_1092
+ L_temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( E_band_n[i], L_temp ), add( E_band_n_exp[i], L_temp_e ), E_band[i], E_band_e[i], &L_temp_e );
+#else
L_temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( E_band_n[i], L_temp ), add( 31, L_temp_e ), E_band[i], E_band_e[i], &L_temp_e );
+#endif
E_band_n[i] = BASOP_Util_Divide3232_Scale_cadence( L_temp, L_add( *vad_frm_cnt, 1 ), &E_band_n_e_tmp );
move32();
+#ifdef FIX_ISSUE_1092
+ E_band_n_exp[i] = add( E_band_n_e_tmp, sub( L_temp_e, 31 ) );
+#else
E_band_n_e_tmp = add( E_band_n_e_tmp, sub( L_temp_e, 31 ) );
E_band_n[i] = L_shr_r( E_band_n[i], sub( 31, E_band_n_e_tmp ) ); // Q31
+#endif
move16();
}
- /*Word16 max_exp = E_band_n_e_tmp[0];
- for ( i = 1; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
- {
- max_exp = s_max( max_exp, E_band_n_e_tmp[i] );
- }
- *E_band_n_e = max_exp;
- for ( i = 0; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
- {
- E_band_n[i] = L_shr_r( E_band_n[i], sub( *E_band_n_e, E_band_n_e_tmp[i] ) );
- }*/
}
ELSE
{
@@ -352,6 +364,20 @@ static void itd_vad_background_update_fx(
FOR( i = 0; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
{
// E_band_n[i] = 0.96f * E_band_n[i] + 0.04f * E_band[i];
+#ifdef FIX_ISSUE_1092
+ E_band_n[i] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( 2061584302 /*0.96 in Q31*/, E_band_n[i] ), E_band_n_exp[i], Mpy_32_32( 85899346 /*0.04 in Q31*/, E_band[i] ), E_band_e[i], &E_band_n_e_tmp );
+ move32();
+ E_band_n_exp[i] = E_band_n_e_tmp;
+ move16();
+ // if ( E_band_n[i] < 1.0f )
+ IF( BASOP_Util_Cmp_Mant32Exp( E_band_n[i], E_band_n_exp[i], MAX_32, 0 ) < 0 )
+ {
+ E_band_n[i] = MAX_32;
+ move32();
+ E_band_n_exp[i] = 0;
+ move16();
+ }
+#else
E_band_n[i] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( 2061584302, E_band_n[i] ), 31, Mpy_32_32( 85899346, E_band[i] ), E_band_e[i], &E_band_n_e_tmp );
move32();
// if ( E_band_n[i] < 1.0f )
@@ -364,17 +390,8 @@ static void itd_vad_background_update_fx(
}
E_band_n[i] = L_shr_r( E_band_n[i], sub( 31, E_band_n_e_tmp ) ); // Q31
move32();
+#endif
}
- /*Word16 max_exp = E_band_n_e_tmp[0];
- for ( i = 1; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
- {
- max_exp = s_max( max_exp, E_band_n_e_tmp[i] );
- }
- *E_band_n_e = max_exp;
- for ( i = 0; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
- {
- E_band_n[i] = L_shr_r( E_band_n[i], sub( *E_band_n_e, E_band_n_e_tmp[i] ) );
- }*/
}
}
@@ -387,7 +404,12 @@ static void itd_vad_background_update_fx(
*-------------------------------------------------------------------------*/
static Word16 stereo_dft_enc_itd_vad_fx(
+#ifdef FIX_ISSUE_1092
+ Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // E_band_n_exp
+ Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM],
+#else
Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0
+#endif
Word16 *vad_frm_cnt,
Word32 *Spd_L,
Word16 *Spd_L_e,
@@ -414,12 +436,17 @@ static Word16 stereo_dft_enc_itd_vad_fx(
Spd_e[i] = sub( Spd_e[i], 1 );
move16();
}
+#ifdef FIX_ISSUE_1092
+ *mssnr = itd_vad_ms_snr_calc_fx( E_band_n, E_band_n_exp, Spd, Spd_e, E_band, E_band_e, mssnr_e );
+ move32();
+ itd_vad_background_update_fx( E_band_n, E_band_n_exp, vad_frm_cnt, *mssnr, *mssnr_e, E_band, E_band_e );
+#else
*mssnr = itd_vad_ms_snr_calc_fx( E_band_n, Spd, Spd_e, E_band, E_band_e, mssnr_e );
move32();
itd_vad_background_update_fx( E_band_n, vad_frm_cnt, *mssnr, *mssnr_e, E_band, E_band_e );
-
+#endif
// if ( *mssnr < ITD_VAD_THRSHOLD )
IF( BASOP_Util_Cmp_Mant32Exp( *mssnr, *mssnr_e, ITD_VAD_THRSHOLD_Q31, 0 ) < 0 )
{
@@ -524,10 +551,10 @@ static Word32 calc_mean_E_ratio_fx(
FOR( i = band_limits[b]; i < min( band_limits[b + 1], STEREO_DFT_N_32k_ENC / 2 ); i++ )
{
// sum_xcorr[0] += hItd->xcorr_smooth[2 * i];
- sum_xcorr[0] = BASOP_Util_Add_Mant32Exp( sum_xcorr[0], sum_xcorr_e[0], hItd->xcorr_smooth_fx[2 * i], hItd->xcorr_smooth_fx_e, &sum_xcorr_e[0] );
+ sum_xcorr[0] = BASOP_Util_Add_Mant32Exp( sum_xcorr[0], sum_xcorr_e[0], hItd->xcorr_smooth_fx[2 * i], hItd->xcorr_smooth_fx_e[2 * i], &sum_xcorr_e[0] );
move32();
// sum_xcorr[1] += hItd->xcorr_smooth[2 * i + 1];
- sum_xcorr[1] = BASOP_Util_Add_Mant32Exp( sum_xcorr[1], sum_xcorr_e[1], hItd->xcorr_smooth_fx[2 * i + 1], hItd->xcorr_smooth_fx_e, &sum_xcorr_e[1] );
+ sum_xcorr[1] = BASOP_Util_Add_Mant32Exp( sum_xcorr[1], sum_xcorr_e[1], hItd->xcorr_smooth_fx[2 * i + 1], hItd->xcorr_smooth_fx_e[2 * i + 1], &sum_xcorr_e[1] );
move32();
// sum_nrg_L += nrg_L[i];
sum_nrg_L = BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, nrg_L[i], nrg_L_e[i], &sum_nrg_L_e );
@@ -622,8 +649,7 @@ static void resetEstimates_fx(
ITD_DATA_HANDLE hItd )
{
set32_fx( hItd->xcorr_smooth_fx, 0, STEREO_DFT_N_32k_ENC );
- hItd->xcorr_smooth_fx_e = 0;
- move16();
+ set16_fx( hItd->xcorr_smooth_fx_e, 0, STEREO_DFT_N_32k_ENC );
set32_fx( hItd->acorr_L_fx, 0, STEREO_DFT_BAND_MAX );
hItd->acorr_L_fx_e = 0;
move16();
@@ -1444,13 +1470,15 @@ void stereo_dft_enc_compute_itd_fx(
move16();
FOR( Word16 ii = 0; ii < 11; ii++ )
{
- L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, Spd_L[i + 1], Spd_L_e[i + 1], &L_temp_e );
+ L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, Spd_L[ii + 1], Spd_L_e[ii + 1], &L_temp_e );
}
// L_temp = sum2_32_fx( &Spd_L[1], 11, &L_temp_e );
sum_nrg_L_lb = BASOP_Util_Add_Mant32Exp( sum_nrg_L_lb, sum_nrg_L_lb_e, L_temp, L_temp_e, &sum_nrg_L_lb_e );
-
+#ifdef FIX_ISSUE_1092
+ vad_flag_itd = stereo_dft_enc_itd_vad_fx( hItd->E_band_n_fx, hItd->E_band_n_exp, &( hItd->vad_frm_cnt ), Spd_L, Spd_L_e, Spd_R, Spd_R_e, &mssnr, &mssnr_e );
+#else
vad_flag_itd = stereo_dft_enc_itd_vad_fx( hItd->E_band_n_fx, &( hItd->vad_frm_cnt ), Spd_L, Spd_L_e, Spd_R, Spd_R_e, &mssnr, &mssnr_e );
-
+#endif
vad_flag_itd = vad_flag_itd && vad_flag_dtx[0];
// if ( sum_nrg_L < EPSILON )
@@ -1583,7 +1611,7 @@ void stereo_dft_enc_compute_itd_fx(
}
Word16 xcorr_smooth_fx_tmp_e[STEREO_DFT_N_32k_ENC];
- set16_fx( xcorr_smooth_fx_tmp_e, hItd->xcorr_smooth_fx_e, STEREO_DFT_N_32k_ENC );
+ Copy( hItd->xcorr_smooth_fx_e, xcorr_smooth_fx_tmp_e, STEREO_DFT_N_32k_ENC );
hItd->xcorr_smooth_fx[0] = 0;
move32();
xcorr_smooth_fx_tmp_e[0] = 0;
@@ -1942,17 +1970,7 @@ void stereo_dft_enc_compute_itd_fx(
/* RESCALING TO COMMON EXP */
max_exp = MIN_16;
move16();
- FOR( i = 0; i < STEREO_DFT_N_32k_ENC; i++ )
- {
- max_exp = s_max( max_exp, xcorr_smooth_fx_tmp_e[i] );
- }
- hItd->xcorr_smooth_fx_e = max_exp;
- move16();
- FOR( i = 0; i < STEREO_DFT_N_32k_ENC; i++ )
- {
- hItd->xcorr_smooth_fx[i] = L_shr_r( hItd->xcorr_smooth_fx[i], sub( hItd->xcorr_smooth_fx_e, xcorr_smooth_fx_tmp_e[i] ) );
- move32();
- }
+ Copy( xcorr_smooth_fx_tmp_e, hItd->xcorr_smooth_fx_e, STEREO_DFT_N_32k_ENC );
max_exp = MIN_16;
move16();
FOR( i = 0; i < STEREO_DFT_N_32k_ENC; i++ )
diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c
index fbcb2ce00df673121a4608c695bae22e229d5203..b997495be50c065ab637383c80e992e112cdd5c5 100644
--- a/lib_enc/ivas_stereo_dft_td_itd.c
+++ b/lib_enc/ivas_stereo_dft_td_itd.c
@@ -229,14 +229,14 @@ static void stereo_td_channel_extrapolate_fx(
nsr = mult( g, f );
nsr_e = BASOP_Util_Add_MantExp( ONE_IN_Q14, 1, negate( nsr ), g_e + f_e, &nsr );
- IF( LE_16( g_e, 0 ) )
- g = g;
- ELSE
- g = check_bounds_s( g, negate( shl( 1, 15 - g_e ) ), shl( ONE_HALF, ( 1 - g_e ) ) );
- IF( LE_16( nsr_e, 0 ) )
- nsr = nsr;
- ELSE
- nsr = check_bounds_s( nsr, 0, shl( 1, 15 - ( nsr_e ) ) );
+ IF( g_e > 0 )
+ {
+ g = check_bounds_s_fx( g, negate( shl( 1, sub( 15, g_e ) ) ), shl( ONE_HALF, sub( 1, g_e ) ) );
+ }
+ IF( nsr_e > 0 )
+ {
+ nsr = check_bounds_s_fx( nsr, 0, shl( 1, sub( 15, nsr_e ) ) );
+ }
g = shl( g, g_e - 1 ); // q14
nsr = shl( nsr, nsr_e ); // Q15
g_lpc_e = 0;
@@ -257,6 +257,7 @@ static void stereo_td_channel_extrapolate_fx(
}
r_l[0] = s_max( r_l[0], 1 );
+
flag = E_LPC_lev_dur( r_h, r_l, A, NULL, STEREO_DFT_CHANNEL_EXTR_LPC_ORDER, NULL );
Copy_Scale_sig( A, A, STEREO_DFT_CHANNEL_EXTR_LPC_ORDER + 1, sub( norm_s( A[0] ), 2 ) );
IF( EQ_16( flag, 1 ) )
@@ -343,6 +344,7 @@ void stereo_td_itd_fx(
Word16 itd, itd_max;
Word16 shift_input[L_FRAME48k];
Word16 shift_mem[L_FRAME48k];
+ Word16 q_shift_mem;
Word16 *mdct_mem[CPE_CHANNELS];
// Word16 q_mdct_mem[CPE_CHANNELS];
Word16 q_shift, q_new_shift;
@@ -451,12 +453,16 @@ void stereo_td_itd_fx(
/*shift past part*/
Copy( input_mem[ch] + shift[ch], shift_mem, size_ovl - shift[ch] );
Copy( sts[ch]->input_fx, shift_mem + size_ovl - shift[ch], shift[ch] );
+ q_shift_mem = sts[ch]->q_inp;
+ move16();
}
ELSE
{
/*shift past part*/
Copy( mdct_mem[ch] + shift[ch], shift_mem, input_frame - shift[ch] );
Copy( sts[ch]->input_fx, shift_mem + input_frame - shift[ch], shift[ch] );
+ q_shift_mem = sts[ch]->q_inp;
+ move16();
}
/*shift current part*/
Copy( sts[ch]->input_fx + shift[ch], shift_input, input_frame - shift[ch] );
@@ -490,7 +496,9 @@ void stereo_td_itd_fx(
ELSE
{
Copy( shift_mem, mdct_mem[ch], input_frame );
- Scale_sig( mdct_mem[ch], input_frame, sub( sts[ch]->q_inp, *q_input_mem ) );
+ sts[ch]->q_old_inp = q_new_shift;
+ move16();
+ Scale_sig( mdct_mem[ch], input_frame, sub( sts[ch]->q_inp, q_shift_mem ) );
}
}
}
diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c
index dbf4e1f7cfe5cb2b388a9e22e8133c46a40e9c3a..6020d83516321a44fe1a58e145ac74e88aee9971 100644
--- a/lib_enc/ivas_stereo_ica_enc.c
+++ b/lib_enc/ivas_stereo_ica_enc.c
@@ -52,14 +52,14 @@
static void unclr_calc_corr_features_fx(
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier handle */
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: ICA Stereo Encoder handle */
- Word32 buf1[], /* i : left channel */
- Word32 buf2[], /* i : right channel */
+ Word32 buf1[], /* i : left channel q_com*/
+ Word32 buf2[], /* i : right channel q_com*/
Word16 q_com,
- const Word16 length, /* i : length of input signal buffers */
- Word32 corrEst[], /* i : buffer containing inter-channel correlation values */
+ const Word16 length, /* i : length of input signal buffers Q0*/
+ Word32 corrEst[], /* i : buffer containing inter-channel correlation values Q31-corrEst_exp*/
Word16 corrEst_exp,
- const int16_t lagSearchRange[], /* i : minimum and maximum lags for corrEst[] */
- Word32 *corrEst_ncorr, /* o : norm. x-correlation btw. current and previous correlation buffers */
+ const Word16 lagSearchRange[], /* i : minimum and maximum lags for corrEst[] Q0*/
+ Word32 *corrEst_ncorr, /* o : norm. x-correlation btw. current and previous correlation buffers Q31-corrEst_ncorr_exp*/
Word16 *corrEst_ncorr_exp );
@@ -67,7 +67,7 @@ static void unclr_calc_corr_features_fx(
#define XH_BIAS_FX_Q15 13107
#define XL_WIDTH_FX_Q15 3932
#define XH_WIDTH_FX_Q15 4915
-#define SMOOTH_DIST_FACTOR_FX_Q15 14418
+#define SMOOTH_DIST_FACTOR_FX_Q15 13107
#define A_BIAS_FX_Q15 3277
#define B_BIAS_FX_Q15 -16384
#define A_WIDTH_FX_Q31 32212264
@@ -82,11 +82,11 @@ static void unclr_calc_corr_features_fx(
* ---------------------------------------------------------------*/
static void tcaTargetCh_LA_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA,
- Word32 *ptrChanL,
- Word32 *ptrChanR,
+ Word32 *ptrChanL, /* q_com */
+ Word32 *ptrChanR, /* q_com */
Word16 *q_com,
- const Word16 currentNCShift,
- const Word16 input_frame )
+ const Word16 currentNCShift, /* Q0 */
+ const Word16 input_frame /* Q0 */ )
{
Word16 i, j;
Word16 tempS, temp, sine_inp;
@@ -121,44 +121,46 @@ static void tcaTargetCh_LA_fx(
move32();
tempF2_exp = 0;
move16();
- FOR( i = 0; i < sub( input_frame, currentNCShift ); i++ )
+ FOR( i = 0; i < ( input_frame - currentNCShift ); i++ )
{
- tempF1 = BASOP_Util_Add_Mant32Exp( tempF1, tempF1_exp, L_abs( ref[i] ), ref_exp, &tempF1_exp );
- tempF2 = BASOP_Util_Add_Mant32Exp( tempF2, tempF2_exp, L_abs( target[i + currentNCShift] ), target_exp, &tempF2_exp );
+ tempF1 = BASOP_Util_Add_Mant32Exp( tempF1, tempF1_exp, L_abs( ref[i] ), ref_exp, &tempF1_exp ); /* Q31-tempF1_exp */
+ tempF2 = BASOP_Util_Add_Mant32Exp( tempF2, tempF2_exp, L_abs( target[i + currentNCShift] ), target_exp, &tempF2_exp ); /* Q31-tempF2_exp */
}
IF( tempF1 == 0 )
{
- gAdj = ONE_IN_Q31;
+ gAdj = ONE_IN_Q31; /* Q31 */
move32();
gAdj_exp = 0;
move16();
}
ELSE
{
- Word32 deno = BASOP_Util_Add_Mant32Exp( tempF1, tempF1_exp, -21475 /*0.00001f in Q31*/, 0, &temp );
+ Word32 deno = BASOP_Util_Add_Mant32Exp( tempF1, tempF1_exp, -21475 /*0.00001f in Q31*/, 0, &temp ); /* Q31-temp */
Word16 deno_exp;
IF( deno > 0 )
{
deno = tempF1;
+ move32();
deno_exp = tempF1_exp;
+ move16();
}
ELSE
{
deno = 21475;
+ move32();
deno_exp = 0;
+ move16();
}
- move32();
- move32();
- gAdj = BASOP_Util_Divide3232_Scale_cadence( tempF2, deno, &gAdj_exp );
+ gAdj = BASOP_Util_Divide3232_Scale_cadence( tempF2, deno, &gAdj_exp ); /* Q31-gAdj_exp */
gAdj_exp = add( gAdj_exp, sub( tempF2_exp, deno_exp ) );
}
FOR( i = 0; i < tempS; i++ )
{
- sine_inp = BASOP_Util_Divide1616_Scale( add( shl( i, 10 ), 512 ), shl( tempS, 1 ), &temp );
- sine_inp = shl_sat( sine_inp, add( temp, -10 ) );
- win[i] = getSineWord16R2( shr( sine_inp, 1 ) );
+ sine_inp = BASOP_Util_Divide1616_Scale( add( shl( i, 10 ), 512 /* 0.5 Q10 */ ), shl( tempS, 1 ), &temp ); /* Q15-(temp+(15-10)) */
+ sine_inp = shl_sat( sine_inp, add( temp, -10 ) ); /*Q0*/
+ win[i] = getSineWord16R2( shr( sine_inp, 1 ) ); /*Q15*/
move16();
}
@@ -167,9 +169,9 @@ static void tcaTargetCh_LA_fx(
Word16 exp_com = target_exp_temp[0];
move16();
- FOR( i = sub( input_frame, add( currentNCShift, tempS ) ); i < sub( input_frame, currentNCShift ); ( i++, j++ ) )
+ FOR( i = ( input_frame - ( currentNCShift + tempS ) ); i < ( input_frame - currentNCShift ); ( i++, j++ ) )
{
- target[i + currentNCShift] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( Mpy_32_16_1( gAdj, win[j] ), ref[i] ), add( ref_exp, gAdj_exp ), Mpy_32_16_1( target[i + currentNCShift], sub( MAX_16, win[j] ) ), target_exp, &temp );
+ target[i + currentNCShift] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( Mpy_32_16_1( gAdj, win[j] ), ref[i] ), add( ref_exp, gAdj_exp ), Mpy_32_16_1( target[i + currentNCShift], sub( MAX_16, win[j] ) ), target_exp, &temp ); /* Q31-temp */
move32();
target_exp_temp[i + currentNCShift] = temp;
move16();
@@ -178,7 +180,7 @@ static void tcaTargetCh_LA_fx(
FOR( ; i < input_frame; i++ )
{
- target[i + currentNCShift] = Mpy_32_32( gAdj, ref[i] );
+ target[i + currentNCShift] = Mpy_32_32( gAdj, ref[i] ); /* Q31-target_exp_temp */
move32();
target_exp_temp[i + currentNCShift] = add( gAdj_exp, ref_exp );
move16();
@@ -187,9 +189,9 @@ static void tcaTargetCh_LA_fx(
FOR( i = 0; i < input_frame; i++ )
{
- target[i] = L_shl( target[i], sub( target_exp_temp[i], exp_com ) );
+ target[i] = L_shl( target[i], sub( target_exp_temp[i], exp_com ) ); /* Q31-exp_com */
move32();
- ref[i] = L_shl( ref[i], sub( ref_exp, exp_com ) );
+ ref[i] = L_shl( ref[i], sub( ref_exp, exp_com ) ); /* Q31-exp_com */
move32();
}
*q_com = sub( 31, exp_com );
@@ -206,8 +208,8 @@ static void tcaTargetCh_LA_fx(
void spectral_balancer_fx16(
Word16 *signal, /* i/o : signal Qx */
Word16 *mem, /* i/o : mem Qx */
- const Word16 lg, /* i : input signal length */
- const Word16 coeff_set /* i : coefficient set */
+ const Word16 lg, /* i : input signal length Q0*/
+ const Word16 coeff_set /* i : coefficient set Q0*/
)
{
Word16 i;
@@ -268,26 +270,26 @@ void spectral_balancer_fx16(
FOR( i = 0; i < lg; i++ )
{
- x2 = x1;
+ x2 = x1; /*Qx*/
move16();
- x1 = x0;
+ x1 = x0; /*Qx*/
move16();
- x0 = signal[i];
+ x0 = signal[i]; /*Qx*/
move16();
// y0 = (y1 * a1) + (y2 * a2) + (x0 * b0) + (x1 * b1) + (x2 * b2);
y0 = extract_l( W_extract_l( W_shr( W_mac_32_16( W_mac_32_16( W_mac_32_16( W_mac_32_16( W_mult_32_16( a1, y1 ), a2, y2 ), b0, x0 ), b1, x1 ), b2, x2 ), 30 ) ) ); // Qx
- signal[i] = y0;
+ signal[i] = y0; /*Qx*/
move16();
- y2 = y1;
+ y2 = y1; /*Qx*/
move16();
- y1 = y0;
+ y1 = y0; /*Qx*/
move16();
}
- mem[0] = y1;
- mem[1] = y2;
- mem[2] = x0;
- mem[3] = x1;
+ mem[0] = y1; /*Qx*/
+ mem[1] = y2; /*Qx*/
+ mem[2] = x0; /*Qx*/
+ mem[3] = x1; /*Qx*/
move16();
move16();
move16();
@@ -299,18 +301,18 @@ void spectral_balancer_fx16(
void spectral_balancer_fx(
Word32 *signal, /* i/o : signal Qx */
Word32 *mem, /* i/o : mem Qx */
- const Word16 lg, /* i : input signal length */
- const Word16 coeff_set /* i : coefficient set */
+ const Word16 lg, /* i : input signal length Q0*/
+ const Word16 coeff_set /* i : coefficient set Q0*/
)
{
Word16 i;
Word32 x0, x1, x2, y0, y1, y2;
Word32 a1, a2, b0, b1, b2;
- y1 = mem[0];
- y2 = mem[1];
- x0 = mem[2];
- x1 = mem[3];
+ y1 = mem[0]; /*Qx*/
+ y2 = mem[1]; /*Qx*/
+ x0 = mem[2]; /*Qx*/
+ x1 = mem[3]; /*Qx*/
move32();
move32();
move32();
@@ -351,28 +353,28 @@ void spectral_balancer_fx(
FOR( i = 0; i < lg; i++ )
{
- x2 = x1;
+ x2 = x1; /*Qx*/
move16();
- x1 = x0;
+ x1 = x0; /*Qx*/
move16();
- x0 = signal[i];
+ x0 = signal[i]; /*Qx*/
move16();
y0 = W_extract_l( W_shr( W_mac_32_32( W_mac_32_32( W_mac_32_32( W_mac_32_32( W_mult_32_32( a1, y1 ), a2, y2 ), b0, x0 ), b1, x1 ), b2, x2 ), 30 ) ); // Qx
- signal[i] = y0;
+ signal[i] = y0; /*Qx*/
move16();
- y2 = y1;
+ y2 = y1; /*Qx*/
move16();
- y1 = y0;
+ y1 = y0; /*Qx*/
move16();
}
- mem[0] = y1;
+ mem[0] = y1; /*Qx*/
move32();
- mem[1] = y2;
+ mem[1] = y2; /*Qx*/
move32();
- mem[2] = x0;
+ mem[2] = x0; /*Qx*/
move32();
- mem[3] = x1;
+ mem[3] = x1; /*Qx*/
move32();
return;
@@ -384,14 +386,14 @@ void spectral_balancer_fx(
*
* De-emphasize and resample the L and R channels.
* ---------------------------------------------------------------*/
-static void deEmphResample(
+static void deEmphResample_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA encoder handle */
const Word32 *tempChan1_fx, /* i : Stereo data Qx*/
const Word32 *tempChan2_fx, /* i : Stereo data Qx*/
- Word32 *chan1_fx, // Qx
- Word32 *chan2_fx, // Qx
- const Word16 input_frame,
- const Word16 dsFactor )
+ Word32 *chan1_fx, /*Qx*/
+ Word32 *chan2_fx, /*Qx*/
+ const Word16 input_frame, /*Q0*/
+ const Word16 dsFactor /*Q0*/ )
{
Word32 buf1_fx[L_FRAME48k], buf2_fx[L_FRAME48k];
Word32 tempBuf1_fx[2 * L_FRAME_DS], tempBuf2_fx[2 * L_FRAME_DS];
@@ -399,23 +401,23 @@ static void deEmphResample(
Word16 dsFac1, dsFac2;
/* Estimate first and second stage downsample factors */
- dsFac1 = shr( dsFactor, 1 );
- dsFac2 = idiv1616( dsFactor, dsFac1 );
+ dsFac1 = shr( dsFactor, 1 ); /*Qx*/
+ dsFac2 = idiv1616( dsFactor, dsFac1 ); /*Qx*/
/* convert stereo data to two distinct channels, e.g., L, R */
- Copy32( tempChan1_fx, buf1_fx, input_frame );
- Copy32( tempChan2_fx, buf2_fx, input_frame );
+ Copy32( tempChan1_fx, buf1_fx, input_frame ); /*Qx*/
+ Copy32( tempChan2_fx, buf2_fx, input_frame ); /*Qx*/
/* De-emphasis, 1/(1-mu z^-1), and resample, stage 1 */
deemph_fx_32( 0, buf1_fx, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim_fx[0] );
deemph_fx_32( 0, buf2_fx, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim_fx[1] );
- FOR( i = 0; i < idiv1616( input_frame, dsFac1 ); i++ )
+ FOR( i = 0; i < ( input_frame / dsFac1 ); i++ )
{
- tempBuf1_fx[i] = buf1_fx[i * dsFac1];
+ tempBuf1_fx[i] = buf1_fx[i * dsFac1]; /*Qx*/
move32();
- tempBuf2_fx[i] = buf2_fx[i * dsFac1];
+ tempBuf2_fx[i] = buf2_fx[i * dsFac1]; /*Qx*/
move32();
}
@@ -423,11 +425,11 @@ static void deEmphResample(
deemph_fx_32( 0, tempBuf1_fx, PREEMPH_FAC_16k, idiv1616( input_frame, dsFac1 ), &hStereoTCA->memdecim_fx[2] );
deemph_fx_32( 0, tempBuf2_fx, PREEMPH_FAC_16k, idiv1616( input_frame, dsFac1 ), &hStereoTCA->memdecim_fx[3] );
- FOR( i = 0; i < idiv1616( input_frame, dsFactor ); i++ )
+ FOR( i = 0; i < ( input_frame / dsFactor ); i++ )
{
- chan1_fx[i] = tempBuf1_fx[i * dsFac2];
+ chan1_fx[i] = tempBuf1_fx[i * dsFac2]; /*Qx*/
move32();
- chan2_fx[i] = tempBuf2_fx[i * dsFac2];
+ chan2_fx[i] = tempBuf2_fx[i * dsFac2]; /*Qx*/
move32();
}
@@ -444,13 +446,13 @@ static void deEmphResample(
* ---------------------------------------------------------------*/
static void utilCrossCorr_mod_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: ICA Stereo Encoder handle */
- Word32 *buf1,
- Word32 *buf2,
+ Word32 *buf1, /*q_com*/
+ Word32 *buf2, /*q_com*/
const Word16 q_com,
- Word32 *corrEst, /* o : correlation estimate */
- Word16 *corrEst_Exp, /* o : correlation estimate */
- const Word16 *lagSearchRange,
- const Word16 len )
+ Word32 *corrEst, /* o : correlation estimate Q31-corrEst_Exp*/
+ Word16 *corrEst_Exp, /* o : correlation estimate Q31-corrEst_Exp*/
+ const Word16 *lagSearchRange, /*Q0*/
+ const Word16 len /*Q0*/ )
{
Word32 C, E1, E2, C_C_mem;
Word16 i, j, E1_exp, E2_exp, Inv_Tot_E_exp, k, C_exp, exp, gb;
@@ -463,33 +465,34 @@ static void utilCrossCorr_mod_fx(
gb = 0;
move16();
- if ( LT_16( L_norm_arr( buf1, len ), 2 ) )
+ IF( LT_16( L_norm_arr( buf1, len ), 2 ) )
{
gb = 2;
move16();
}
- E1 = sum2_32_exp_fx( buf1, len, &E1_exp, gb );
+ E1 = sum2_32_exp_fx( buf1, len, &E1_exp, gb ); /* Q31-E1_exp */
gb = 0;
move16();
- if ( LT_16( L_norm_arr( buf2, len ), 2 ) )
+ IF( LT_16( L_norm_arr( buf2, len ), 2 ) )
{
gb = 2;
move16();
}
- E2 = sum2_32_exp_fx( buf2, len, &E2_exp, gb );
+ E2 = sum2_32_exp_fx( buf2, len, &E2_exp, gb ); /* Q31-E2_exp */
- Word32 E1_mul = BASOP_Util_Add_Mant32Exp( E1, E1_exp, hStereoTCA->E1_mem_fx, hStereoTCA->E1_mem_exp, &E1_exp );
- Word32 E2_mul = BASOP_Util_Add_Mant32Exp( E2, E2_exp, hStereoTCA->E2_mem_fx, hStereoTCA->E2_mem_exp, &E2_exp );
+ Word16 temp1, temp2;
+ Word32 E1_mul = BASOP_Util_Add_Mant32Exp( E1, E1_exp, hStereoTCA->E1_mem_fx, hStereoTCA->E1_mem_exp, &temp1 ); /* Q31-temp1 */
+ Word32 E2_mul = BASOP_Util_Add_Mant32Exp( E2, E2_exp, hStereoTCA->E2_mem_fx, hStereoTCA->E2_mem_exp, &temp2 ); /* Q31-temp2 */
Word32 sqr_inp = Mpy_32_32( E1_mul, E2_mul );
- Word16 sq_exp = add( E1_exp, E2_exp );
+ Word16 sq_exp = add( temp1, temp2 );
IF( sqr_inp )
{
- sqr_inp = Sqrt32( sqr_inp, &sq_exp );
- sqr_inp = Mpy_32_32( sqr_inp, 1342177280 /* 320 in Q22*/ );
+ sqr_inp = Sqrt32( sqr_inp, &sq_exp ); /* Q31-sq_exp */
+ sqr_inp = Mpy_32_32( sqr_inp, 1342177280 /* 320 in Q22*/ ); /* Q31-sq_exp+22-31 */
sq_exp = add( sq_exp, 9 );
- Inv_Tot_E = BASOP_Util_Divide3232_Scale( ONE_IN_Q31, sqr_inp, &Inv_Tot_E_exp );
+ Inv_Tot_E = BASOP_Util_Divide3232_Scale( ONE_IN_Q31, sqr_inp, &Inv_Tot_E_exp ); /* Q15-Inv_Tot_E_exp */
Inv_Tot_E_exp = add( Inv_Tot_E_exp, sub( 0, sq_exp ) );
}
ELSE
@@ -500,9 +503,9 @@ static void utilCrossCorr_mod_fx(
move16();
}
- hStereoTCA->E1_mem_fx = E1;
+ hStereoTCA->E1_mem_fx = E1; /* Q31-E1_exp */
move32();
- hStereoTCA->E2_mem_fx = E2;
+ hStereoTCA->E2_mem_fx = E2; /* Q31-E2_exp */
move32();
hStereoTCA->E1_mem_exp = E1_exp;
move16();
@@ -511,21 +514,20 @@ static void utilCrossCorr_mod_fx(
*corrEst_Exp = corrEst_exp[0];
move16();
- /* FOR BASOP causing error/warning */
- for ( i = lagSearchRange[0], j = 0; i <= 0; i++, j++ )
+ FOR( ( i = lagSearchRange[0], j = 0 ); i <= 0; ( i++, j++ ) )
{
L64_sum = 1;
move64();
FOR( k = 0; k < len; k++ )
{
- L64_sum = W_mac_32_32( L64_sum, buf1[k], buf2[k + i] );
+ L64_sum = W_mac_32_32( L64_sum, buf1[k], buf2[k + i] ); /* 2*q_com+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- C = W_extract_h( L64_sum ); // ener_side_q
+ L64_sum = W_shl( L64_sum, k ); /* 2*q_com+1+k */
+ C = W_extract_h( L64_sum ); // ener_side_q
C_exp = sub( 31, sub( add( add( shl( q_com, 1 ), 1 ), k ), 32 ) );
- C_C_mem = BASOP_Util_Add_Mant32Exp( C, C_exp, hStereoTCA->C_mem_fx[j], hStereoTCA->C_mem_exp[j], &exp );
- corrEst[j] = Mpy_32_16_1( C_C_mem, Inv_Tot_E );
+ C_C_mem = BASOP_Util_Add_Mant32Exp( C, C_exp, hStereoTCA->C_mem_fx[j], hStereoTCA->C_mem_exp[j], &exp ); /* Q31-exp */
+ corrEst[j] = Mpy_32_16_1( C_C_mem, Inv_Tot_E ); /* Q31-corrEst_exp */
move32();
corrEst_exp[j] = add( Inv_Tot_E_exp, exp );
move16();
@@ -537,21 +539,20 @@ static void utilCrossCorr_mod_fx(
move16();
}
- /* FOR BASOP causing error/warning */
- for ( ; i <= lagSearchRange[1]; i++, j++ )
+ FOR( ; i <= lagSearchRange[1]; ( i++, j++ ) )
{
L64_sum = 1;
move64();
FOR( k = 0; k < len; k++ )
{
- L64_sum = W_mac_32_32( L64_sum, buf1[k - i], buf2[k] );
+ L64_sum = W_mac_32_32( L64_sum, buf1[k - i], buf2[k] ); /* 2*q_com+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- C = W_extract_h( L64_sum ); // ener_side_q
+ L64_sum = W_shl( L64_sum, k ); /* 2*q_com+1+k */
+ C = W_extract_h( L64_sum ); // ener_side_q
C_exp = sub( 31, sub( add( add( shl( q_com, 1 ), 1 ), k ), 32 ) );
- C_C_mem = BASOP_Util_Add_Mant32Exp( C, C_exp, hStereoTCA->C_mem_fx[j], hStereoTCA->C_mem_exp[j], &exp );
- corrEst[j] = Mpy_32_16_1( C_C_mem, Inv_Tot_E );
+ C_C_mem = BASOP_Util_Add_Mant32Exp( C, C_exp, hStereoTCA->C_mem_fx[j], hStereoTCA->C_mem_exp[j], &exp ); /* Q31-exp */
+ corrEst[j] = Mpy_32_16_1( C_C_mem, Inv_Tot_E ); /* Q31-corrEst_exp */
move32();
corrEst_exp[j] = add( Inv_Tot_E_exp, exp );
move16();
@@ -567,7 +568,7 @@ static void utilCrossCorr_mod_fx(
FOR( i = 0; i < ( 2 * L_NCSHIFT_DS + 1 ); i++ )
{
- corrEst[i] = L_shl( corrEst[i], sub( corrEst_exp[i], *corrEst_Exp ) );
+ corrEst[i] = L_shl( corrEst[i], sub( corrEst_exp[i], *corrEst_Exp ) ); /* Q31-corrEst_Exp */
move32();
}
@@ -584,12 +585,12 @@ static void utilCrossCorr_fx(
Word16 buf1_q,
const Word32 *buf2, // buf2_q
Word16 buf2_q,
- const Word32 *win,
- Word32 *corrEst, /* o : correlation estimate corrEst_e */
+ const Word32 *win, /*Qx*/
+ Word32 *corrEst, /* o : correlation estimate corrEst_e */
Word16 *corrEst_e,
- const Word16 *lagSearchRange,
- const Word16 len,
- const Word16 winSymmFlag )
+ const Word16 *lagSearchRange, /*Q0*/
+ const Word16 len, /*Q0*/
+ const Word16 winSymmFlag /*Q0*/ )
{
Word32 tempBuf1[L_FRAME48k];
Word32 tempBuf2[L_FRAME48k];
@@ -619,17 +620,17 @@ static void utilCrossCorr_fx(
FOR( i = shr( len, 1 ); i < len; i++ )
{
- tempBuf1[i] = Mpy_32_32( win[len - 1 - i], buf1[i] );
+ tempBuf1[i] = Mpy_32_32( win[len - 1 - i], buf1[i] ); /* Qx+buf1_q-31 */
move32();
- tempBuf2[i] = Mpy_32_32( win[len - 1 - i], buf2[i] );
+ tempBuf2[i] = Mpy_32_32( win[len - 1 - i], buf2[i] ); /* Qx+buf2_q-31 */
move32();
}
}
}
ELSE
{
- Copy32( buf1, tempBuf1, len );
- Copy32( buf2, tempBuf2, len );
+ Copy32( buf1, tempBuf1, len ); /* buf1_q */
+ Copy32( buf2, tempBuf2, len ); /* buf2_q */
}
Word16 temp1_e = sub( Q31, buf1_q );
@@ -653,20 +654,20 @@ static void utilCrossCorr_fx(
assert( lagSearchRange[0] <= lagSearchRange[1] );
/* first part of noncausal corr est. */
- for ( i = lagSearchRange[0], j = 0; i <= s_min( 0, lagSearchRange[1] ); ( i++, j++ ) )
+ FOR( ( i = lagSearchRange[0], j = 0 ); i <= s_min( 0, lagSearchRange[1] ); ( i++, j++ ) )
{
L64_sum = 0;
move64();
- FOR( k = 0; k < add( len, i ); k++ )
+ FOR( k = 0; k < ( len + i ); k++ )
{
- L64_sum = W_mac_32_32( L64_sum, buf1[k - i], buf2[k] );
+ L64_sum = W_mac_32_32( L64_sum, buf1[k - i], buf2[k] ); /* buf1_q+buf2_q+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- temp = W_extract_h( L64_sum );
+ L64_sum = W_shl( L64_sum, k ); /* buf1_q+buf2_q+1+k */
+ temp = W_extract_h( L64_sum ); /* buf1_q+buf2_q+1+k-32 */
res_e = sub( 31, sub( add( add( add( buf1_q, buf2_q ), 1 ), k ), 32 ) );
- corrEst[j] = L_deposit_h( BASOP_Util_Divide3216_Scale( temp, ( len + i ), &tmp_e ) );
+ corrEst[j] = L_deposit_h( BASOP_Util_Divide3216_Scale( temp, ( len + i ), &tmp_e ) ); /* Q31-max_e */
move32();
corrEstTemp_e[j] = add( tmp_e, sub( res_e, 15 ) );
move16();
@@ -674,20 +675,20 @@ static void utilCrossCorr_fx(
}
/* second part of noncausal corr est. */
- for ( ; i <= lagSearchRange[1]; ( i++, j++ ) )
+ FOR( ; i <= lagSearchRange[1]; ( i++, j++ ) )
{
L64_sum = 1;
move64();
FOR( k = 0; k < sub( len, i ); k++ )
{
- L64_sum = W_mac_32_32( L64_sum, buf1[k], buf2[k + i] );
+ L64_sum = W_mac_32_32( L64_sum, buf1[k], buf2[k + i] ); /* buf1_q+buf2_q+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- temp = W_extract_h( L64_sum );
+ L64_sum = W_shl( L64_sum, k ); /* buf1_q+buf2_q+1+k */
+ temp = W_extract_h( L64_sum ); /* buf1_q+buf2_q+1+k-32 */
res_e = sub( 31, sub( add( add( add( buf1_q, buf2_q ), 1 ), k ), 32 ) );
- corrEst[j] = L_deposit_h( BASOP_Util_Divide3216_Scale( temp, ( len - i ), &tmp_e ) );
+ corrEst[j] = L_deposit_h( BASOP_Util_Divide3216_Scale( temp, ( len - i ), &tmp_e ) ); /* Q31-max_e */
move32();
corrEstTemp_e[j] = add( tmp_e, sub( res_e, 15 ) );
move16();
@@ -698,7 +699,7 @@ static void utilCrossCorr_fx(
FOR( i = 0; i < j; i++ )
{
- corrEst[i] = L_shr( corrEst[i], sub( max_e, corrEstTemp_e[i] ) );
+ corrEst[i] = L_shr( corrEst[i], sub( max_e, corrEstTemp_e[i] ) ); /* Q31-corrEstTemp_e */
move32();
}
@@ -716,22 +717,23 @@ static void utilCrossCorr_fx(
* Non-causal shift estimation to encode future samples.
* ---------------------------------------------------------------*/
-static Word16 TRUNC_FX( Word32 inp, Word16 exp )
+static Word16 TRUNC_FX( Word32 inp /*Q31-exp*/, Word16 exp )
{
Word16 ouptut;
Word32 temp;
- temp = L_shr( inp, sub( 31, exp ) );
+ temp = L_shr( inp, sub( 31, exp ) ); /*Q0*/
test();
IF( GT_32( temp, 32767 ) || LT_32( temp, -32768 ) )
{
+ test();
IF( temp < 0 )
{
- ouptut = -32768;
+ ouptut = -32768; /*Q0*/
}
ELSE
{
- ouptut = 32767;
+ ouptut = 32767; /*Q0*/
}
move16();
}
@@ -739,31 +741,31 @@ static Word16 TRUNC_FX( Word32 inp, Word16 exp )
{
IF( NE_32( temp, L_shl_sat( 1, sub( 31, exp ) ) ) )
{
- Word32 temp1 = L_add_sat( inp, L_shl_sat( 1, sub( 31, add( exp, 1 ) ) ) );
- ouptut = (Word16) L_shr( temp1, sub( 31, exp ) );
+ Word32 temp1 = L_add_sat( inp, L_shl_sat( 1, sub( 31, add( exp, 1 ) ) ) ); /* Q31-exp */
+ ouptut = extract_l( L_shr( temp1, sub( 31, exp ) ) ); /*Q0*/
IF( temp < 0 )
{
- ouptut = add( ouptut, 1 );
+ ouptut = add( ouptut, 1 ); /*Q0*/
}
}
ELSE
{
- ouptut = (Word16) temp;
+ ouptut = extract_l( temp ); /*Q0*/
move16();
}
}
- return ouptut;
+ return ouptut; /*Q0*/
}
static void corrStatsEst_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA Encoder handle */
Word32 *buf1_fx, /* i : channel 1 q_com*/
Word32 *buf2_fx, /* i : channel 2 q_com*/
Word16 q_com,
- const Word16 bufLenDS, /* i : buffer length */
- const Word16 dsFactor, /* i : buffer length */
- const Word16 vad_flag1, /* i : VAD flag channel 1 */
- const Word16 vad_flag2, /* i : VAD flag channel 2 */
+ const Word16 bufLenDS, /* i : buffer length Q0*/
+ const Word16 dsFactor, /* i : buffer length Q0*/
+ const Word16 vad_flag1, /* i : VAD flag channel 1 Q0*/
+ const Word16 vad_flag2, /* i : VAD flag channel 2 Q0*/
STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier handle */
)
{
@@ -831,46 +833,36 @@ static void corrStatsEst_fx(
/* back up the corrEst */
FOR( i = 0; i < 2; i++ )
{
- Copy32( hStereoTCA->corrEstPrev_fx[i + 1], hStereoTCA->corrEstPrev_fx[i], tempLen );
+ Copy32( hStereoTCA->corrEstPrev_fx[i + 1], hStereoTCA->corrEstPrev_fx[i], tempLen ); /* Q31-hStereoTCA->corrEstPrev_exp */
}
temp = getScaleFactor32( corrEst_fx, 2 * L_NCSHIFT_DS + 1 );
- scale_sig32( corrEst_fx, 2 * L_NCSHIFT_DS + 1, temp );
+ scale_sig32( corrEst_fx, 2 * L_NCSHIFT_DS + 1, temp ); /* Q31-corrEst_exp */
corrEst_exp = sub( corrEst_exp, temp );
- IF( GT_16( corrEst_exp, hStereoTCA->corrEstPrev_exp ) )
- {
- scale_sig32( hStereoTCA->corrEstPrev_fx[0], 2 * L_NCSHIFT_DS + 1, sub( hStereoTCA->corrEstPrev_exp, corrEst_exp ) );
- scale_sig32( hStereoTCA->corrEstPrev_fx[1], 2 * L_NCSHIFT_DS + 1, sub( hStereoTCA->corrEstPrev_exp, corrEst_exp ) );
- Copy32( corrEst_fx, hStereoTCA->corrEstPrev_fx[2], tempLen );
- hStereoTCA->corrEstPrev_exp = corrEst_exp;
- move16();
- }
- ELSE
- {
- Copy32( corrEst_fx, hStereoTCA->corrEstPrev_fx[2], tempLen );
- scale_sig32( hStereoTCA->corrEstPrev_fx[2], 2 * L_NCSHIFT_DS + 1, sub( corrEst_exp, hStereoTCA->corrEstPrev_exp ) );
- }
- scale_sig32( hStereoTCA->corrEstPrev_fx[0], 2 * L_NCSHIFT_DS + 1, -1 );
- scale_sig32( hStereoTCA->corrEstPrev_fx[1], 2 * L_NCSHIFT_DS + 1, -1 );
- scale_sig32( hStereoTCA->corrEstPrev_fx[2], 2 * L_NCSHIFT_DS + 1, -1 );
- hStereoTCA->corrEstPrev_exp = add( hStereoTCA->corrEstPrev_exp, 1 );
+ Copy32( corrEst_fx, hStereoTCA->corrEstPrev_fx[2], tempLen ); /* Q31-corrEst_exp */
+ hStereoTCA->corrEstPrev_exp = corrEst_exp;
+ move16();
+ Word16 gb = find_guarded_bits_fx( 2 * L_NCSHIFT_DS + 1 );
+
+ scale_sig32( hStereoTCA->corrEstPrev_fx[2], 2 * L_NCSHIFT_DS + 1, -gb ); /* Q31-hStereoTCA->corrEstPrev_exp-1 */
+ hStereoTCA->corrEstPrev_exp = add( hStereoTCA->corrEstPrev_exp, gb );
move16();
Word32 buf1_fx_temp[L_FRAME_DS];
Word32 buf2_fx_temp[L_FRAME_DS];
- Copy32( buf1_fx, buf1_fx_temp, L_FRAME_DS );
- Copy32( buf2_fx, buf2_fx_temp, L_FRAME_DS );
+ Copy32( buf1_fx, buf1_fx_temp, L_FRAME_DS ); /* q_com */
+ Copy32( buf2_fx, buf2_fx_temp, L_FRAME_DS ); /* q_com */
- scale_sig32( buf1_fx_temp, L_FRAME_DS, -4 );
- scale_sig32( buf2_fx_temp, L_FRAME_DS, -4 );
+ scale_sig32( buf1_fx_temp, L_FRAME_DS, -4 ); /* q_com-4 */
+ scale_sig32( buf2_fx_temp, L_FRAME_DS, -4 ); /* q_com-4 */
temp_A_fx = L_add( sumAbs_fx( buf1_fx_temp, L_FRAME_DS - L_XCORRMEM_DS ), sumAbs_fx( buf2_fx_temp, L_FRAME_DS - L_XCORRMEM_DS ) );
temp_B_fx = L_add( sumAbs_fx( buf1_fx_temp + ( L_FRAME_DS - L_XCORRMEM_DS ), L_XCORRMEM_DS ), sumAbs_fx( buf2_fx_temp + ( L_FRAME_DS - L_XCORRMEM_DS ), L_XCORRMEM_DS ) );
- tempF_fx = BASOP_Util_Add_Mant32Exp( L_add( temp_A_fx, temp_B_fx ), sub( 31, sub( q_com, 4 ) ), hStereoTCA->mem_tempF_fx, hStereoTCA->mem_tempF_exp, &temp );
+ tempF_fx = BASOP_Util_Add_Mant32Exp( L_add( temp_A_fx, temp_B_fx ), sub( 31, sub( q_com, 4 ) ), hStereoTCA->mem_tempF_fx, hStereoTCA->mem_tempF_exp, &temp ); /* Q31-tempF_exp */
Word16 tempF_exp = temp;
- hStereoTCA->mem_tempF_fx = temp_B_fx;
+ hStereoTCA->mem_tempF_fx = temp_B_fx; /* Q31-hStereoTCA->mem_tempF_exp */
move32();
hStereoTCA->mem_tempF_exp = sub( 31, sub( q_com, 4 ) );
move16();
@@ -894,18 +886,18 @@ static void corrStatsEst_fx(
move32();
/* long term corr Stats estimation */
- v_multc_fixed_16( hStereoTCA->corrEstLT_fx, alpha_fx, hStereoTCA->corrEstLT_fx, 2 * L_NCSHIFT_DS + 1 );
- v_multc_fixed_16( corrEst_fx, sub( MAX_16, alpha_fx ), corrEst_fx, 2 * L_NCSHIFT_DS + 1 );
+ v_multc_fixed_16( hStereoTCA->corrEstLT_fx, alpha_fx, hStereoTCA->corrEstLT_fx, 2 * L_NCSHIFT_DS + 1 ); /* Q31-hStereoTCA->corrEstLT_exp */
+ v_multc_fixed_16( corrEst_fx, sub( MAX_16, alpha_fx ), corrEst_fx, 2 * L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */
v_add_fixed_me( hStereoTCA->corrEstLT_fx, hStereoTCA->corrEstLT_exp, corrEst_fx, corrEst_exp, hStereoTCA->corrEstLT_fx, &hStereoTCA->corrEstLT_exp, 2 * L_NCSHIFT_DS + 1, 0 );
- hStereoTCA->ica_envVarLT_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->ica_envVarLT_fx, SMOOTH_ENV_FACTOR_FX_Q15 ), hStereoTCA->ica_envVarLT_exp, Mpy_32_16_1( tempF_fx, ONE_IN_Q15 - SMOOTH_ENV_FACTOR_FX_Q15 ), tempF_exp, &hStereoTCA->ica_envVarLT_exp ); // SMOOTH_ENV_FACTOR_FX_Q15
+ hStereoTCA->ica_envVarLT_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->ica_envVarLT_fx, SMOOTH_ENV_FACTOR_FX_Q15 ), hStereoTCA->ica_envVarLT_exp, Mpy_32_16_1( tempF_fx, ONE_IN_Q15 - SMOOTH_ENV_FACTOR_FX_Q15 ), tempF_exp, &hStereoTCA->ica_envVarLT_exp ); // SMOOTH_ENV_FACTOR_FX_Q15 (Q31-hStereoTCA->ica_envVarLT_exp)
move32();
- Copy32( hStereoTCA->corrEstLT_fx, corrEst_fx, 2 * L_NCSHIFT_DS + 1 );
+ Copy32( hStereoTCA->corrEstLT_fx, corrEst_fx, 2 * L_NCSHIFT_DS + 1 ); /* Q31-hStereoTCA->corrEstLT_exp */
corrEst_exp = hStereoTCA->corrEstLT_exp;
move16();
- Y_hat_fx = hStereoTCA->delay_0_mem_fx[0];
+ Y_hat_fx = hStereoTCA->delay_0_mem_fx[0]; /* Q31-hStereoTCA->delay_0_mem_exp */
move32();
Y_hat_exp = hStereoTCA->delay_0_mem_exp;
move16();
@@ -913,35 +905,35 @@ static void corrStatsEst_fx(
/* Note: keep X_hat and X_SQR_hat calculations inside the loop to allow future tuning of MAX_DELAYREGLEN */
FOR( i = 1; i < MAX_DELAYREGLEN; i++ )
{
- X_hat_fx = BASOP_Util_Add_Mant32Exp( X_hat_fx, X_hat_exp, L_shl( i, 27 ), 4, &X_hat_exp );
- Y_hat_fx = BASOP_Util_Add_Mant32Exp( Y_hat_fx, Y_hat_exp, hStereoTCA->delay_0_mem_fx[i], hStereoTCA->delay_0_mem_exp, &Y_hat_exp );
- XY_hat_fx = BASOP_Util_Add_Mant32Exp( XY_hat_fx, XY_hat_exp, Mpy_32_32( hStereoTCA->delay_0_mem_fx[i], L_shl( i, 27 ) ), add( 4, hStereoTCA->delay_0_mem_exp ), &XY_hat_exp );
- X_SQR_hat_fx = BASOP_Util_Add_Mant32Exp( X_SQR_hat_fx, X_SQR_hat_exp, Mpy_32_32( L_shl( i, 27 ), L_shl( i, 27 ) ), 8, &X_SQR_hat_exp );
+ X_hat_fx = BASOP_Util_Add_Mant32Exp( X_hat_fx, X_hat_exp, L_shl( i, 27 ), 4, &X_hat_exp ); /* Q31-X_hat_exp */
+ Y_hat_fx = BASOP_Util_Add_Mant32Exp( Y_hat_fx, Y_hat_exp, hStereoTCA->delay_0_mem_fx[i], hStereoTCA->delay_0_mem_exp, &Y_hat_exp ); /* Q31-Y_hat_exp */
+ XY_hat_fx = BASOP_Util_Add_Mant32Exp( XY_hat_fx, XY_hat_exp, Mpy_32_32( hStereoTCA->delay_0_mem_fx[i], L_shl( i, 27 ) ), add( 4, hStereoTCA->delay_0_mem_exp ), &XY_hat_exp ); /* Q31-XY_hat_exp */
+ X_SQR_hat_fx = BASOP_Util_Add_Mant32Exp( X_SQR_hat_fx, X_SQR_hat_exp, Mpy_32_32( L_shl( i, 27 ), L_shl( i, 27 ) ), 8, &X_SQR_hat_exp ); /* Q31-X_SQR_hat_exp */
}
- X_hat_fx = Mpy_32_16_1( X_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 );
- Y_hat_fx = Mpy_32_16_1( Y_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 );
- XY_hat_fx = Mpy_32_16_1( XY_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 );
- X_SQR_hat_fx = Mpy_32_16_1( X_SQR_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 );
+ X_hat_fx = Mpy_32_16_1( X_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 ); /* Q31-X_hat_exp */
+ Y_hat_fx = Mpy_32_16_1( Y_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 ); /* Q31-Y_hat_exp */
+ XY_hat_fx = Mpy_32_16_1( XY_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 ); /* Q31-XY_hat_exp */
+ X_SQR_hat_fx = Mpy_32_16_1( X_SQR_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 ); /* Q31-X_SQR_hat_exp */
beta_reg_fx = 0;
move32();
beta_reg_exp = 0;
move16();
- tempF_fx = BASOP_Util_Add_Mant32Exp( X_SQR_hat_fx, X_SQR_hat_exp, L_negate( Mpy_32_32( X_hat_fx, X_hat_fx ) ), shl( X_hat_exp, 1 ), &tempF_exp );
+ tempF_fx = BASOP_Util_Add_Mant32Exp( X_SQR_hat_fx, X_SQR_hat_exp, L_negate( Mpy_32_32( X_hat_fx, X_hat_fx ) ), shl( X_hat_exp, 1 ), &tempF_exp ); /* Q31-tempF_exp */
IF( tempF_fx != 0 )
{
- temp32 = BASOP_Util_Add_Mant32Exp( XY_hat_fx, XY_hat_exp, L_negate( Mpy_32_32( X_hat_fx, Y_hat_fx ) ), add( X_hat_exp, Y_hat_exp ), &exp );
- beta_reg_fx = BASOP_Util_Divide3232_Scale_cadence( temp32, tempF_fx, &beta_reg_exp );
+ temp32 = BASOP_Util_Add_Mant32Exp( XY_hat_fx, XY_hat_exp, L_negate( Mpy_32_32( X_hat_fx, Y_hat_fx ) ), add( X_hat_exp, Y_hat_exp ), &exp ); /* Q31-exp */
+ beta_reg_fx = BASOP_Util_Divide3232_Scale_cadence( temp32, tempF_fx, &beta_reg_exp ); /* Q31-beta_reg_exp */
if ( beta_reg_fx )
{
beta_reg_exp = add( beta_reg_exp, sub( exp, tempF_exp ) );
}
}
- alpha_reg_fx = BASOP_Util_Add_Mant32Exp( Y_hat_fx, Y_hat_exp, L_negate( Mpy_32_32( X_hat_fx, beta_reg_fx ) ), add( X_hat_exp, beta_reg_exp ), &alpha_reg_exp );
- reg_prv_corr_fx = BASOP_Util_Add_Mant32Exp( alpha_reg_fx, alpha_reg_exp, Mpy_32_32( beta_reg_fx, L_shl( MAX_DELAYREGLEN, 27 ) ), add( 4, beta_reg_exp ), ®_prv_corr_exp );
+ alpha_reg_fx = BASOP_Util_Add_Mant32Exp( Y_hat_fx, Y_hat_exp, L_negate( Mpy_32_32( X_hat_fx, beta_reg_fx ) ), add( X_hat_exp, beta_reg_exp ), &alpha_reg_exp ); /* Q31-alpha_reg_exp */
+ reg_prv_corr_fx = BASOP_Util_Add_Mant32Exp( alpha_reg_fx, alpha_reg_exp, Mpy_32_32( beta_reg_fx, L_shl( MAX_DELAYREGLEN, 27 ) ), add( 4, beta_reg_exp ), ®_prv_corr_exp ); /* Q31-reg_prv_corr_exp */
IF( LE_16( TRUNC_FX( reg_prv_corr_fx, reg_prv_corr_exp ), -L_NCSHIFT_DS ) )
{
@@ -959,21 +951,21 @@ static void corrStatsEst_fx(
move16();
}
- bias_par_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->smooth_dist_reg_prv_corr_fx, A_BIAS_FX_Q15 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, L_shl( B_BIAS_FX_Q15, Q16 ), 0, &bias_par_exp );
+ bias_par_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->smooth_dist_reg_prv_corr_fx, A_BIAS_FX_Q15 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, L_shl( B_BIAS_FX_Q15, Q16 ), 0, &bias_par_exp ); /* Q31-bias_par_exp */
- Word32 XH_BIAS_tmp = L_shl( XH_BIAS_FX_Q15, Q16 );
- Word32 XL_BIAS_tmp = L_shl( XL_BIAS_FX_Q15, Q16 );
+ Word32 XH_BIAS_tmp = L_shl( XH_BIAS_FX_Q15, Q16 ); /* Q31 */
+ Word32 XL_BIAS_tmp = L_shl( XL_BIAS_FX_Q15, Q16 ); /* Q31 */
IF( bias_par_exp < 0 )
{
- bias_par_fx = L_shl( bias_par_fx, bias_par_exp );
+ bias_par_fx = L_shl( bias_par_fx, bias_par_exp ); /* Q31 */
bias_par_exp = 0;
move16();
}
ELSE
{
- XH_BIAS_tmp = L_shr( XH_BIAS_tmp, bias_par_exp );
- XL_BIAS_tmp = L_shr( XL_BIAS_tmp, bias_par_exp );
+ XH_BIAS_tmp = L_shr( XH_BIAS_tmp, bias_par_exp ); /* Q31-bias_par_exp */
+ XL_BIAS_tmp = L_shr( XL_BIAS_tmp, bias_par_exp ); /* Q31-bias_par_exp */
}
bias_par_fx = L_min( bias_par_fx, XH_BIAS_tmp );
@@ -982,13 +974,13 @@ static void corrStatsEst_fx(
bias_par_exp = 0;
move16();
- width_par_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->smooth_dist_reg_prv_corr_fx, A_WIDTH_FX_Q31 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, B_WIDTH_FX_Q31, 0, &width_par_exp );
- Word32 XH_WIDTH_tmp = L_shl( XH_WIDTH_FX_Q15, Q16 );
- Word32 XL_WIDTH_tmp = L_shl( XL_WIDTH_FX_Q15, Q16 );
+ width_par_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->smooth_dist_reg_prv_corr_fx, A_WIDTH_FX_Q31 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, B_WIDTH_FX_Q31, 0, &width_par_exp ); /* Q31-width_par_exp */
+ Word32 XH_WIDTH_tmp = L_shl( XH_WIDTH_FX_Q15, Q16 ); /* Q31 */
+ Word32 XL_WIDTH_tmp = L_shl( XL_WIDTH_FX_Q15, Q16 ); /* Q31 */
IF( width_par_exp < 0 )
{
- width_par_fx = L_shl( width_par_fx, width_par_exp );
+ width_par_fx = L_shl( width_par_fx, width_par_exp ); /* Q31 */
width_par_exp = 0;
move16();
}
@@ -1003,39 +995,40 @@ static void corrStatsEst_fx(
width_par_exp = 0;
move16();
- win_width = (Word16) L_shr( Mpy_32_32( width_par_fx, 1350565888 /* ( 4L_NCSHIFT_DS + 1 ) in Q23 */ ), sub( 31, add( width_par_exp, 8 ) ) );
+ win_width = (Word16) L_shr( Mpy_32_32( width_par_fx, 1350565888 /* ( 4L_NCSHIFT_DS + 1 ) in Q23 */ ), sub( 31, add( width_par_exp, 8 ) ) ); /* Q23-(31-(width_par_exp-8)) */
win_bias_fx = round_fx( bias_par_fx ); // Q15
k1_fx = add( MAX_16 >> 1, shr( win_bias_fx, 1 ) ); // Q15
k2_fx = sub( MAX_16 >> 1, shr( win_bias_fx, 1 ) ); // Q15
- FOR( i = 0; i < sub( 2 * L_NCSHIFT_DS, shl( win_width, 1 ) ); i++ )
+ FOR( i = 0; i < ( 2 * L_NCSHIFT_DS - ( win_width * 2 ) ); i++ )
{
loc_weight_win_fx[i] = win_bias_fx; // Q15
move16();
}
- FOR( i = sub( 2 * L_NCSHIFT_DS, shl( win_width, 1 ) ); i <= add( 2 * L_NCSHIFT_DS, shl( win_width, 1 ) ); i++ )
+ FOR( i = ( 2 * L_NCSHIFT_DS - ( win_width * 2 ) ); i <= ( 2 * L_NCSHIFT_DS + ( win_width * 2 ) ); i++ )
{
- Word16 cos_inp = BASOP_Util_Divide1616_Scale( sub( i, 2 * L_NCSHIFT_DS ), shl( win_width, 1 ), &exp );
+ Word16 cos_inp = BASOP_Util_Divide1616_Scale( sub( i, 2 * L_NCSHIFT_DS ), shl( win_width, 1 ), &exp ); /* Q15-exp */
cos_inp = shr_sat( cos_inp, sub( 0, exp ) );
- cos_inp = getCosWord16R2( shr( cos_inp, 1 ) );
- loc_weight_win_fx[i] = add( k1_fx, mult( k2_fx, cos_inp ) );
+ cos_inp = getCosWord16R2( shr( cos_inp, 1 ) ); // Q15
+ loc_weight_win_fx[i] = add( k1_fx, mult( k2_fx, cos_inp ) ); // Q15
move16();
}
- FOR( i = add( 2 * L_NCSHIFT_DS, shl( win_width, 1 ) ); i < ( 4 * L_NCSHIFT_DS + 1 ); i++ )
+ FOR( i = ( 2 * L_NCSHIFT_DS + ( win_width * 2 ) ); i < ( 4 * L_NCSHIFT_DS + 1 ); i++ )
{
loc_weight_win_fx[i] = win_bias_fx; // Q15
move16();
}
-
- Word16 x = TRUNC_FX( reg_prv_corr_fx, reg_prv_corr_exp );
+ reg_prv_corr_fx = L_shr( reg_prv_corr_fx, 1 );
+ reg_prv_corr_exp = add( reg_prv_corr_exp, 1 );
+ Word16 x = TRUNC_FX( reg_prv_corr_fx, reg_prv_corr_exp ); /* Q0 */
move16();
- for ( i = 0, j = sub( L_NCSHIFT_DS, x ); i < 2 * L_NCSHIFT_DS + 1; i++, j++ )
+ for ( i = 0, j = ( L_NCSHIFT_DS - x ); i < 2 * L_NCSHIFT_DS + 1; i++, j++ )
{
- corrEst_fx[i] = Mpy_32_16_1( corrEst_fx[i], loc_weight_win_fx[j] );
+ corrEst_fx[i] = Mpy_32_16_1( corrEst_fx[i], loc_weight_win_fx[j] ); /* Q31-corrEst_exp */
move32();
}
test();
@@ -1043,15 +1036,15 @@ static void corrStatsEst_fx(
IF( LT_32( hStereoTCA->prevTargetGain_fx, 429496730 /*0.8f in Q29*/ ) && vad_flag1 )
{
/* ch 2 is prev reference channel */
- v_multc_fixed( corrEst_fx, 644245095 /*1.2f in Q29*/, corrEst_fx, L_NCSHIFT_DS + 1 );
- v_multc_fixed( corrEst_fx + L_NCSHIFT_DS + 1, 447213470 /* 0.833 in Q29*/, corrEst_fx + L_NCSHIFT_DS + 1, L_NCSHIFT_DS );
+ v_multc_fixed( corrEst_fx, 644245095 /*1.2f in Q29*/, corrEst_fx, L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */
+ v_multc_fixed( corrEst_fx + L_NCSHIFT_DS + 1, 447213470 /* 0.833 in Q29*/, corrEst_fx + L_NCSHIFT_DS + 1, L_NCSHIFT_DS ); /* Q31-corrEst_exp */
corrEst_exp = add( corrEst_exp, 2 );
}
ELSE IF( GT_32( hStereoTCA->prevTargetGain_fx, 644245094 /*1.2f in Q29*/ ) && vad_flag1 )
{
/* ch 1 is prev reference channel */
- v_multc_fixed( corrEst_fx, 447213470 /* 0.833 f in Q29*/, corrEst_fx, L_NCSHIFT_DS );
- v_multc_fixed( corrEst_fx + L_NCSHIFT_DS, 644245095 /*1.2f in Q29*/, corrEst_fx + L_NCSHIFT_DS, L_NCSHIFT_DS + 1 );
+ v_multc_fixed( corrEst_fx, 447213470 /* 0.833 f in Q29*/, corrEst_fx, L_NCSHIFT_DS ); /* Q31-corrEst_exp */
+ v_multc_fixed( corrEst_fx + L_NCSHIFT_DS, 644245095 /*1.2f in Q29*/, corrEst_fx + L_NCSHIFT_DS, L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */
corrEst_exp = add( corrEst_exp, 2 );
}
test();
@@ -1061,9 +1054,9 @@ static void corrStatsEst_fx(
j = s_min( 2 * L_NCSHIFT_DS, add( hStereoTCA->prevCorrLagStats[0], 1 + L_NCSHIFT_DS ) );
k = add( sub( j, i ), 1 );
- v_multc_fixed( corrEst_fx, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx, i ); // to allign in same exp
- v_multc_fixed( corrEst_fx + i, 644245095 /*1.2f in Q29*/, corrEst_fx + i, k );
- v_multc_fixed( corrEst_fx + i + k, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx + i + k, sub( 2 * L_NCSHIFT_DS + 1, i + k ) ); // to allign in same exp
+ v_multc_fixed( corrEst_fx, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx, i ); // to allign in same exp (Q31-corrEst_exp)
+ v_multc_fixed( corrEst_fx + i, 644245095 /*1.2f in Q29*/, corrEst_fx + i, k ); /* Q31-corrEst_exp */
+ v_multc_fixed( corrEst_fx + i + k, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx + i + k, sub( 2 * L_NCSHIFT_DS + 1, i + k ) ); // to allign in same exp (Q31-corrEst_exp)
corrEst_exp = add( corrEst_exp, 2 );
}
@@ -1075,35 +1068,35 @@ static void corrStatsEst_fx(
corrLagStats[0] = add( corrLagStats[0], lagSearchRange[0] );
move16();
- stmp = i_mult( corrLagStats[0], dsFactor );
- hStereoClassif->unclr_fv_fx[E_corrLagStats0] = L_shl( stmp, Q15 );
+ stmp = i_mult( corrLagStats[0], dsFactor ); /* Q0 */
+ hStereoClassif->unclr_fv_fx[E_corrLagStats0] = L_shl( stmp, Q15 ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrLagStats0] = L_shl( stmp, Q15 );
+ hStereoClassif->xtalk_fv_fx[E_corrLagStats0] = L_shl( stmp, Q15 ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_ica_corr_value0] = L_shl( tempF_fx, sub( tempF_exp, Q16 ) );
+ hStereoClassif->xtalk_fv_fx[E_ica_corr_value0] = L_shl( tempF_fx, sub( tempF_exp, Q16 ) ); /* Q15 */
move32();
test();
- if ( vad_flag1 == 0 && GT_16( alpha_fx, 22938 /* 0.7f in Q15 */ ) )
+ IF( vad_flag1 == 0 && GT_16( alpha_fx, 22938 /* 0.7f in Q15 */ ) )
{
corrLagStats[0] = 0;
move16();
}
- dist_reg_prv_corr_fx = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -corrLagStats[0], Q31, &dist_reg_prv_corr_exp ) );
+ dist_reg_prv_corr_fx = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -corrLagStats[0], Q31, &dist_reg_prv_corr_exp ) ); /* Q31-dist_reg_prv_corr_exp */
test();
IF( EQ_16( vad_flag1, 1 ) && EQ_16( vad_flag2, 1 ) )
{
- hStereoTCA->smooth_dist_reg_prv_corr_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->smooth_dist_reg_prv_corr_fx, SMOOTH_DIST_FACTOR_FX_Q15 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, Mpy_32_16_1( dist_reg_prv_corr_fx, MAX_16 - SMOOTH_DIST_FACTOR_FX_Q15 ), dist_reg_prv_corr_exp, &hStereoTCA->smooth_dist_reg_prv_corr_exp );
+ hStereoTCA->smooth_dist_reg_prv_corr_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->smooth_dist_reg_prv_corr_fx, SMOOTH_DIST_FACTOR_FX_Q15 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, Mpy_32_16_1( dist_reg_prv_corr_fx, MAX_16 - SMOOTH_DIST_FACTOR_FX_Q15 ), dist_reg_prv_corr_exp, &hStereoTCA->smooth_dist_reg_prv_corr_exp ); /* Q31-hStereoTCA->smooth_dist_reg_prv_corr_exp */
move32();
- Copy32( &( hStereoTCA->delay_0_mem_fx[1] ), &( hStereoTCA->delay_0_mem_fx[0] ), MAX_DELAYREGLEN - 1 );
+ Copy32( &( hStereoTCA->delay_0_mem_fx[1] ), &( hStereoTCA->delay_0_mem_fx[0] ), MAX_DELAYREGLEN - 1 ); /* Q31-hStereoTCA->delay_0_mem_exp */
- hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], 429496730 /* 0.2 in Q31*/ ), hStereoTCA->delay_0_mem_exp, L_mult0( 26214 /* 0.8 in Q15*/, corrLagStats[0] ), Q16, &temp );
+ hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], 429496730 /* 0.2 in Q31*/ ), hStereoTCA->delay_0_mem_exp, L_mult0( 26214 /* 0.8 in Q15*/, corrLagStats[0] ), Q16, &temp ); /* Q31-temp */
move32();
- Word32 inpp = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -hStereoTCA->delay_0_mem_fx[0], hStereoTCA->delay_0_mem_exp, &exp ) );
- inpp = L_shr( inpp, sub( Q31, exp ) );
- IF( GT_32( inpp, 25 ) )
+ Word32 inpp = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -hStereoTCA->delay_0_mem_fx[0], hStereoTCA->delay_0_mem_exp, &exp ) ); /* Q31-exp */
+ inpp = L_shl_sat( inpp, sub( exp, 5 ) ); /* Q26 */
+ IF( GT_32( inpp, 1677721600 ) ) // 25 in Q26
{
set32_fx( &( hStereoTCA->delay_0_mem_fx[0] ), hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], MAX_DELAYREGLEN - 1 );
hStereoTCA->delay_0_mem_exp = temp;
@@ -1113,13 +1106,13 @@ static void corrStatsEst_fx(
{
IF( GT_16( temp, hStereoTCA->delay_0_mem_exp ) )
{
- scale_sig32( hStereoTCA->delay_0_mem_fx, MAX_DELAYREGLEN - 1, sub( hStereoTCA->delay_0_mem_exp, temp ) );
+ scale_sig32( hStereoTCA->delay_0_mem_fx, MAX_DELAYREGLEN - 1, sub( hStereoTCA->delay_0_mem_exp, temp ) ); /* Q31-hStereoTCA->delay_0_mem_exp */
hStereoTCA->delay_0_mem_exp = temp;
move16();
}
ELSE
{
- hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = L_shl( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], sub( temp, hStereoTCA->delay_0_mem_exp ) );
+ hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = L_shl( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], sub( temp, hStereoTCA->delay_0_mem_exp ) ); /* Q31-temp */
move32();
}
}
@@ -1134,7 +1127,7 @@ static void corrStatsEst_fx(
test();
IF( vad_flag1 == 0 || vad_flag2 == 0 )
{
- corrLagStats[0] = TRUNC_FX( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], hStereoTCA->delay_0_mem_exp );
+ corrLagStats[0] = TRUNC_FX( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], hStereoTCA->delay_0_mem_exp ); /* Q0 */
move32();
}
@@ -1155,7 +1148,7 @@ static void corrStatsEst_fx(
winInterp_fx = ica_sincInterp6_fx + SINC_ORDER1;
}
- corrLagStats[1] = i_mult( corrLagStats[0], dsFactor );
+ corrLagStats[1] = i_mult( corrLagStats[0], dsFactor ); /* Q0 */
move16();
interpMin = s_max( -sub( dsFactor, 1 ), -add( corrLagStats[1], i_mult( L_NCSHIFT_DS, dsFactor ) ) );
interpMax = s_min( sub( dsFactor, 1 ), sub( i_mult( L_NCSHIFT_DS, dsFactor ), corrLagStats[1] ) );
@@ -1165,29 +1158,29 @@ static void corrStatsEst_fx(
{
rInterp_fx[k] = 0;
move32();
- FOR( j = -idiv1616( SINC_ORDER1, dsFactor ); j <= idiv1616( SINC_ORDER1, dsFactor ); j++ )
+ FOR( j = -( SINC_ORDER1 / dsFactor ); j <= ( SINC_ORDER1 / dsFactor ); j++ )
{
- m = i_mult( j, dsFactor );
+ m = i_mult( j, dsFactor ); /* Q0 */
test();
IF( GE_16( sub( m, i ), -SINC_ORDER1 ) && LE_16( sub( m, i ), SINC_ORDER1 ) )
{
IF( GT_16( j, sub( lagSearchRange[1], corrLagStats[0] ) ) )
{
- rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[lagSearchRange[1] - corrLagStats[0]], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp );
+ rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[lagSearchRange[1] - corrLagStats[0]], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp ); /* Q31-temp */
move32();
rInterp_exp[k] = temp;
move16();
}
ELSE IF( LT_16( j, sub( lagSearchRange[0], corrLagStats[0] ) ) )
{
- rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[lagSearchRange[0] - corrLagStats[0]], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp );
+ rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[lagSearchRange[0] - corrLagStats[0]], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp ); /* Q31-temp */
move32();
rInterp_exp[k] = temp;
move16();
}
ELSE
{
- rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[j], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp );
+ rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[j], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp ); /* Q31-temp */
move32();
rInterp_exp[k] = temp;
move16();
@@ -1204,15 +1197,15 @@ static void corrStatsEst_fx(
FOR( i = 0; i < MAX_INTERPOLATE; i++ )
{
- rInterp_fx[i] = L_shl( rInterp_fx[i], sub( rInterp_exp[i], temp ) );
+ rInterp_fx[i] = L_shl( rInterp_fx[i], sub( rInterp_exp[i], temp ) ); /* Q31-rInterp_exp[i] */
move32();
}
- corrLagStats[1] = add( corrLagStats[1], add( maximum_32_fx( rInterp_fx, interpLen, &tempF_fx ), interpMin ) );
+ corrLagStats[1] = add( corrLagStats[1], add( maximum_32_fx( rInterp_fx, interpLen, &tempF_fx ), interpMin ) ); /* Q0 */
move16();
/* save corr lag stats for the current frame */
- Copy( corrLagStats, hStereoTCA->corrLagStats, 3 );
+ Copy( corrLagStats, hStereoTCA->corrLagStats, 3 ); /* Q0 */
return;
}
@@ -1225,14 +1218,14 @@ static void corrStatsEst_fx(
static void estDownmixGain_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA Encoder handle */
- const Word32 *chan1, /* i : reference signal Qx */
- const Word32 *chan2, /* i/o: target signal to be scaled Qx */
- const Word16 q_chan, /* i : Q of the channel signal */
- const Word16 ncShift, /* i : shift */
- const Word16 length, /* i : input frame length */
- const Word16 element_mode, /* i : element mode */
+ const Word32 *chan1, /* i : reference signal q_chan */
+ const Word32 *chan2, /* i/o: target signal to be scaled q_chan */
+ const Word16 q_chan, /* i : Q of the channel signal Q0*/
+ const Word16 ncShift, /* i : shift Q0*/
+ const Word16 length, /* i : input frame length Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier handle */
- const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
+ const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag Q0*/
)
{
Word16 i, i1, i2;
@@ -1251,12 +1244,12 @@ static void estDownmixGain_fx(
{
i1 = 0;
move16();
- i2 = ncShift;
+ i2 = ncShift; /* Q0 */
move16();
}
ELSE
{
- i1 = ncShift;
+ i1 = ncShift; /* Q0 */
move16();
i2 = 0;
move16();
@@ -1269,11 +1262,11 @@ static void estDownmixGain_fx(
move32();
FOR( i = 0; i < length; i++ )
{
- tempN = L_add( tempN, L_abs( chan1[i1 + i] ) );
- tempD = L_add( tempD, L_abs( chan2[i2 + i] ) );
+ tempN = L_add( tempN, L_abs( chan1[i1 + i] ) ); /* q_chan */
+ tempD = L_add( tempD, L_abs( chan2[i2 + i] ) ); /* q_chan */
}
- alpha = hStereoTCA->corrStatsSmoothFac_fx;
+ alpha = hStereoTCA->corrStatsSmoothFac_fx; /* Q15 */
move16();
IF( tempD == 0 )
{
@@ -1283,7 +1276,7 @@ static void estDownmixGain_fx(
}
ELSE
{
- currentGain = BASOP_Util_Divide3232_Scale( tempN, tempD, &exp );
+ currentGain = BASOP_Util_Divide3232_Scale( tempN, tempD, &exp ); /* Q31-exp */
currentGain_e = exp;
move16();
if ( currentGain == 0 )
@@ -1306,7 +1299,7 @@ static void estDownmixGain_fx(
currentGain_log10 = BASOP_Util_Log10( L_deposit_h( currentGain ), currentGain_e ); // Output in Q25
// multiplication result will be Q25 should be fit to Q15 hence right shift by 10.
// Q25 - Q10 = Q15
- currentGain = extract_l( L_shr( Madd_32_16( Mpy_32_16_1( prevTargetGain_log10, alpha ), currentGain_log10, sub( MAX_16, alpha ) ), Q10 ) );
+ currentGain = extract_l( L_shr( Madd_32_16( Mpy_32_16_1( prevTargetGain_log10, alpha ), currentGain_log10, sub( MAX_16, alpha ) ), Q10 ) ); /* Q15 */
currentGain_e = 0;
move16();
@@ -1318,8 +1311,8 @@ static void estDownmixGain_fx(
// tempD = powf( 10, currentGain );
// 10 ^ currentGain = 2 ^ (3.32192809488 * currentGain)
// 3.32192809488 in Q13 27213
- tempD = BASOP_util_Pow2( L_mult( currentGain, 27213 ), add( currentGain_e, Q2 ), &exp );
- unclr_instTargetGain = L_deposit_h( BASOP_Util_Divide3232_Scale( tempN, L_add( tempD, EPSILON_FX ), &exp_div ) );
+ tempD = BASOP_util_Pow2( L_mult( currentGain, 27213 ), add( currentGain_e, Q2 ), &exp ); /* Q31-exp */
+ unclr_instTargetGain = L_deposit_h( BASOP_Util_Divide3232_Scale( tempN, L_add( tempD, EPSILON_FX ), &exp_div ) ); /* Q31-exp */
exp = add( sub( exp_chan, exp ), exp_div );
if ( unclr_instTargetGain == 0 )
{
@@ -1328,7 +1321,7 @@ static void estDownmixGain_fx(
}
unclr_instTargetGain = BASOP_Util_Log10( L_add( unclr_instTargetGain, L_shr( MAX_32, sub( Q31, exp ) ) ), exp );
// unclr_fv_fx is expected in Q15 - log result will be in Q25 - hence rightshift by 10.
- hStereoClassif->unclr_fv_fx[E_ica_instTargetGain] = L_shr( unclr_instTargetGain, Q10 );
+ hStereoClassif->unclr_fv_fx[E_ica_instTargetGain] = L_shr( unclr_instTargetGain, Q10 ); /* Q15 */
move32();
}
@@ -1344,7 +1337,7 @@ static void estDownmixGain_fx(
/* Division result Q has to be got back to the Q of initial currentGain hence the shift operation below */
IF( currentGain_e != 0 )
{
- currentGain = shr( currentGain, sub( Q15, currentGain_e ) );
+ currentGain = shr( currentGain, sub( Q15, currentGain_e ) ); /* Q15 */
currentGain_e = 0;
move16();
}
@@ -1354,7 +1347,7 @@ static void estDownmixGain_fx(
IF( GE_16( norm_s( currentGain ), sub( currentGain_e, 1 ) ) )
{
/* convert currentGain into Q14 */
- currentGain = shl( currentGain, sub( currentGain_e, 1 ) );
+ currentGain = shl( currentGain, sub( currentGain_e, 1 ) ); /* Q14 */
currentGain_e = 1;
move16();
}
@@ -1365,7 +1358,7 @@ static void estDownmixGain_fx(
}
/* quantize the target gain */
- hStereoTCA->indx_ica_gD = usquant_fx( currentGain, &temp, shr( STEREO_TCA_GDMIN_FX_Q14, shift ), shr( STEREO_TCA_GDSTEP_FX_Q13, shift ), 1 << STEREO_BITS_TCA_GD );
+ hStereoTCA->indx_ica_gD = usquant_fx( currentGain, &temp, shr( STEREO_TCA_GDMIN_FX_Q14, shift ), shr( STEREO_TCA_GDSTEP_FX_Q13, shift ), ( 1 << STEREO_BITS_TCA_GD ) ); /* Q13 */
move16();
// hStereoTCA->targetGain_fx = powf( 10, temp );
// 10 ^ temp = 2 ^ (3.32192809488 * temp)
@@ -1373,7 +1366,7 @@ static void estDownmixGain_fx(
// exponent of power function input will be 2 more since constant is in Q13
exp = 2;
move16();
- hStereoTCA->targetGain_fx = BASOP_util_Pow2( L_mult( temp, 27213 ), add( currentGain_e, 2 ), &exp );
+ hStereoTCA->targetGain_fx = BASOP_util_Pow2( L_mult( temp, 27213 ), add( currentGain_e, 2 ), &exp ); /* Q31-exp */
move32();
hStereoTCA->targetGain_fx = L_shl( hStereoTCA->targetGain_fx, sub( exp, 2 ) ); // Q29
move32();
@@ -1391,9 +1384,9 @@ static void icaMemUpdate_fx(
Word32 *bufChanL, /* i/o: L signal correction from previous frame q_com*/
Word32 *bufChanR, /* i/o: R signal correction from previous frame q_com*/
Word16 q_com,
- const Word16 lMemRecalc, /* i : memory length at input Sampling Rate */
- const Word16 lMemRecalc_SCh, /* i : SCh memory length at input Sampling Rate*/
- const Word16 input_frame /* i : frame length */
+ const Word16 lMemRecalc, /* i : memory length at input Sampling Rate Q0*/
+ const Word16 lMemRecalc_SCh, /* i : SCh memory length at input Sampling Rate Q0*/
+ const Word16 input_frame /* i : frame length Q0*/
)
{
Word32 *ptr1, *ptr2;
@@ -1409,29 +1402,29 @@ static void icaMemUpdate_fx(
IF( hCPE->hStereoTD->tdm_last_SM_flag )
{
- ratio_L = hCPE->hStereoTD->tdm_last_ratio_SM_fx;
+ ratio_L = hCPE->hStereoTD->tdm_last_ratio_SM_fx; /* Q31 */
move32();
One_m_Ratio = L_sub( ratio_L, MAX_32 );
}
ELSE
{
- ratio_L = hCPE->hStereoTD->tdm_last_ratio_fx;
+ ratio_L = hCPE->hStereoTD->tdm_last_ratio_fx; /* Q31 */
move32();
One_m_Ratio = L_sub( MAX_32, ratio_L );
}
- ptr1 = sts[0]->input32_fx - add( lMemRecalc, lMemRecalc_SCh );
- ptr2 = sts[1]->input32_fx - add( lMemRecalc, lMemRecalc_SCh );
+ ptr1 = sts[0]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ); /* Q31-sts[0]->q_inp32 */
+ ptr2 = sts[1]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ); /* Q31-sts[1]->q_inp32 */
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) )
{
IF( hCPE->hStereoTD->flag_skip_DMX )
{
- FOR( i = lMemRecalc_SCh; i < add( lMemRecalc, lMemRecalc_SCh ); i++ )
+ FOR( i = lMemRecalc_SCh; i < ( lMemRecalc + lMemRecalc_SCh ); i++ )
{
- ptr1[i] = bufChanL[i];
+ ptr1[i] = bufChanL[i]; /* q_com */
move32();
- ptr2[i] = bufChanR[i];
+ ptr2[i] = bufChanR[i]; /* q_com */
move32();
}
}
@@ -1439,9 +1432,9 @@ static void icaMemUpdate_fx(
{
FOR( i = lMemRecalc_SCh; i < lMemRecalc + lMemRecalc_SCh; i++ )
{
- ptr1[i] = L_add( Mpy_32_32( bufChanR[i], One_m_Ratio ), Mpy_32_32( bufChanL[i], ratio_L ) );
+ ptr1[i] = L_add( Mpy_32_32( bufChanR[i], One_m_Ratio ), Mpy_32_32( bufChanL[i], ratio_L ) ); /* q_com */
move32();
- ptr2[i] = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) );
+ ptr2[i] = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) ); /* q_com */
move32();
}
}
@@ -1459,7 +1452,7 @@ static void icaMemUpdate_fx(
/* reconstruction of the Secondary channel past segment */
FOR( i = 0; i < lMemRecalc_SCh; i++ )
{
- ptr2[i] = L_add( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) );
+ ptr2[i] = L_add( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) ); /* q_com */
move32();
}
@@ -1468,18 +1461,18 @@ static void icaMemUpdate_fx(
incr = fac; // Q15
move16();
- FOR( i = lMemRecalc_SCh; i < add( lMemRecalc, lMemRecalc_SCh ); i++ )
+ FOR( i = lMemRecalc_SCh; i < ( lMemRecalc + lMemRecalc_SCh ); i++ )
{
- tmp1 = bufChanL[i];
+ tmp1 = bufChanL[i]; /* q_com */
move32();
- tmp2 = bufChanR[i];
+ tmp2 = bufChanR[i]; /* q_com */
move32();
- ptr1[i] = L_add( Mpy_32_16_1( ptr1[i], sub( MAX_16, fac ) ), Mpy_32_16_1( tmp1, fac ) );
+ ptr1[i] = L_add( Mpy_32_16_1( ptr1[i], sub( MAX_16, fac ) ), Mpy_32_16_1( tmp1, fac ) ); /* q_com */
move32();
/*ptr2[i] = (1.0f - fac) * ptr2[i] + fac * tmp2;*/ /* the secondary channel (downmixed) buffer of DFT stereo is empty ! */
- ptr2[i] = tmp2;
+ ptr2[i] = tmp2; /* q_com */
move32();
fac = add_sat( fac, incr );
@@ -1490,7 +1483,7 @@ static void icaMemUpdate_fx(
/* reconstruction of the Secondary channel past segment */
FOR( i = 0; i < lMemRecalc_SCh; i++ )
{
- ptr2[i] = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) );
+ ptr2[i] = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) ); /* q_com */
move32();
}
@@ -1498,15 +1491,15 @@ static void icaMemUpdate_fx(
fac = div_s( 1, lMemRecalc ); // Q15
incr = fac; // Q15
move16();
- FOR( i = lMemRecalc_SCh; i < add( lMemRecalc, lMemRecalc_SCh ); i++ )
+ FOR( i = lMemRecalc_SCh; i < ( lMemRecalc + lMemRecalc_SCh ); i++ )
{
- tmp1 = L_add( Mpy_32_32( bufChanR[i], One_m_Ratio ), Mpy_32_32( bufChanL[i], ratio_L ) );
- tmp2 = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) );
+ tmp1 = L_add( Mpy_32_32( bufChanR[i], One_m_Ratio ), Mpy_32_32( bufChanL[i], ratio_L ) ); /* q_com */
+ tmp2 = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) ); /* q_com */
- ptr1[i] = L_add( Mpy_32_16_1( ptr1[i], sub( MAX_16, fac ) ), Mpy_32_16_1( tmp1, fac ) );
+ ptr1[i] = L_add( Mpy_32_16_1( ptr1[i], sub( MAX_16, fac ) ), Mpy_32_16_1( tmp1, fac ) ); /* q_com */
move32();
/*ptr2[i] = (1.0f - fac) * ptr2[i] + fac * tmp2;*/ /* the secondary channel (downmixed) buffer of DFT stereo is empty ! */
- ptr2[i] = tmp2;
+ ptr2[i] = tmp2; /* q_com */
move32();
fac = add_sat( fac, incr );
@@ -1519,8 +1512,8 @@ static void icaMemUpdate_fx(
{
assert( L_MEM_RECALC_TBE_NS <= L_MEM_RECALC_NS );
i = NS2SA( sts[0]->input_Fs, L_MEM_RECALC_TBE_NS );
- Copy_Scale_sig_32_16( bufChanL + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[0], i, -Q16 );
- Copy_Scale_sig_32_16( bufChanR + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[1], i, -Q16 );
+ Copy_Scale_sig_32_16( bufChanL + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[0], i, -Q16 ); /* q_com-16 */
+ Copy_Scale_sig_32_16( bufChanR + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[1], i, -Q16 ); /* q_com-16 */
hCPE->hStereoICBWE->q_dataChan_fx = sub( q_com, Q16 );
move16();
}
@@ -1535,7 +1528,7 @@ static void icaMemUpdate_fx(
* ---------------------------------------------------------------*/
void stereo_tca_enc_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- const Word16 input_frame /* i : length of a frame per channel */
+ const Word16 input_frame /* i : length of a frame per channel Q0*/
)
{
/* temp variables */
@@ -1599,12 +1592,12 @@ void stereo_tca_enc_fx(
/* populate L/R memories into current buffers */
Word16 tempp_scale = L_norm_arr( hStereoTCA->memChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH );
tempp_scale = s_min( tempp_scale, L_norm_arr( hStereoTCA->memChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH ) );
- scale_sig32( hStereoTCA->memChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH, tempp_scale );
- scale_sig32( hStereoTCA->memChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH, tempp_scale );
+ scale_sig32( hStereoTCA->memChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH, tempp_scale ); /* hStereoTCA->memChan_q + tempp_scale */
+ scale_sig32( hStereoTCA->memChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH, tempp_scale ); /* hStereoTCA->memChan_q + tempp_scale */
hStereoTCA->memChan_q = add( hStereoTCA->memChan_q, tempp_scale );
move16();
- Copy32( hStereoTCA->memChanL_fx, bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) );
- Copy32( hStereoTCA->memChanR_fx, bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) );
+ Copy32( hStereoTCA->memChanL_fx, bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* hStereoTCA->memChan_q */
+ Copy32( hStereoTCA->memChanR_fx, bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* hStereoTCA->memChan_q */
bufChan_q = hStereoTCA->memChan_q;
move16();
/* pointers to the current frame */
@@ -1612,14 +1605,14 @@ void stereo_tca_enc_fx(
ptrChanR_fx = bufChanR_fx + add( lMemRecalc, lMemRecalc_SCh ); // Q:bufChan_q
/* copy interleaved stereo data to two channels, e.g., L, R */
- Copy32( sts[0]->input32_fx, ptrChanL_fx, input_frame );
- Copy32( sts[1]->input32_fx, ptrChanR_fx, input_frame );
+ Copy32( sts[0]->input32_fx, ptrChanL_fx, input_frame ); /* sts[0]->q_inp32 */
+ Copy32( sts[1]->input32_fx, ptrChanR_fx, input_frame ); /* sts[1]->q_inp32 */
/* Scaling buffers to common Q*/
- scale_sig32( ptrChanL_fx, input_frame, sub( s_min( q_com, bufChan_q ), q_com ) );
- scale_sig32( ptrChanR_fx, input_frame, sub( s_min( q_com, bufChan_q ), q_com ) );
- scale_sig32( bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) );
- scale_sig32( bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) );
+ scale_sig32( ptrChanL_fx, input_frame, sub( s_min( q_com, bufChan_q ), q_com ) ); /* s_min( q_com, bufChan_q ) */
+ scale_sig32( ptrChanR_fx, input_frame, sub( s_min( q_com, bufChan_q ), q_com ) ); /* s_min( q_com, bufChan_q ) */
+ scale_sig32( bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); /* s_min( q_com, bufChan_q ) */
+ scale_sig32( bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); /* s_min( q_com, bufChan_q ) */
bufChan_q = s_min( q_com, bufChan_q );
q_com = bufChan_q;
move16();
@@ -1673,7 +1666,7 @@ void stereo_tca_enc_fx(
tempS = hStereoTCA->prevRefChanIndx;
move16();
- Copy( hStereoTCA->prevCorrLagStats, tempS_buff, 3 );
+ Copy( hStereoTCA->prevCorrLagStats, tempS_buff, 3 ); /* Q0 */
stereo_tca_init_enc_fx( hStereoTCA, input_Fs );
@@ -1695,13 +1688,13 @@ void stereo_tca_enc_fx(
hStereoTCA->prevRefChanIndx = tempS;
move16();
- Copy( tempS_buff, hStereoTCA->prevCorrLagStats, 3 );
+ Copy( tempS_buff, hStereoTCA->prevCorrLagStats, 3 ); /* Q0 */
/* populate memory */
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
- Copy32( sts[0]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ), bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) );
- Copy32( sts[1]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ), bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) );
+ Copy32( sts[0]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ), bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* sts[0]->q_inp32 */
+ Copy32( sts[1]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ), bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* sts[1]->q_inp32 */
}
}
@@ -1714,6 +1707,7 @@ void stereo_tca_enc_fx(
scale_sig32( bufChanL_DS_fx, ADDED_MEM_DS, sub( s_min( hStereoTCA->memChan_DS_q, bufChan_q ), hStereoTCA->memChan_DS_q ) ); // s_min( hStereoTCA->memChan_DS_q, bufChan_q )
scale_sig32( bufChanR_DS_fx, ADDED_MEM_DS, sub( s_min( hStereoTCA->memChan_DS_q, bufChan_q ), hStereoTCA->memChan_DS_q ) ); // s_min( hStereoTCA->memChan_DS_q, bufChan_q )
+ scale_sig32( hStereoTCA->memdecim_fx, 12, sub( s_min( hStereoTCA->memChan_DS_q, bufChan_q ), hStereoTCA->memChan_DS_q ) ); // s_min( hStereoTCA->memChan_DS_q, bufChan_q )
bufChan_q = s_min( hStereoTCA->memChan_DS_q, bufChan_q );
q_com = bufChan_q;
@@ -1723,14 +1717,14 @@ void stereo_tca_enc_fx(
/* pointers to the current frame of DS */
- ptrChanL_DS_fx = bufChanL_DS_fx + ADDED_MEM_DS;
- ptrChanR_DS_fx = bufChanR_DS_fx + ADDED_MEM_DS;
+ ptrChanL_DS_fx = bufChanL_DS_fx + ADDED_MEM_DS; /* hStereoTCA->memChan_DS_q */
+ ptrChanR_DS_fx = bufChanR_DS_fx + ADDED_MEM_DS; /* hStereoTCA->memChan_DS_q */
/* resample factor */
- dsFactor = (Word16) Mpy_32_32( input_Fs, 268436 /* 1/CORR_INTER_FS in Q31*/ ); // Q0
+ dsFactor = extract_l( Mpy_32_32( input_Fs, 268436 /* 1/CORR_INTER_FS in Q31*/ ) ); // Q0
/* resample the stereo channels */
- deEmphResample( hStereoTCA, ptrChanL_fx, ptrChanR_fx, ptrChanL_DS_fx, ptrChanR_DS_fx, input_frame, dsFactor );
+ deEmphResample_fx( hStereoTCA, ptrChanL_fx, ptrChanR_fx, ptrChanL_DS_fx, ptrChanR_DS_fx, input_frame, dsFactor );
/**********************NEED to Allign first 40 index in each channel ************************************/
/* inter-channel corrStats estimation */
@@ -1757,7 +1751,7 @@ void stereo_tca_enc_fx(
move16();
maxCorrStatsDev = N_MAX_SHIFT_CHANGE;
move16();
- if ( LE_16( hStereoTCA->corrStatsSmoothFac_fx, 22938 /*0.7f*/ ) )
+ IF( LE_16( hStereoTCA->corrStatsSmoothFac_fx, 22938 /*0.7f*/ ) )
{
maxCorrStatsDev = 160; /* L_NCSHIFT_MAX @ 32kHz */
move16();
@@ -1765,7 +1759,7 @@ void stereo_tca_enc_fx(
IF( LT_32( input_Fs, 32000 ) )
{
- maxCorrStatsDev = (Word16) Mpy_32_32( imult3216( input_Fs, maxCorrStatsDev ), 67109 /* 1/32000.0f in Q31*/ ); // Q0
+ maxCorrStatsDev = extract_l( Mpy_32_32( imult3216( input_Fs, maxCorrStatsDev ), 67109 /* 1/32000.0f in Q31*/ ) ); // Q0
}
musicMode = ( hCPE->hCoreCoder[0]->sp_aud_decision0 == 1 || sts[0]->last_core > ACELP_CORE );
@@ -1778,17 +1772,17 @@ void stereo_tca_enc_fx(
set16_fx( hStereoTCA->corrLagStats + 1, 0, 2 );
}
- tempS = sub( hStereoTCA->corrLagStats[1], hStereoTCA->prevCorrLagStats[2] );
+ tempS = sub( hStereoTCA->corrLagStats[1], hStereoTCA->prevCorrLagStats[2] ); /* Q0 */
IF( GT_16( abs_s( tempS ), maxCorrStatsDev ) )
{
IF( tempS > 0 )
{
- hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], maxCorrStatsDev );
+ hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], maxCorrStatsDev ); /* Q0 */
}
ELSE
{
- hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], -maxCorrStatsDev );
+ hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], -maxCorrStatsDev ); /* Q0 */
}
move16();
}
@@ -1802,22 +1796,24 @@ void stereo_tca_enc_fx(
{
tempF_fx = 0;
move32();
+ corrEstStage2_exp = 0;
+ move16();
IF( !musicMode )
{
- tempLag[0] = s_min( hStereoTCA->corrLagStats[2], hStereoTCA->prevCorrLagStats[2] );
+ tempLag[0] = s_min( hStereoTCA->corrLagStats[2], hStereoTCA->prevCorrLagStats[2] ); /* Q0 */
move16();
- tempLag[1] = s_max( hStereoTCA->corrLagStats[2], hStereoTCA->prevCorrLagStats[2] );
+ tempLag[1] = s_max( hStereoTCA->corrLagStats[2], hStereoTCA->prevCorrLagStats[2] ); /* Q0 */
move16();
neighborLimit = s_min( 3, maxCorrStatsDev );
IF( LT_16( hStereoTCA->prevCorrLagStats[2], hStereoTCA->corrLagStats[2] ) )
{
- tempLag[1] = s_min( tempLag[1], add( tempLag[0], neighborLimit ) );
+ tempLag[1] = s_min( tempLag[1], add( tempLag[0], neighborLimit ) ); /* Q0 */
}
ELSE
{
- tempLag[0] = s_max( tempLag[0], sub( tempLag[1], neighborLimit ) );
+ tempLag[0] = s_max( tempLag[0], sub( tempLag[1], neighborLimit ) ); /* Q0 */
}
move16();
utilCrossCorr_fx( ptrChanL_fx, q_com, ptrChanR_fx, q_com, NULL, corrEstStage2_fx, &corrEstStage2_exp, tempLag, input_frame, 0 );
@@ -1830,22 +1826,22 @@ void stereo_tca_enc_fx(
IF( GT_16( abs_s( tempS ), neighborLimit ) )
{
- tempLag[0] = hStereoTCA->corrLagStats[1];
+ tempLag[0] = hStereoTCA->corrLagStats[1]; /* Q0 */
move16();
- tempLag[1] = hStereoTCA->corrLagStats[1];
+ tempLag[1] = hStereoTCA->corrLagStats[1]; /* Q0 */
move16();
utilCrossCorr_fx( ptrChanL_fx, q_com, ptrChanR_fx, q_com, NULL, &tempF1_fx, &tempF1_exp, tempLag, input_frame, 0 );
test();
- IF( GT_32( tempF1_fx, tempF_fx ) || musicMode )
+ IF( ( BASOP_Util_Cmp_Mant32Exp( tempF1_fx, tempF1_exp, tempF_fx, corrEstStage2_exp ) > 0 ) || musicMode )
{
IF( tempS > 0 )
{
- hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], s_min( abs_s( tempS ), maxCorrStatsDev ) );
+ hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], s_min( abs_s( tempS ), maxCorrStatsDev ) ); /* Q0 */
}
ELSE
{
- hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], s_max( -abs_s( tempS ), -maxCorrStatsDev ) );
+ hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], s_max( -abs_s( tempS ), -maxCorrStatsDev ) ); /* Q0 */
}
move16();
}
@@ -1879,37 +1875,37 @@ void stereo_tca_enc_fx(
1. adjust samples,
2. interp shift variation,
3. gain estimation */
- prevNCShift = abs_s( hStereoTCA->prevCorrLagStats[2] );
- currentNCShift = abs_s( hStereoTCA->corrLagStats[2] );
+ prevNCShift = abs_s( hStereoTCA->prevCorrLagStats[2] ); /* Q0 */
+ currentNCShift = abs_s( hStereoTCA->corrLagStats[2] ); /* Q0 */
IF( EQ_16( hStereoTCA->prevRefChanIndx, L_CH_INDX ) )
{
- v_multc_fixed( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q*/
+ v_multc_fixed( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q - 2*/
Copy32( ptrChanL_fx - add( lMemRecalc, lMemRecalc_SCh ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q - 2
v_multc_fixed( ptrChanR_fx + sub( prevNCShift, add( lMemRecalc, lMemRecalc_SCh ) ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q-2
- v_multc_fixed( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2 */
+ v_multc_fixed( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/
}
ELSE
{
- v_multc_fixed( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q*/
+ v_multc_fixed( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/
Copy32( ptrChanL_fx + add( prevNCShift, sub( lMemRecalc, lMemRecalc_SCh ) ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2
v_multc_fixed( ptrChanR_fx - add( lMemRecalc, lMemRecalc_SCh ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2
- v_multc_fixed( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q*/
+ v_multc_fixed( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/
}
bufChan_q = sub( bufChan_q, 2 );
q_com = bufChan_q;
move16();
input_mem_loc_q = bufChan_q;
move16();
- target_fx = ptrChanR_fx;
- target_idx = R_CH_INDX;
+ target_fx = ptrChanR_fx; /* bufChan_q -2 */
+ target_idx = R_CH_INDX; /* Q0 */
move16();
/* identify target signal to correct for shift variations */
test();
test();
IF( ( prevNCShift == 0 && hStereoTCA->corrLagStats[2] < 0 ) || EQ_16( hStereoTCA->prevRefChanIndx, R_CH_INDX ) )
{
- target_fx = ptrChanL_fx;
+ target_fx = ptrChanL_fx; /* bufChan_q - 2 */
target_idx = L_CH_INDX;
move16();
}
@@ -1926,7 +1922,7 @@ void stereo_tca_enc_fx(
}
/* Note!! : Always keep the assert (prevNCShift>>1) below according to the equation used here to get tempS */
- tempS = shr( currentNCShift, 1 );
+ tempS = shr( currentNCShift, 1 ); /* Q0 */
IF( LE_32( abs( sub( currentNCShift, prevNCShift ) ), L_min( N_MAX_SHIFT_CHANGE, Mpy_32_32( imult3216( input_Fs, N_MAX_SHIFT_CHANGE ), 67109 /* 1/32000.0f in Q31*/ ) ) ) )
{
@@ -1934,18 +1930,18 @@ void stereo_tca_enc_fx(
}
ELSE
{
- tempS = s_min( s_max( tempS, add( sub( prevNCShift, currentNCShift ), sub( L_shift_adapt, input_frame ) ) ), add( sub( prevNCShift, currentNCShift ), lMemRecalc ) );
+ tempS = s_min( s_max( tempS, add( sub( prevNCShift, currentNCShift ), sub( L_shift_adapt, input_frame ) ) ), add( sub( prevNCShift, currentNCShift ), lMemRecalc ) ); /* Q0 */
adjustTargetSignal_fx( ( target_fx - tempS ), prevNCShift, currentNCShift, L_shift_adapt, 1 );
}
IF( target_idx == L_CH_INDX )
{
- Copy32( target_fx - tempS, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) );
+ Copy32( target_fx - tempS, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) ); /* bufChan_q - 2 */
}
ELSE
{
- v_multc_fixed( target_fx - tempS, hStereoTCA->prevTargetGain_fx, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) );
+ v_multc_fixed( target_fx - tempS, hStereoTCA->prevTargetGain_fx, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) ); /* bufChan_q - 2 */
}
}
@@ -1967,16 +1963,16 @@ void stereo_tca_enc_fx(
/* quantize the corrStats */
Word16 temp_exp, tempF_16fx;
- Word16 scalar_value = BASOP_Util_Divide1616_Scale( currentNCShift, dsFactor, &temp_exp );
+ Word16 scalar_value = BASOP_Util_Divide1616_Scale( currentNCShift, dsFactor, &temp_exp ); /* Q15-temp_exp */
IF( temp_exp < 0 )
{
- scalar_value = shl( scalar_value, sub( temp_exp, Q3 ) ); // Q12
- hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, ONE_IN_Q11, 1 << STEREO_BITS_TCA_CORRSTATS );
+ scalar_value = shl( scalar_value, sub( temp_exp, Q3 ) ); // Q12
+ hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, ONE_IN_Q11, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */
move16();
}
ELSE
{
- hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, shl( 1, sub( 14, temp_exp ) ), 1 << STEREO_BITS_TCA_CORRSTATS );
+ hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, shl( 1, sub( 14, temp_exp ) ), ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */
move16();
}
tempF_fx = tempF_16fx;
@@ -1995,7 +1991,7 @@ void stereo_tca_enc_fx(
currentNCShift = 0; /* only to avoid compilation warning */
move16();
- target_fx = ptrChanL_fx; /* only to avoid compilation warning */
+ target_fx = ptrChanL_fx; /* only to avoid compilation warning bufChan_q*/
move16();
target_idx = L_CH_INDX; /* only to avoid compilation warning */
move16();
@@ -2021,8 +2017,8 @@ void stereo_tca_enc_fx(
*-----------------------------------------------------------------*/
/* back up the L/R missing target */
- Copy32( bufChanL_fx + input_frame, hStereoTCA->memChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) );
- Copy32( bufChanR_fx + input_frame, hStereoTCA->memChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) );
+ Copy32( bufChanL_fx + input_frame, hStereoTCA->memChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* bufChan_q */
+ Copy32( bufChanR_fx + input_frame, hStereoTCA->memChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* bufChan_q */
hStereoTCA->memChan_q = bufChan_q;
IF( currentNCShift != 0 )
@@ -2051,7 +2047,7 @@ void stereo_tca_enc_fx(
scale_sig32( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( s_min( input_mem_loc_q, sts[0]->q_inp32 ), sts[0]->q_inp32 ) ); // s_min( input_mem_loc_q, sts[0]->q_inp32 )
scale_sig32( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( s_min( input_mem_loc_q, sts[1]->q_inp32 ), sts[1]->q_inp32 ) ); // s_min( input_mem_loc_q, sts[0]->q_inp32 )
- input_mem_loc_q = s_min( input_mem_loc_q, sts[0]->q_inp32 );
+ input_mem_loc_q = s_min( input_mem_loc_q, sts[0]->q_inp32 ); /* sts[0]->q_inp32 */
sts[0]->q_inp32 = input_mem_loc_q;
move16();
sts[1]->q_inp32 = input_mem_loc_q;
@@ -2063,7 +2059,7 @@ void stereo_tca_enc_fx(
test();
IF( hCPE->hStereoTD->prev_fr_LRTD_TD_dec == 0 || EQ_16( prev_ICA_flag, 1 ) )
{
- Copy32( target_fx + currentNCShift, sts[target_idx]->input32_fx, input_frame );
+ Copy32( target_fx + currentNCShift, sts[target_idx]->input32_fx, input_frame ); /* bufChan_q */
}
IF( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) )
@@ -2100,14 +2096,14 @@ void stereo_tca_enc_fx(
}
/* update L/R DS memories */
- Copy32( bufChanL_DS_fx + L_FRAME_DS, hStereoTCA->memChanL_DS_fx, ADDED_MEM_DS );
- Copy32( bufChanR_DS_fx + L_FRAME_DS, hStereoTCA->memChanR_DS_fx, ADDED_MEM_DS );
+ Copy32( bufChanL_DS_fx + L_FRAME_DS, hStereoTCA->memChanL_DS_fx, ADDED_MEM_DS ); /* hStereoTCA->memChan_DS_q */
+ Copy32( bufChanR_DS_fx + L_FRAME_DS, hStereoTCA->memChanR_DS_fx, ADDED_MEM_DS ); /* hStereoTCA->memChan_DS_q */
/* save the reference channel index for next frame */
- hStereoTCA->prevRefChanIndx = hStereoTCA->refChanIndx;
+ hStereoTCA->prevRefChanIndx = hStereoTCA->refChanIndx; /* Q0 */
move16();
/* save the corr lag stats for next frame */
- Copy( hStereoTCA->corrLagStats, hStereoTCA->prevCorrLagStats, 3 );
+ Copy( hStereoTCA->corrLagStats, hStereoTCA->prevCorrLagStats, 3 ); /* Q0 */
/* save the target gain for next frame */
hStereoTCA->prevTargetGain_fx = hStereoTCA->targetGain_fx; // Q29
@@ -2121,18 +2117,18 @@ void stereo_tca_enc_fx(
*-------------------------------------------------------------------*/
void stereo_tca_init_enc_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo ICA handle */
- const Word32 input_Fs /* i : input sampling frequency */
+ const Word32 input_Fs /* i : input sampling frequency Q0*/
)
{
Word16 div1;
Word16 div_e;
hStereoTCA->lMemRecalc = NS2SA_FX2( input_Fs, L_MEM_RECALC_NS );
move16();
- div1 = BASOP_Util_Divide3232_Scale( L_mult( hStereoTCA->lMemRecalc, INT_FS_12k8 ), input_Fs, &div_e );
+ div1 = BASOP_Util_Divide3232_Scale( L_mult( hStereoTCA->lMemRecalc, INT_FS_12k8 ), input_Fs, &div_e ); /* Q15-div_e */
hStereoTCA->lMemRecalc_12k8 = shr( div1, 1 + sub( 15, div_e ) );
move16();
- div1 = BASOP_Util_Divide3232_Scale( L_mult( hStereoTCA->lMemRecalc, INT_FS_16k ), input_Fs, &div_e );
+ div1 = BASOP_Util_Divide3232_Scale( L_mult( hStereoTCA->lMemRecalc, INT_FS_16k ), input_Fs, &div_e ); /* Q15-div_e */
hStereoTCA->lMemRecalc_16k = shr( div1, 1 + sub( 15, div_e ) );
move16();
@@ -2210,10 +2206,10 @@ static void unclr_calc_corr_features_fx(
Word32 buf1[], /* i : left channel q_com*/
Word32 buf2[], /* i : right channel q_com*/
Word16 q_com,
- const Word16 length, /* i : length of input signal buffers */
+ const Word16 length, /* i : length of input signal buffers Q0*/
Word32 corrEst[], /* i : buffer containing inter-channel correlation values corrEst_exp*/
Word16 corrEst_exp,
- const Word16 lagSearchRange[], /* i : minimum and maximum lags for corrEst[] */
+ const Word16 lagSearchRange[], /* i : minimum and maximum lags for corrEst[] Q0*/
Word32 *corrEst_ncorr, /* o : norm. x-correlation btw. current and previous correlation buffers corrEst_ncorr_exp*/
Word16 *corrEst_ncorr_exp )
{
@@ -2246,22 +2242,22 @@ static void unclr_calc_corr_features_fx(
FOR( i = 0; i < length; i++ )
{
- mono_i = BASOP_Util_Add_Mant32Exp( L_shr( buf1[i], 1 ), sub( 31, q_com ), L_shr( buf2[i], 1 ), sub( 31, q_com ), &exp );
- corrL = BASOP_Util_Add_Mant32Exp( corrL, corrL_exp, Mpy_32_32( buf1[i], mono_i ), add( sub( 31, q_com ), exp ), &corrL_exp );
- corrR = BASOP_Util_Add_Mant32Exp( corrR, corrR_exp, Mpy_32_32( buf2[i], mono_i ), add( sub( 31, q_com ), exp ), &corrR_exp );
+ mono_i = BASOP_Util_Add_Mant32Exp( L_shr( buf1[i], 1 ), sub( 31, q_com ), L_shr( buf2[i], 1 ), sub( 31, q_com ), &exp ); /* Q31-exp */
+ corrL = BASOP_Util_Add_Mant32Exp( corrL, corrL_exp, Mpy_32_32( buf1[i], mono_i ), add( sub( 31, q_com ), exp ), &corrL_exp ); /* Q31-corrL_exp */
+ corrR = BASOP_Util_Add_Mant32Exp( corrR, corrR_exp, Mpy_32_32( buf2[i], mono_i ), add( sub( 31, q_com ), exp ), &corrR_exp ); /* Q31-corrR_exp */
ener = BASOP_Util_Add_Mant32Exp( ener, ener_exp, Mpy_32_32( mono_i, mono_i ), shl( exp, 1 ), &ener_exp );
- side_i = BASOP_Util_Add_Mant32Exp( L_shr( buf1[i], 1 ), sub( 31, q_com ), L_negate( L_shr( buf2[i], 1 ) ), sub( 31, q_com ), &exp );
- ener_side = BASOP_Util_Add_Mant32Exp( ener_side, ener_side_exp, Mpy_32_32( side_i, side_i ), shl( exp, 1 ), &ener_side_exp );
- sum_prod = BASOP_Util_Add_Mant32Exp( sum_prod, sum_prod_exp, Mpy_32_32( buf1[i], buf2[i] ), sub( 62, shl( q_com, 1 ) ), &sum_prod_exp );
+ side_i = BASOP_Util_Add_Mant32Exp( L_shr( buf1[i], 1 ), sub( 31, q_com ), L_negate( L_shr( buf2[i], 1 ) ), sub( 31, q_com ), &exp ); /* Q31-exp */
+ ener_side = BASOP_Util_Add_Mant32Exp( ener_side, ener_side_exp, Mpy_32_32( side_i, side_i ), shl( exp, 1 ), &ener_side_exp ); /* Q31-ener_side_exp */
+ sum_prod = BASOP_Util_Add_Mant32Exp( sum_prod, sum_prod_exp, Mpy_32_32( buf1[i], buf2[i] ), sub( 62, shl( q_com, 1 ) ), &sum_prod_exp ); /* Q31-sum_prod_exp */
}
/* average energy of L and R channels */
- hStereoClassif->ave_ener_L_fx = Mpy_32_32( hStereoTCA->E1_mem_fx, 13421772 /* 1/length in Q31*/ );
+ hStereoClassif->ave_ener_L_fx = Mpy_32_32( hStereoTCA->E1_mem_fx, 13421772 /* 1/length in Q31*/ ); /* Q31-hStereoClassif->ave_ener_L_fx_e */
move32();
hStereoClassif->ave_ener_L_fx_e = hStereoTCA->E1_mem_exp;
move16();
- hStereoClassif->ave_ener_R_fx = Mpy_32_32( hStereoTCA->E2_mem_fx, 13421772 /* 1/length in Q31*/ );
+ hStereoClassif->ave_ener_R_fx = Mpy_32_32( hStereoTCA->E2_mem_fx, 13421772 /* 1/length in Q31*/ ); /* Q31-hStereoClassif->ave_ener_R_fx_e */
move32();
hStereoClassif->ave_ener_R_fx_e = hStereoTCA->E2_mem_exp;
move16();
@@ -2269,7 +2265,7 @@ static void unclr_calc_corr_features_fx(
/* unnormalized L/R correlation */
IF( sum_prod )
{
- sum_prod = BASOP_Util_Log10( L_abs( sum_prod ), sum_prod_exp );
+ sum_prod = BASOP_Util_Log10( L_abs( sum_prod ), sum_prod_exp ); /* Q31-sum_prod_exp */
sum_prod_exp = 6;
move16();
}
@@ -2286,12 +2282,12 @@ static void unclr_calc_corr_features_fx(
hStereoClassif->xtalk_fv_fx[E_sum_prod] = L_shr( sum_prod, 10 ); // Q15
move32();
/* S/M energy ratio */
- Word32 inp1 = Sqrt32( Mpy_32_32( ener_side, 13421773 /* 1/L_FRAME_DS in Q31*/ ), &ener_side_exp );
- inp1 = BASOP_Util_Log10( inp1, ener_side_exp );
+ Word32 inp1 = Sqrt32( Mpy_32_32( ener_side, 13421773 /* 1/L_FRAME_DS in Q31*/ ), &ener_side_exp ); /* Q31-ener_side_exp */
+ inp1 = BASOP_Util_Log10( inp1, ener_side_exp ); /* Q31-ener_side_exp */
Word16 temp = ener_exp;
move16();
- Word32 inp2 = Sqrt32( Mpy_32_32( ener, 13421773 /* 1/L_FRAME_DS in Q31*/ ), &ener_exp );
- inp2 = BASOP_Util_Log10( inp2, ener_exp );
+ Word32 inp2 = Sqrt32( Mpy_32_32( ener, 13421773 /* 1/L_FRAME_DS in Q31*/ ), &ener_exp ); /* Q31-ener_exp */
+ inp2 = BASOP_Util_Log10( inp2, ener_exp ); /* Q31-ener_exp */
ener_exp = temp;
move16();
@@ -2319,17 +2315,17 @@ static void unclr_calc_corr_features_fx(
move32();
}
- hStereoClassif->unclr_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) );
+ hStereoClassif->unclr_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->unclr_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) );
+ hStereoClassif->unclr_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->unclr_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 );
+ hStereoClassif->unclr_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) );
+ hStereoClassif->xtalk_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) );
+ hStereoClassif->xtalk_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 );
+ hStereoClassif->xtalk_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 ); /* Q15 */
move32();
/* L/M and R/M correlation */
@@ -2345,14 +2341,14 @@ static void unclr_calc_corr_features_fx(
move32();
}
- ic_Lm = BASOP_Util_Divide3232_Scale_cadence( corrL, ener, &exp1 );
+ ic_Lm = BASOP_Util_Divide3232_Scale_cadence( corrL, ener, &exp1 ); /* Q31-exp1 */
exp1 = add( exp1, sub( corrL_exp, ener_exp ) );
- ic_Rm = BASOP_Util_Divide3232_Scale_cadence( corrR, ener, &exp2 );
+ ic_Rm = BASOP_Util_Divide3232_Scale_cadence( corrR, ener, &exp2 ); /* Q31-exp2 */
exp2 = add( exp2, sub( corrR_exp, ener_exp ) );
m_corrL_corrR = L_sub( L_max( L_abs( L_shl( ic_Lm, sub( exp1, s_max( exp1, exp2 ) ) ) ), L_abs( L_shl( ic_Rm, sub( exp2, s_max( exp1, exp2 ) ) ) ) ), L_min( L_abs( L_shl( ic_Lm, sub( exp1, s_max( exp1, exp2 ) ) ) ), L_abs( L_shl( ic_Rm, sub( exp2, s_max( exp1, exp2 ) ) ) ) ) ); // s_max(exp1, exp2)
- inp1 = BASOP_Util_Add_Mant32Exp( corrL, corrL_exp, corrR, corrR_exp, &exp );
+ inp1 = BASOP_Util_Add_Mant32Exp( corrL, corrL_exp, corrR, corrR_exp, &exp ); /* Q31-exp */
IF( inp1 )
{
d_corrL_corrR = BASOP_Util_Log10( L_abs( inp1 ), exp ); // Q25
@@ -2372,16 +2368,17 @@ static void unclr_calc_corr_features_fx(
/* norm. x-correlation btw. current and previous correlation buffers */
tempLen = ( 2 * L_NCSHIFT_DS + 1 );
+ move16();
Word64 L64_sum = 0;
move64();
FOR( k = 0; k < tempLen; k++ )
{
- L64_sum = W_mac_32_32( L64_sum, corrEst[k], hStereoTCA->corrEstPrev_fx[2][k] );
+ L64_sum = W_mac_32_32( L64_sum, corrEst[k], hStereoTCA->corrEstPrev_fx[2][k] ); /* 2*(Q31-corrEst_exp)+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- num = W_extract_h( L64_sum ); // ener_side_q
+ L64_sum = W_shl( L64_sum, k ); /* 2*(Q31-corrEst_exp)+1+k */
+ num = W_extract_h( L64_sum ); // ener_side_q
num_exp = sub( 31, sub( add( add( add( sub( 31, corrEst_exp ), sub( 31, hStereoTCA->corrEstPrev_exp ) ), 1 ), k ), 32 ) );
exp1 = corrEst_exp;
@@ -2393,24 +2390,26 @@ static void unclr_calc_corr_features_fx(
inp2 = sum2_32_exp_fx( hStereoTCA->corrEstPrev_fx[2], tempLen, &exp2, 3 );
den_exp = add( exp1, exp2 );
- den = Sqrt32( Mpy_32_32( inp1, inp2 ), &den_exp );
+ den = Sqrt32( Mpy_32_32( inp1, inp2 ), &den_exp ); /* Q31-den_exp */
IF( den == 0 )
{
*corrEst_ncorr = 0;
- move16();
- *corrEst_ncorr_exp = 0;
move32();
+ *corrEst_ncorr_exp = 0;
+ move16();
}
ELSE
{
- *corrEst_ncorr = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp );
+ *corrEst_ncorr = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp ); /* Q31-corrEst_ncorr_exp */
*corrEst_ncorr_exp = add( exp, sub( num_exp, den_exp ) );
+ move32();
+ move16();
}
- hStereoClassif->unclr_fv_fx[E_corrEst_ncorr] = L_shl( *corrEst_ncorr, sub( *corrEst_ncorr_exp, 16 ) );
+ hStereoClassif->unclr_fv_fx[E_corrEst_ncorr] = L_shl( *corrEst_ncorr, sub( *corrEst_ncorr_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrEst_ncorr] = L_shl( *corrEst_ncorr, sub( *corrEst_ncorr_exp, 16 ) );
+ hStereoClassif->xtalk_fv_fx[E_corrEst_ncorr] = L_shl( *corrEst_ncorr, sub( *corrEst_ncorr_exp, 16 ) ); /* Q15 */
move32();
return;
diff --git a/lib_enc/ivas_stereo_icbwe_enc.c b/lib_enc/ivas_stereo_icbwe_enc.c
index 7ed9d71d179ec00e7e98b21412195130e0481684..90d6da69ebfeba9256b988b36f943dba67f767ce 100644
--- a/lib_enc/ivas_stereo_icbwe_enc.c
+++ b/lib_enc/ivas_stereo_icbwe_enc.c
@@ -61,7 +61,7 @@ static void ic_bwe_enc_reset_fx(
/* inter-channel BWE spectral shape adj. */
hStereoICBWE->prevSpecMapping_fx = 0;
move32();
- hStereoICBWE->prevgsMapping_fx = ONE_IN_Q31;
+ hStereoICBWE->prevgsMapping_fx = ONE_IN_Q31; /* Q31 */
move32();
hStereoICBWE->prevgsMapping_e = 0;
move16();
@@ -71,7 +71,7 @@ static void ic_bwe_enc_reset_fx(
set32_fx( hStereoICBWE->memShbSpecXcorr_fx, 0, 6 );
hStereoICBWE->memShbSpecXcorr_e = 0;
move16();
- set32_fx( hStereoICBWE->memGsEnerMap_fx, ONE_IN_Q31, 2 );
+ set32_fx( hStereoICBWE->memGsEnerMap_fx, ONE_IN_Q31, 2 ); /* Q31 */
hStereoICBWE->memGsEnerMap_e = 0;
move16();
set32_fx( hStereoICBWE->mem_nrg_L_fx, 0, 2 );
@@ -83,7 +83,7 @@ static void ic_bwe_enc_reset_fx(
set32_fx( hStereoICBWE->mem_nrg_DMX_fx, 0, 2 );
hStereoICBWE->mem_nrg_DMX_fx_e = 0;
move16();
- hStereoICBWE->gDes_pastFrame_fx = ONE_IN_Q31;
+ hStereoICBWE->gDes_pastFrame_fx = ONE_IN_Q31; /* Q31 */
move32();
hStereoICBWE->gDes_pastFrame_e = 0;
move16();
@@ -101,13 +101,13 @@ static void ic_bwe_enc_reset_fx(
* Encode and apply the spectral shape mapping of ref to the non-ref channel
*---------------------------------------------------------------------------*/
static Word16 ic_bwe_enc_specMapping_ivas_fx(
- const Word32 *shb_frame_target_fx, /* i : target shb */
+ const Word32 *shb_frame_target_fx, /* i : target shb Q31-shb_frame_target_e*/
Word16 shb_frame_target_e,
- Word32 *shb_synth_nonref_fx, /* o : non-ref shb synth */
+ Word32 *shb_synth_nonref_fx, /* o : non-ref shb synth Q31-shb_synth_nonref_e*/
Word16 shb_synth_nonref_e,
- Word32 *specMapping_fx, /* i/o: current frame's mapping */
- Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping */
- Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory */
+ Word32 *specMapping_fx, /* i/o: current frame's mapping Qx*/
+ Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping Qx*/
+ Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory Q31-memShbSpecXcorr_e*/
Word16 *memShbSpecXcorr_e )
{
Word16 idx;
@@ -133,8 +133,8 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
/* Calculate rxx(1)/rxx(0) of the non ref target */
- temp0_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx, shb_frame_target_e, L_FRAME16k - 1, &temp0_exp );
- temp1_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp1_exp );
+ temp0_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx, shb_frame_target_e, L_FRAME16k - 1, &temp0_exp ); /* Q31-temp0_exp */
+ temp1_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp1_exp ); /* Q31-temp1_exp */
/* Smoothing */
temp0_fx = L_shr( temp0_fx, 1 );
@@ -164,10 +164,10 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
}
/* Calculate rxx(1)/rxx(0) of the non ref synth */
- temp0_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, L_FRAME16k - 3, &temp0_exp );
- temp1_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 1, shb_synth_nonref_e, L_FRAME16k - 3, &temp1_exp );
- temp2_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 2, shb_synth_nonref_e, L_FRAME16k - 3, &temp2_exp );
- temp3_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 3, shb_synth_nonref_e, L_FRAME16k - 3, &temp3_exp );
+ temp0_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, L_FRAME16k - 3, &temp0_exp ); /* Q31-temp0_exp */
+ temp1_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 1, shb_synth_nonref_e, L_FRAME16k - 3, &temp1_exp ); /* Q31-temp1_exp */
+ temp2_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 2, shb_synth_nonref_e, L_FRAME16k - 3, &temp2_exp ); /* Q31-temp2_exp */
+ temp3_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 3, shb_synth_nonref_e, L_FRAME16k - 3, &temp3_exp ); /* Q31-temp3_exp */
/* Smoothing */
temp0_fx = L_shr( temp0_fx, 1 );
@@ -193,10 +193,10 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
move16();
}
}
- memShbSpecXcorr_fx[2] = L_shr( temp0_fx, sub( exp, temp0_exp ) );
- memShbSpecXcorr_fx[3] = L_shr( temp1_fx, sub( exp, temp1_exp ) );
- memShbSpecXcorr_fx[4] = L_shr( temp2_fx, sub( exp, temp2_exp ) );
- memShbSpecXcorr_fx[5] = L_shr( temp3_fx, sub( exp, temp3_exp ) );
+ memShbSpecXcorr_fx[2] = L_shr( temp0_fx, sub( exp, temp0_exp ) ); /* Q31-exp */
+ memShbSpecXcorr_fx[3] = L_shr( temp1_fx, sub( exp, temp1_exp ) ); /* Q31-exp */
+ memShbSpecXcorr_fx[4] = L_shr( temp2_fx, sub( exp, temp2_exp ) ); /* Q31-exp */
+ memShbSpecXcorr_fx[5] = L_shr( temp3_fx, sub( exp, temp3_exp ) ); /* Q31-exp */
*memShbSpecXcorr_e = exp;
move32();
@@ -208,9 +208,9 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
IF( temp0_fx != 0 )
{
- Txx1_fx = BASOP_Util_Divide3232_Scale( temp1_fx, temp0_fx, &Txx1_e );
- Txx2_fx = BASOP_Util_Divide3232_Scale( temp2_fx, temp0_fx, &Txx2_e );
- Txx3_fx = BASOP_Util_Divide3232_Scale( temp3_fx, temp0_fx, &Txx3_e );
+ Txx1_fx = BASOP_Util_Divide3232_Scale( temp1_fx, temp0_fx, &Txx1_e ); /* Q31-Txx1_e */
+ Txx2_fx = BASOP_Util_Divide3232_Scale( temp2_fx, temp0_fx, &Txx2_e ); /* Q31-Txx1_e */
+ Txx3_fx = BASOP_Util_Divide3232_Scale( temp3_fx, temp0_fx, &Txx3_e ); /* Q31-Txx1_e */
}
T_desired_fx = T_nonref_target_fx;
@@ -219,32 +219,32 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
move16();
Word16 tmp, tmp1;
- exp = BASOP_Util_Add_MantExp( Txx3_fx, Txx3_e, Txx1_fx, Txx1_e, &tmp );
- tmp1 = mult( Txx2_fx, T_desired_fx ); // Txx2_e + T_desired_e
- a_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx2_e, T_desired_e ), 1 ), negate( tmp ), exp, &a_fx );
+ exp = BASOP_Util_Add_MantExp( Txx3_fx, Txx3_e, Txx1_fx, Txx1_e, &tmp ); /* Q15-exp */
+ tmp1 = mult( Txx2_fx, T_desired_fx ); // Txx2_e + T_desired_e
+ a_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx2_e, T_desired_e ), 1 ), negate( tmp ), exp, &a_fx ); /* Q15-a_e */
- exp = BASOP_Util_Add_MantExp( Txx2_fx, Txx2_e, 32767, 1, &tmp );
- tmp1 = mult( Txx1_fx, T_desired_fx ); // Txx1_e + T_desired_e
- b_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx1_e, T_desired_e ), 1 ), negate( tmp ), exp, &b_fx );
+ exp = BASOP_Util_Add_MantExp( Txx2_fx, Txx2_e, 32767, 1, &tmp ); /* Q15-exp */
+ tmp1 = mult( Txx1_fx, T_desired_fx ); // Txx1_e + T_desired_e
+ b_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx1_e, T_desired_e ), 1 ), negate( tmp ), exp, &b_fx ); /* Q15-b_fx */
- c_e = BASOP_Util_Add_MantExp( T_desired_fx, T_desired_e, negate( Txx1_fx ), Txx1_e, &c_fx );
+ c_e = BASOP_Util_Add_MantExp( T_desired_fx, T_desired_e, negate( Txx1_fx ), Txx1_e, &c_fx ); /* Q15-c_fx */
u_fx = extract_l( *specMapping_fx );
tmp = mult( b_fx, b_fx ); // b_e + b_e;
tmp1 = mult( a_fx, c_fx ); // a_e + c_e + 2
- exp = BASOP_Util_Add_MantExp( tmp, add( b_e, b_e ), tmp1, add( a_e, add( c_e, 2 ) ), &temp_fx );
+ exp = BASOP_Util_Add_MantExp( tmp, add( b_e, b_e ), tmp1, add( a_e, add( c_e, 2 ) ), &temp_fx ); /* Q15-exp */
test();
IF( temp_fx >= 0 && a_fx != 0 )
{
- temp_fx = Sqrt16( temp_fx, &exp );
- exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, temp_fx, exp, &tmp );
- u1_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u1_fx );
+ temp_fx = Sqrt16( temp_fx, &exp ); /* Q15-exp */
+ exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, temp_fx, exp, &tmp ); /* Q15-exp */
+ u1_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u1_fx ); /* Q15-u1_e */
u1_e = add( u1_e, sub( exp, add( a_e, 1 ) ) );
- exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, negate( temp_fx ), exp, &tmp );
- u2_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u2_fx );
+ exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, negate( temp_fx ), exp, &tmp ); /* Q15-exp */
+ u2_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u2_fx ); /* Q15-u2_e */
u2_e = add( u2_e, sub( exp, add( a_e, 1 ) ) );
test();
@@ -298,7 +298,7 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
/* Quantize spec. mapping **/
Word16 specMapping16;
- idx = usquant_fx( shr( u_fx, sub( 0, u_e ) ), &specMapping16, -19660, 6553, 1 << STEREO_ICBWE_SPBITS ); // -0.6 in in Q15 -> -19660, 0.2 in Q15 -> 6553
+ idx = usquant_fx( shr( u_fx, sub( 0, u_e ) ), &specMapping16, -19660, 6553, ( 1 << STEREO_ICBWE_SPBITS ) ); // -0.6 in in Q15 -> -19660, 0.2 in Q15 -> 6553
*specMapping_fx = L_deposit_h( specMapping16 );
move32();
@@ -324,17 +324,17 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
/*! r: return quant. index value */
static Word16 ic_bwe_enc_gsMapping_ivas_fx(
- const Word32 relG_targ_fx, /* i : gDes, rel gain target */
+ const Word32 relG_targ_fx, /* i : gDes, rel gain target Q31-relG_targ_e*/
Word16 relG_targ_e,
- const Word16 *shbSynth_fx, /* i : ref synth signal */
+ const Word16 *shbSynth_fx, /* i : ref synth signal Q15-shbSynth_e*/
Word16 shbSynth_e, /* i : ref synth signal */
- Word32 *synthSHB_nonref_fx, /* i : nonref synth signal */
+ Word32 *synthSHB_nonref_fx, /* i : nonref synth signal Q31-synthSHB_nonref_e*/
Word16 *synthSHB_nonref_e, /* i : nonref synth signal */
- Word32 *gsMapping_fx, /* i/o: gs mapping */
+ Word32 *gsMapping_fx, /* i/o: gs mapping Q31-gsMapping_e*/
Word16 *gsMapping_e, /* i/o: gs mapping */
- Word32 *memEner_fx, /* */
+ Word32 *memEner_fx, /* Q31-memEner_e*/
Word16 *memEner_e,
- const Word16 element_mode /* i : element mode */
+ const Word16 element_mode /* i : element mode Q0*/
)
{
Word16 i;
@@ -355,13 +355,13 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
move16();
FOR( i = 0; i < L_FRAME16k; i++ )
{
- temp1_fx32 = BASOP_Util_Add_Mant32Exp( temp1_fx32, temp1_exp, L_abs( L_deposit_h( shbSynth_fx[i] ) ), exp1, &temp1_exp );
- temp2_fx32 = BASOP_Util_Add_Mant32Exp( temp2_fx32, temp2_exp, L_abs( synthSHB_nonref_fx[i] ), exp2, &temp2_exp );
+ temp1_fx32 = BASOP_Util_Add_Mant32Exp( temp1_fx32, temp1_exp, L_abs( L_deposit_h( shbSynth_fx[i] ) ), exp1, &temp1_exp ); /* Q31-temp1_exp */
+ temp2_fx32 = BASOP_Util_Add_Mant32Exp( temp2_fx32, temp2_exp, L_abs( synthSHB_nonref_fx[i] ), exp2, &temp2_exp ); /* Q31-temp2_exp */
}
- memEner_fx[0] = temp1_fx32;
- memEner_fx[1] = L_shr( temp2_fx32, abs_s( sub( temp1_exp, temp2_exp ) ) );
+ memEner_fx[0] = temp1_fx32; /* Q31-temp1_exp */
+ memEner_fx[1] = L_shr( temp2_fx32, abs_s( sub( temp1_exp, temp2_exp ) ) ); /* Q31-temp1_exp */
move32();
move32();
*memEner_e = s_max( temp1_exp, temp2_exp );
@@ -389,7 +389,7 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
temp2_fx = extract_l( L_shr( temp2_fx32, Q10 ) ); // Q15
gsMapping_fx16 = 0;
move16();
- idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMapping_tbl_fx, 1 << STEREO_ICBWE_GSBITS ); // Q12
+ idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMapping_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS ) ); // Q12
// idx = squant_fx( temp2, gsMapping, icbwe_gsMapping_tbl_fx, 1 << STEREO_ICBWE_GSBITS );
}
ELSE
@@ -397,13 +397,13 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
temp2_fx = extract_l( L_shr( temp2_fx32, Q10 ) ); // Q15
gsMapping_fx16 = 0;
move16();
- idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMappingDFT_tbl_fx, 1 << STEREO_ICBWE_GSBITS ); // Q12
+ idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMappingDFT_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS ) ); // Q12
}
*gsMapping_fx = L_deposit_h( gsMapping_fx16 ); // Q28
move32();
Word16 e;
L_mult = Mult_32_16( *gsMapping_fx, 27213 /*=log2(10)*2^13*/ ); // Q27 + Q13 - Q15 -> Q26
- *gsMapping_fx = BASOP_util_Pow2( L_mult, 5, &e );
+ *gsMapping_fx = BASOP_util_Pow2( L_mult, 5, &e ); /* Q31-e */
move32();
*gsMapping_e = e; // Q31
@@ -420,7 +420,7 @@ static void icbwe_dft_stereo_param_ivas_fx(
STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: */
STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i : */
Encoder_State *st, /* i/o: */
- Word32 *shb_synth_nonref_fx, /* i/o: */
+ Word32 *shb_synth_nonref_fx, /* i/o: Q31-shb_synth_nonref_e*/
Word16 shb_synth_nonref_e /* i/o: */
)
{
@@ -465,6 +465,9 @@ static void icbwe_dft_stereo_param_ivas_fx(
sum_nrg_L_fx = sum_32_fx( hStereoICBWE->mem_nrg_L_fx, 2, &sum_nrg_L_e ); // hStereoICBWE->mem_nrg_L_fx_e
sum_nrg_R_fx = sum_32_fx( hStereoICBWE->mem_nrg_R_fx, 2, &sum_nrg_R_e ); // hStereoICBWE->mem_nrg_R_fx_e
sum_nrg_DMX_fx = sum_32_fx( hStereoICBWE->mem_nrg_DMX_fx, 2, &sum_nrg_DMX_e ); // hStereoICBWE->mem_nrg_DMX_fx_e
+ move16();
+ move16();
+ move16();
/* refChanIndex_bwe refinement */
@@ -487,7 +490,7 @@ static void icbwe_dft_stereo_param_ivas_fx(
slopeILD_fx = 0;
move32();
- spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT );
+ spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT ); /* Q0 */
test();
test();
@@ -499,26 +502,21 @@ static void icbwe_dft_stereo_param_ivas_fx(
Word32 L_tmp, L_tmp1;
L_tmp = Mpy_32_32( hStereoICBWE->mem_nrg_L_fx[1], hStereoICBWE->mem_nrg_R_fx[0] ); // hStereoICBWE->mem_nrg_L_fx_e[1] + hStereoICBWE->mem_nrg_R_fx_e[1]
L_tmp1 = Mpy_32_32( hStereoICBWE->mem_nrg_R_fx[1], hStereoICBWE->mem_nrg_L_fx[0] ); // hStereoICBWE->mem_nrg_L_fx_e[1] + hStereoICBWE->mem_nrg_R_fx_e[1]
- tmp1 = BASOP_Util_Divide3232_Scale( L_tmp, L_tmp1, &exp1 );
+ tmp1 = BASOP_Util_Divide3232_Scale( L_tmp, L_tmp1, &exp1 ); /* Q15-exp1 */
exp1 = add( exp1, sub( add( hStereoICBWE->mem_nrg_L_fx_e, hStereoICBWE->mem_nrg_R_fx_e ), add( hStereoICBWE->mem_nrg_L_fx_e, hStereoICBWE->mem_nrg_R_fx_e ) ) );
L_tmp = BASOP_Util_Log10( L_deposit_h( tmp1 ), exp1 );
L_tmp = Mpy_32_32( normFac_fx, L_tmp ); // // Q25 + Q29 - Q31 -> Q23
slopeILD_fx = extract_l( L_shr( L_tmp, 16 ) ); // Q23 - Q16 -> Q7
IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
{
- slopeILD_fx = negate( slopeILD_fx );
- }
- ELSE
- {
- slopeILD_fx = slopeILD_fx;
- move16();
+ slopeILD_fx = negate( slopeILD_fx ); /* Q7 */
}
spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT );
IF( Mpy_32_32( spec_table_fx[spIndx], hStereoICBWE->prevSpecMapping_fx ) < 0 )
{
slopeILD_fx = 0;
move32();
- spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT );
+ spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT ); /* Q0 */
}
hStereoICBWE->prevSpecMapping_fx = spec_table_fx[spIndx]; // q31
@@ -538,16 +536,16 @@ static void icbwe_dft_stereo_param_ivas_fx(
Word16 exp;
IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
{
- gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_R_fx, sum_nrg_DMX_fx, &exp );
+ gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_R_fx, sum_nrg_DMX_fx, &exp ); /* Q15-exp */
exp = add( exp, sub( sum_nrg_R_e, sum_nrg_DMX_e ) );
}
ELSE
{
- gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_L_fx, sum_nrg_DMX_fx, &exp );
+ gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_L_fx, sum_nrg_DMX_fx, &exp ); /* Q15-exp */
exp = add( exp, sub( sum_nrg_L_e, sum_nrg_DMX_e ) );
}
- gDes_fx = Sqrt16( gDes_fx, &exp );
+ gDes_fx = Sqrt16( gDes_fx, &exp ); /* Q15-exp */
Word16 exp1 = hStereoICBWE->gDes_pastFrame_e, exp2, tmp;
Word32 tmp321 = 0, tmp322 = 0;
move32();
@@ -556,16 +554,16 @@ static void icbwe_dft_stereo_param_ivas_fx(
tmp321 = Sqrt32( hStereoICBWE->gDes_pastFrame_fx, &exp1 ); // exp1
exp2 = exp;
move16();
- tmp = Sqrt16( gDes_fx, &exp2 );
+ tmp = Sqrt16( gDes_fx, &exp2 ); /* Q15-exp2 */
tmp322 = Mpy_32_32( tmp321, L_deposit_h( tmp ) ); // exp1 + exp2
hStereoICBWE->gDes_pastFrame_fx = tmp322;
hStereoICBWE->gDes_pastFrame_e = add( exp1, exp2 );
move32();
move16();
- gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode );
+ gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
- hStereoICBWE->gDes_pastFrame_fx = L_deposit_h( gDes_fx );
+ hStereoICBWE->gDes_pastFrame_fx = L_deposit_h( gDes_fx ); /* Q31-exp */
hStereoICBWE->gDes_pastFrame_e = exp;
move32();
move16();
@@ -584,9 +582,9 @@ static void icbwe_dft_stereo_param_ivas_fx(
void stereo_icBWE_enc_ivas_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel */
+ const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel Q31-shb_speech_ref_e*/
const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */
- Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel */
+ Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/
Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */
const Word32 *voice_factors_fx /* i : voicing factors Q31 */
)
@@ -689,7 +687,7 @@ void stereo_icBWE_enc_ivas_fx(
shb_synth_nonref_e = max_e;
move16();
- Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) );
+ Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) ); /* shb_speech_ref_e */
Copy_Scale_sig_32_16( shb_frame_ref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) - Q16 ); // mem_shb_speech_ref_e
test();
@@ -724,7 +722,7 @@ void stereo_icBWE_enc_ivas_fx(
{
temp1_fx = 0;
temp1_e = 0;
- temp2_fx = ONE_IN_Q31;
+ temp2_fx = ONE_IN_Q31; /* Q31 */
temp2_e = 0;
move16();
move32();
@@ -735,16 +733,16 @@ void stereo_icBWE_enc_ivas_fx(
{
temp1_e = 0, temp2_e = 0;
move16();
- move32();
+ move16();
temp1_fx = Sqrt32( nlMixFac_fx[i], &temp1_e );
- temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e );
+ temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e ); /* Q31-temp2_e */
}
- tmp = BASOP_Util_Divide1616_Scale( L_FRAME16k, nbSubFr, &exp );
- tmp = shr( tmp, sub( Q15, exp ) );
+ tmp = BASOP_Util_Divide1616_Scale( L_FRAME16k, nbSubFr, &exp ); /* Q15-exp */
+ tmp = shr( tmp, sub( Q15, exp ) ); /* Q0 */
FOR( j = 0; j < tmp; ( j++, k++ ) )
{
- excSHB_nonref_fx[k] = extract_l( BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, hStereoICBWE->nlExc16k_fx[k] ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, hStereoICBWE->mixExc16k_fx[k] ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ) );
+ excSHB_nonref_fx[k] = extract_l( BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, hStereoICBWE->nlExc16k_fx[k] ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, hStereoICBWE->mixExc16k_fx[k] ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ) ); /* Q31-exp_buf */
move32();
}
}
@@ -762,7 +760,7 @@ void stereo_icBWE_enc_ivas_fx(
FOR( j = 0; j < L_FRAME16k; j++ )
{
- excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) );
+ excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */
move32();
}
/* LP synthesis */
@@ -770,8 +768,8 @@ void stereo_icBWE_enc_ivas_fx(
Word32 lpSHBRef_fx32[LPC_SHB_ORDER + 1];
- Copy_Scale_sig32( hCPE->hStereoICBWE->lpSHBRef_fx, lpSHBRef_fx32, LPC_SHB_ORDER + 1, negate( sub( tmp_e, hCPE->hStereoICBWE->lpSHBRef_e ) ) );
- Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_e, max_e ) ) );
+ Copy_Scale_sig32( hCPE->hStereoICBWE->lpSHBRef_fx, lpSHBRef_fx32, LPC_SHB_ORDER + 1, negate( sub( tmp_e, hCPE->hStereoICBWE->lpSHBRef_e ) ) ); /* Q31-tmp_e */
+ Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_e, max_e ) ) ); /* Q31-tmp_e */
// set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, LPC_SHB_ORDER );
E_UTIL_synthesis_fx( 0, lpSHBRef_fx32, excSHB_nonref_fx, shb_synth_nonref_fx, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 1, LPC_SHB_ORDER );
@@ -782,10 +780,10 @@ void stereo_icBWE_enc_ivas_fx(
}
ELSE
{
- Copy_Scale_sig_32_16( shb_frame_ref_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k, -16 ); // max_e
+ Copy_Scale_sig_32_16( shb_frame_ref_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k, -16 ); /* Q15-shb_frame_ref_e */
hStereoICBWE->shbSynthRef_e = shb_frame_ref_e;
move16();
- Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k ); // max_e
+ Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k ); /* Q31-shb_frame_ref_e */
shb_synth_nonref_e = shb_frame_ref_e;
move16();
set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 );
@@ -810,7 +808,7 @@ void stereo_icBWE_enc_ivas_fx(
move16();
/* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */
- Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) );
+ Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) ); /* Q31-max_e */
Copy_Scale_sig_32_16( shb_frame_ref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e
set32_fx( shb_frame_nonref_fx, 0, L_LOOK_16k + L_FRAME16k );
@@ -826,7 +824,7 @@ void stereo_icBWE_enc_ivas_fx(
move16();
/* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */
- Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) );
+ Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) ); /* Q31-max_e */
Copy_Scale_sig_32_16( shb_frame_nonref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e
@@ -871,14 +869,14 @@ void stereo_icBWE_enc_ivas_fx(
move32();
move32();
L_tmp = sum2_32_fx( shb_frame_nonref_fx + sub( L_LOOK_16k, refMemLen ), L_FRAME16k, &temp1_e );
- temp1_fx = Sqrt32( L_tmp, &temp1_e );
+ temp1_fx = Sqrt32( L_tmp, &temp1_e ); /* Q31-temp1_e */
/*temp1 = 0.8f*hStereoICBWE->prevNonRefEner + 0.2f*temp1;*/
/*temp2 = 0.8f*hStereoICBWE->prevRefEner + 0.2f*temp2;*/
IF( temp2_fx == 0 )
{
- gDes_fx = 1073741824;
+ gDes_fx = 1073741824; /* 1.0 in Q30 */
gDes_e = 1;
move16();
move32();
@@ -894,8 +892,8 @@ void stereo_icBWE_enc_ivas_fx(
exp = hStereoICBWE->gDes_pastFrame_e;
move16();
move16();
- L_tmp = Sqrt32( gDes_fx, &tmp );
- L_tmp1 = Sqrt32( hStereoICBWE->gDes_pastFrame_fx, &exp );
+ L_tmp = Sqrt32( gDes_fx, &tmp ); /* Q31-tmp */
+ L_tmp1 = Sqrt32( hStereoICBWE->gDes_pastFrame_fx, &exp ); /* Q31-exp */
hStereoICBWE->gDes_pastFrame_fx = Mpy_32_32( L_tmp, L_tmp1 ); // tmp + exp
hStereoICBWE->gDes_pastFrame_e = add( tmp, exp );
@@ -918,9 +916,9 @@ void stereo_icBWE_enc_ivas_fx(
Copy32( voice_factors_fx, nlMixFac_fx, NB_SUBFR16k ); // Q31
test();
- IF( LT_32( gTarget_fx, 268435456 ) || GT_32( gTarget_fx, 1073741824 ) ) //
+ IF( LT_32( gTarget_fx, 268435456 ) || GT_32( gTarget_fx, 1073741824 ) ) // 0.5 in Q29 & 2.0 in Q29
{
- v_multc_fixed( voice_factors_fx, 1073741824, nlMixFac_fx, NB_SUBFR16k );
+ v_multc_fixed( voice_factors_fx, 1073741824 /*0.5 in Q31*/, nlMixFac_fx, NB_SUBFR16k ); /* Q31 */
}
IF( st->flag_ACELP16k == 0 )
@@ -944,7 +942,7 @@ void stereo_icBWE_enc_ivas_fx(
temp1_fx = 0;
temp1_e = 0;
- temp2_fx = ONE_IN_Q31;
+ temp2_fx = ONE_IN_Q31; /* Q31 */
temp2_e = 0;
move32();
move32();
@@ -954,15 +952,15 @@ void stereo_icBWE_enc_ivas_fx(
ELSE
{
temp1_e = 0, temp2_e = 0;
- temp1_fx = Sqrt32( nlMixFac_fx[i], &temp1_e );
- temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e );
+ temp1_fx = Sqrt32( nlMixFac_fx[i], &temp1_e ); /* Q31-temp1_e */
+ temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e ); /* Q31 */
move32();
move16();
}
FOR( j = 0; j < ( L_FRAME16k / nbSubFr ); ( j++, k++ ) )
{
- excSHB_nonref_fx[k] = extract_l( BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, hStereoICBWE->nlExc16k_fx[k] ), temp1_e + hStereoICBWE->nlExc16k_e, Mpy_32_32( temp2_fx, hStereoICBWE->mixExc16k_fx[k] ), temp2_e + hStereoICBWE->mixExc16k_e, &exp_buf[k] ) );
+ excSHB_nonref_fx[k] = extract_l( BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, hStereoICBWE->nlExc16k_fx[k] ), temp1_e + hStereoICBWE->nlExc16k_e, Mpy_32_32( temp2_fx, hStereoICBWE->mixExc16k_fx[k] ), temp2_e + hStereoICBWE->mixExc16k_e, &exp_buf[k] ) ); /* Q31-exp_buf */
move32();
}
}
@@ -980,7 +978,7 @@ void stereo_icBWE_enc_ivas_fx(
FOR( j = 0; j < L_FRAME16k; j++ )
{
- excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) );
+ excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */
move32();
}
/* LP synthesis */
@@ -989,8 +987,8 @@ void stereo_icBWE_enc_ivas_fx(
Word32 lpSHBRef_fx32[LPC_SHB_ORDER + 1];
- Copy_Scale_sig32( hCPE->hStereoICBWE->lpSHBRef_fx, lpSHBRef_fx32, LPC_SHB_ORDER + 1, negate( sub( tmp_e, hCPE->hStereoICBWE->lpSHBRef_e ) ) );
- Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_e, max_e ) ) );
+ Copy_Scale_sig32( hCPE->hStereoICBWE->lpSHBRef_fx, lpSHBRef_fx32, LPC_SHB_ORDER + 1, negate( sub( tmp_e, hCPE->hStereoICBWE->lpSHBRef_e ) ) ); /* Q31-tmp_e */
+ Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_e, max_e ) ) ); /* Q31-tmp_e */
E_UTIL_synthesis_fx( 0, hStereoICBWE->lpSHBRef_fx, excSHB_nonref_fx, shb_synth_nonref_fx, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 1, LPC_SHB_ORDER );
shb_synth_nonref_e = sub( 31, tmp_e );
@@ -1002,7 +1000,7 @@ void stereo_icBWE_enc_ivas_fx(
Copy_Scale_sig_32_16( shb_frame_ref_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k, -16 ); // max_e
hStereoICBWE->shbSynthRef_e = shb_frame_ref_e;
move16();
- Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k );
+ Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k ); /* Q31-shb_synth_nonref_e */
shb_synth_nonref_e = shb_frame_ref_e;
move16();
set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 );
@@ -1014,7 +1012,7 @@ void stereo_icBWE_enc_ivas_fx(
IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
{
/* IC BWE spectral mapping */
- spIndx = ic_bwe_enc_specMapping_ivas_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) );
+ spIndx = ic_bwe_enc_specMapping_ivas_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) ); /* Q0 */
}
ELSE
{
@@ -1038,9 +1036,9 @@ void stereo_icBWE_enc_ivas_fx(
/* IC BWE GS mapping */
- gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode );
+ gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
- hStereoICBWE->gDes_pastFrame_fx = gDes_fx;
+ hStereoICBWE->gDes_pastFrame_fx = gDes_fx; /* Q31-hStereoICBWE->gDes_pastFrame_e */
hStereoICBWE->gDes_pastFrame_e = gDes_e;
move32();
move16();
@@ -1048,7 +1046,7 @@ void stereo_icBWE_enc_ivas_fx(
}
/* IC-BWE updates */
- hStereoICBWE->prev_refChanIndx_bwe = hStereoICBWE->refChanIndx_bwe;
+ hStereoICBWE->prev_refChanIndx_bwe = hStereoICBWE->refChanIndx_bwe; /* Q0 */
move16();
return;
@@ -1152,19 +1150,19 @@ void stereo_icBWE_init_enc_fx(
* Inter-channel BWE pre-proc of the non-ref channel
*-------------------------------------------------------------------*/
static void findRefChanBWE_fx(
- const Word16 *input0_fx, /* i/o : input 0 Qx */
- const Word16 *input1_fx, /* i/o : input 1 Qx */
- Word16 *refChanIndx_bwe, /* o : Ref Channel Index bwe */
- const Word16 input_frame, /* i : input 0 & 1 frame length */
- Word16 *mem0_fx, /* i/o : mem 0 for input 0 Qx */
- Word16 *mem1_fx /* i/o : mem 1 for input 1 Qx */
+ const Word16 *input0_fx, /* i/o : input 0 Qx q_dataChan_fx*/
+ const Word16 *input1_fx, /* i/o : input 1 Qx q_dataChan_fx*/
+ Word16 *refChanIndx_bwe, /* o : Ref Channel Index bwe Q0*/
+ const Word16 input_frame, /* i : input 0 & 1 frame length Q0*/
+ Word16 *mem0_fx, /* i/o : mem 0 for input 0 Qx q_dataChan_fx*/
+ Word16 *mem1_fx /* i/o : mem 1 for input 1 Qx q_dataChan_fx*/
)
{
Word16 inp0_fx[L_FRAME48k], inp1_fx[L_FRAME48k];
Word32 tempF_fx, tempF1_fx;
- Copy( input0_fx, inp0_fx, input_frame );
- Copy( input1_fx, inp1_fx, input_frame );
+ Copy( input0_fx, inp0_fx, input_frame ); /* q_dataChan_fx */
+ Copy( input1_fx, inp1_fx, input_frame ); /* q_dataChan_fx */
spectral_balancer_fx16( inp0_fx, mem0_fx, input_frame, 1 );
spectral_balancer_fx16( inp1_fx, mem1_fx, input_frame, 1 );
@@ -1174,12 +1172,12 @@ static void findRefChanBWE_fx(
IF( LT_32( tempF1_fx, Mpy_32_32( 1374389535 /* 0.64f Q31 */, tempF_fx ) ) )
{
- *refChanIndx_bwe = L_CH_INDX;
+ *refChanIndx_bwe = L_CH_INDX; /* Q0 */
move16();
}
ELSE IF( LT_32( tempF_fx, Mpy_32_32( 1374389535 /* 0.64f Q31 */, tempF1_fx ) ) )
{
- *refChanIndx_bwe = R_CH_INDX;
+ *refChanIndx_bwe = R_CH_INDX; /* Q0 */
move16();
}
@@ -1194,8 +1192,8 @@ static void findRefChanBWE_fx(
*-------------------------------------------------------------------*/
void stereo_icBWE_preproc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word16 input_frame, /* i : input frame length */
- Word16 shb_speech_nonref_fx[], /* o : SHB speech non-ref channel */
+ const Word16 input_frame, /* i : input frame length Q0*/
+ Word16 shb_speech_nonref_fx[], /* o : SHB speech non-ref channel q_shb_speech_nonref_fx*/
Word16 q_shb_speech_nonref_fx /* i : Q SHB speech non-ref channel */
)
{
@@ -1238,11 +1236,11 @@ void stereo_icBWE_preproc_fx(
IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && GE_32( input_Fs, 32000 ) )
{
set16_fx( temp_inp_fx, 0, L_FRAME48k );
- Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) );
+ Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
IF( EQ_32( input_Fs, 48000 ) )
{
- Copy( temp_inp_fx, temp_in_fx, L_FRAME48k );
+ Copy( temp_inp_fx, temp_in_fx, L_FRAME48k ); /* q_dataChan_fx */
set16_fx( temp_inp_fx, 0, L_FRAME48k );
i = 2 * L_FILT48k + L_FILT_2OVER3;
move16();
@@ -1252,17 +1250,17 @@ void stereo_icBWE_preproc_fx(
/* flip the spectrum */
FOR( i = 0; i < L_FRAME32k; i += 2 )
{
- temp_inp_fx[i] = negate( temp_inp_fx[i] );
+ temp_inp_fx[i] = negate( temp_inp_fx[i] ); /* q_dataChan_fx */
move16();
}
- Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[0], 2 * L_FILT32k );
+ Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[0], 2 * L_FILT32k ); /* q_dataChan_fx */
set16_fx( temp_inp_fx, 0, L_FRAME48k );
- Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) );
+ Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
IF( EQ_32( input_Fs, 48000 ) )
{
- Copy( temp_inp_fx, temp_in_fx, L_FRAME48k );
+ Copy( temp_inp_fx, temp_in_fx, L_FRAME48k ); /* q_dataChan_fx */
set16_fx( temp_inp_fx, 0, L_FRAME48k );
i = 2 * L_FILT48k + L_FILT_2OVER3;
move16();
@@ -1273,10 +1271,10 @@ void stereo_icBWE_preproc_fx(
/* flip the spectrum */
FOR( i = 0; i < input_frame; i += 2 )
{
- temp_inp_fx[i] = negate( temp_inp_fx[i] );
+ temp_inp_fx[i] = negate( temp_inp_fx[i] ); /* q_dataChan_fx */
move16();
}
- Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[1], 2 * L_FILT32k );
+ Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[1], 2 * L_FILT32k ); /* q_dataChan_fx */
}
return;
@@ -1285,10 +1283,10 @@ void stereo_icBWE_preproc_fx(
IF( NE_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
/* initial estimate of refChanIndx_bwe */
- gD_fx = hStereoTCA->targetGain_fx;
+ gD_fx = hStereoTCA->targetGain_fx; /* Q29 */
move32();
- refChanIndx_bwe = hStereoTCA->refChanIndx;
+ refChanIndx_bwe = hStereoTCA->refChanIndx; /* Q0 */
move16();
test();
test();
@@ -1298,7 +1296,7 @@ void stereo_icBWE_preproc_fx(
refChanIndx_bwe = !( hStereoTCA->refChanIndx );
move16();
}
- hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe;
+ hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe; /* Q0 */
move16();
set16_fx( hStereoICBWE->dec_2over3_mem_fx, 0, L_FILT_2OVER3 );
@@ -1310,10 +1308,10 @@ void stereo_icBWE_preproc_fx(
return;
}
- gD_fx = hStereoTCA->targetGain_fx;
+ gD_fx = hStereoTCA->targetGain_fx; /* Q29 */
move32();
- refChanIndx_bwe = hStereoTCA->refChanIndx;
+ refChanIndx_bwe = hStereoTCA->refChanIndx; /* Q0 */
move16();
test();
test();
@@ -1331,19 +1329,19 @@ void stereo_icBWE_preproc_fx(
IF( EQ_16( refChanIndx_bwe, R_CH_INDX ) )
{
- Copy( hStereoICBWE->icbwe_inp_mem_fx[0], temp_inp_fx, nonRefMemLen );
- Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) );
+ Copy( hStereoICBWE->icbwe_inp_mem_fx[0], temp_inp_fx, nonRefMemLen ); /* q_dataChan_fx */
+ Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
}
ELSE
{
- Copy( hStereoICBWE->icbwe_inp_mem_fx[1], temp_inp_fx, nonRefMemLen );
- Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) );
+ Copy( hStereoICBWE->icbwe_inp_mem_fx[1], temp_inp_fx, nonRefMemLen ); /* q_dataChan_fx */
+ Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
}
IF( EQ_32( input_Fs, 48000 ) )
{
/*printf("\n Non-ref target HB generation for 48 kHz sample rate needs alignment verification \n");*/
- Copy( temp_inp_fx, temp_in_fx, L_FRAME48k );
+ Copy( temp_inp_fx, temp_in_fx, L_FRAME48k ); /* q_dataChan_fx */
set16_fx( temp_inp_fx, 0, L_FRAME48k );
decimate_2_over_3_allpass_fx( temp_in_fx, L_FRAME48k, temp_inp_fx, hStereoICBWE->dec_2over3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hStereoICBWE->dec_2over3_mem_lp_fx );
@@ -1352,25 +1350,25 @@ void stereo_icBWE_preproc_fx(
/* flip the spectrum */
FOR( i = 0; i < input_frame; i += 2 )
{
- temp_inp_fx[i] = negate( temp_inp_fx[i] );
+ temp_inp_fx[i] = negate( temp_inp_fx[i] ); /* q_dataChan_fx */
move16();
}
test();
test();
test();
- IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && GE_32( input_Fs, 32000 ) && ( NE_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_extl, -1 ) ) )
+ IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && GE_32( input_Fs, 32000 ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_extl, -1 ) ) )
{
- Copy_Scale_sig( hStereoICBWE->memModifyFs_icbwe_fx[!refChanIndx_bwe], hStereoICBWE->mem_decim_shb_ch0_fx, 2 * L_FILT32k, sub( 0, hStereoICBWE->q_dataChan_fx ) );
+ Copy_Scale_sig( hStereoICBWE->memModifyFs_icbwe_fx[!refChanIndx_bwe], hStereoICBWE->mem_decim_shb_ch0_fx, 2 * L_FILT32k, sub( 0, hStereoICBWE->q_dataChan_fx ) ); /* Q0 */
}
Word16 Q_new_inp, mem_decim_size;
- Scale_sig( temp_inp_fx, L_FRAME48k, sub( 0, hStereoICBWE->q_dataChan_fx ) );
+ Scale_sig( temp_inp_fx, L_FRAME48k, sub( 0, hStereoICBWE->q_dataChan_fx ) ); /* q_dataChan_fx */
/* IVAS-219: Re-wire the shb nonref estimation through a lite CLDFB */
modify_Fs_fx( temp_inp_fx, L_FRAME32k, 32000, tempSHB_fx, 16000, hStereoICBWE->mem_decim_shb_ch0_fx, 0, &Q_new_inp, &mem_decim_size );
- Copy_Scale_sig( tempSHB_fx, shb_speech_nonref_fx, L_FRAME16k, sub( q_shb_speech_nonref_fx, Q_new_inp ) );
+ Copy_Scale_sig( tempSHB_fx, shb_speech_nonref_fx, L_FRAME16k, sub( q_shb_speech_nonref_fx, Q_new_inp ) ); /* q_shb_speech_nonref_fx */
return;
}
diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c
index 1b4c9d49f08254b7da8f7e51ce050e599180e4b8..d8dcf5653430c771654e855065d55cd9dc0c799e 100644
--- a/lib_enc/ivas_stereo_mdct_core_enc.c
+++ b/lib_enc/ivas_stereo_mdct_core_enc.c
@@ -49,17 +49,17 @@
* Synchronize under certain conditions the tcx modes and set overlap
* windows accordingly
*-------------------------------------------------------------------*/
-static void sync_tcx_mode(
+static void sync_tcx_mode_fx(
Encoder_State **st /* i/o: Encoder state */
)
{
- const Word32 prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay];
+ const Word32 prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay]; /* Q0 */
move32();
- const Word32 prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay];
+ const Word32 prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay]; /* Q0 */
move32();
- const Word32 lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[add( st[0]->hTranDet->subblockEnergies.nDelay, st[0]->hTranDet->transientDetector.nSubblocksToCheck )];
+ const Word32 lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[( st[0]->hTranDet->subblockEnergies.nDelay + st[0]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q0 */
move32();
- const Word32 lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[add( st[1]->hTranDet->subblockEnergies.nDelay, st[1]->hTranDet->transientDetector.nSubblocksToCheck )];
+ const Word32 lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[( st[1]->hTranDet->subblockEnergies.nDelay + st[1]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q0 */
move32();
test();
@@ -84,8 +84,8 @@ static void sync_tcx_mode(
test();
test();
test();
- IF( GT_32( prevAccNrg0, Mpy_32_16_1( prevAccNrg1, 1311 ) ) && GT_32( prevAccNrg1, Mpy_32_16_1( prevAccNrg0, 1311 ) ) /* 14 dB */
- && GT_32( lastAccNrg0, Mpy_32_16_1( lastAccNrg1, 2048 ) ) && GT_32( lastAccNrg1, Mpy_32_16_1( lastAccNrg0, 2048 ) ) ) /* 12 dB */
+ IF( GT_32( prevAccNrg0, Mpy_32_16_1( prevAccNrg1, 1311 /*1/25 in Q15*/ ) ) && GT_32( prevAccNrg1, Mpy_32_16_1( prevAccNrg0, 1311 /*1/25 in Q15*/ ) ) /* 14 dB */
+ && GT_32( lastAccNrg0, Mpy_32_16_1( lastAccNrg1, 2048 /*1/12 in Q15*/ ) ) && GT_32( lastAccNrg1, Mpy_32_16_1( lastAccNrg0, 2048 /*1/12 in Q15*/ ) ) ) /* 12 dB */
{
st[0]->hTcxEnc->tcxMode = st[1]->hTcxEnc->tcxMode = s_max( st[0]->hTcxEnc->tcxMode, st[1]->hTcxEnc->tcxMode ); /* synchronize TCX mode of both channels */
move16();
@@ -130,15 +130,16 @@ static void sync_tcx_mode(
*-------------------------------------------------------------------*/
void stereo_mdct_core_enc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples */
- Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */
- Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */
+ Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/
+ Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/
+ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/
)
{
Word32 orig_spectrum_long_fx[CPE_CHANNELS][N_MAX]; /* MDCT output (L/R). */
Word32 *orig_spectrum_fx[CPE_CHANNELS][NB_DIV]; /* Pointers to MDCT output for a short block (L/R) */
Word32 powerSpec_fx[CPE_CHANNELS][N_MAX];
Word32 *p_powerSpec_fx[CPE_CHANNELS];
+ Word16 exp_powerSpec[CPE_CHANNELS][N_MAX + L_MDCT_OVLP_MAX];
Word32 powerSpecMsInv_long_fx[CPE_CHANNELS][N_MAX]; /* MS inv power spectrum, also inverse MDST spectrum */
Word32 *powerSpecMsInv_fx[CPE_CHANNELS][NB_DIV];
Word32 quantized_spectrum_long_fx[CPE_CHANNELS][N_MAX]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */
@@ -209,11 +210,11 @@ void stereo_mdct_core_enc_fx(
Word16 tmp_e = 0;
move16();
Word32 L_tmp;
- L_tmp = Sqrt32( L_add( L_shr( Mpy_32_32( sts[0]->hTcxEnc->tfm_mem_fx, sts[0]->hTcxEnc->tfm_mem_fx ), 1 ), L_shr( Mpy_32_32( sts[1]->hTcxEnc->tfm_mem_fx, sts[1]->hTcxEnc->tfm_mem_fx ), 1 ) ), &tmp_e ); /* RMS */
+ L_tmp = Sqrt32( L_add( L_shr( Mpy_32_32( sts[0]->hTcxEnc->tfm_mem_fx, sts[0]->hTcxEnc->tfm_mem_fx ), 1 ), L_shr( Mpy_32_32( sts[1]->hTcxEnc->tfm_mem_fx, sts[1]->hTcxEnc->tfm_mem_fx ), 1 ) ), &tmp_e ); /* RMS Q31-tmp_e*/
sts[0]->hTcxEnc->tfm_mem_fx = sts[1]->hTcxEnc->tfm_mem_fx = L_shl( L_tmp, tmp_e ); /* Q31 */
move32();
move32();
- sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = extract_l( L_shr( L_add( sts[0]->hTcxEnc->tcxltp_norm_corr_past, sts[1]->hTcxEnc->tcxltp_norm_corr_past ), 1 ) );
+ sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = extract_l( L_shr( L_add( sts[0]->hTcxEnc->tcxltp_norm_corr_past, sts[1]->hTcxEnc->tcxltp_norm_corr_past ), 1 ) ); /* Q15 */
move16();
move16();
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -229,21 +230,11 @@ void stereo_mdct_core_enc_fx(
EQ_16( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ) ||
EQ_16( add( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ), extract_l( 5 ) ) ) ) /* disable syncing for stereo switching or large diff in last frame overlap */
{
- sync_tcx_mode( sts );
+ sync_tcx_mode_fx( sts );
}
IF( hCPE->hCoreCoder[0]->igf )
{
-
-#ifdef DEBUGGING
- int16_t orig_mdct_stereo_mode_cmdl = hCPE->hStereoMdct->mdct_stereo_mode_cmdl;
- hCPE->hStereoMdct->mdct_stereo_mode_cmdl = SMDCT_MS_DECISION;
-#endif
initMdctStereoEncData_fx( hCPE->hStereoMdct, STEREO_FORMAT, IVAS_CPE_MDCT, hCPE->element_brate, hCPE->hCoreCoder[0]->bwidth, hCPE->hCoreCoder[0]->igf, hCPE->hCoreCoder[0]->hIGFEnc->igfData.igfInfo.grid, 0 );
-
-#ifdef DEBUGGING
- hCPE->hStereoMdct->mdct_stereo_mode_cmdl = orig_mdct_stereo_mode_cmdl;
-#endif
-
stereo_mdct_init_igf_start_band_fx( &( hCPE->hStereoMdct->stbParamsTCX20 ), 16384 /* 1.0f in Q14 */, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate );
stereo_mdct_init_igf_start_band_fx( &( hCPE->hStereoMdct->stbParamsTCX10 ), 8192 /* 0.5f in Q14 */, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate );
stereo_mdct_init_igf_start_band_fx( &( hCPE->hStereoMdct->stbParamsTCX20afterACELP ), 20480 /* 1.25f in Q14 */, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate );
@@ -280,8 +271,8 @@ void stereo_mdct_core_enc_fx(
sts[ch]->hTcxEnc->tns_ms_flag[1] = 0;
move16();
- Scale_sig( sts[ch]->input_fx, (Word16) ( sts[ch]->input_Fs / 50 ) + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), negate( sts[ch]->q_inp ) );
- Scale_sig( sts[ch]->old_input_signal_fx, (Word16) ( sts[ch]->input_Fs / 50 ), negate( sts[ch]->q_old_inp ) );
+ Scale_sig( sts[ch]->input_fx, add( extract_l( Mpy_32_32( sts[ch]->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( sts[ch]->q_inp ) ); /* Q0 */
+ Scale_sig( sts[ch]->old_input_signal_fx, extract_l( Mpy_32_32( sts[ch]->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), negate( sts[ch]->q_old_inp ) ); /* Q0 */
sts[ch]->q_old_inp = 0;
move16();
sts[ch]->q_inp = 0;
@@ -313,8 +304,8 @@ void stereo_mdct_core_enc_fx(
IF( EQ_16( nSubframes, NB_DIV ) )
{
Word16 max_e = s_max( orig_spectrum_e[i][0], orig_spectrum_e[i][1] );
- Scale_sig32( orig_spectrum_fx[i][0], N_TCX10_MAX, sub( orig_spectrum_e[i][0], max_e ) );
- Scale_sig32( orig_spectrum_fx[i][1], N_TCX10_MAX, sub( orig_spectrum_e[i][1], max_e ) );
+ Scale_sig32( orig_spectrum_fx[i][0], N_TCX10_MAX, sub( orig_spectrum_e[i][0], max_e ) ); /* Q31-max_e */
+ Scale_sig32( orig_spectrum_fx[i][1], N_TCX10_MAX, sub( orig_spectrum_e[i][1], max_e ) ); /* Q31-max_e */
p_orig_spectrum_e[i] = max_e;
move16();
}
@@ -338,19 +329,19 @@ void stereo_mdct_core_enc_fx(
FOR( n = 0; n < nSubframes; n++ )
{
- st->side_bits_frame_channel = add( st->side_bits_frame_channel, NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL );
+ st->side_bits_frame_channel = add( st->side_bits_frame_channel, NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ); /* Q0 */
move16();
}
}
- sts[0]->side_bits_frame_channel = add( sts[0]->side_bits_frame_channel, SMDCT_NBBITS_SPLIT_RATIO );
+ sts[0]->side_bits_frame_channel = add( sts[0]->side_bits_frame_channel, SMDCT_NBBITS_SPLIT_RATIO ); /* Q0 */
move16();
/*--------------------------------------------------------------*
* Stereo Processing
*---------------------------------------------------------------*/
-
- if ( !hStereoMdct->isSBAStereoMode )
+ test();
+ IF( !hStereoMdct->isSBAStereoMode )
{
/* Common q for mdst_spectrum and spectrum */
Word16 k;
@@ -375,13 +366,13 @@ void stereo_mdct_core_enc_fx(
n_sb = 1;
move16();
}
- length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb );
+ length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */
FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
{
- Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[k], length, sub( q_spec, sub( Q31, sts[ch]->hTcxEnc->spectrum_e[k] ) ) );
+ Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[k], length, sub( q_spec, sub( Q31, sts[ch]->hTcxEnc->spectrum_e[k] ) ) ); /* q_spec */
sts[ch]->hTcxEnc->spectrum_e[k] = sub( Q31, q_spec );
- Scale_sig32( mdst_spectrum_fx[ch][k], length, sub( q_spec, sub( Q31, mdst_spectrum_e[ch][k] ) ) );
+ Scale_sig32( mdst_spectrum_fx[ch][k], length, sub( q_spec, sub( Q31, mdst_spectrum_e[ch][k] ) ) ); /* q_spec */
mdst_spectrum_e[ch][k] = sub( Q31, q_spec );
}
}
@@ -398,7 +389,7 @@ void stereo_mdct_core_enc_fx(
IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
{
nSubframes = 1;
- L_subframeTCX = sts[ch]->hTcxEnc->L_frameTCX;
+ L_subframeTCX = sts[ch]->hTcxEnc->L_frameTCX; /* Q0 */
move16();
move16();
}
@@ -406,13 +397,13 @@ void stereo_mdct_core_enc_fx(
{
nSubframes = NB_DIV;
move16();
- L_subframeTCX = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 );
+ L_subframeTCX = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); /* Q0 */
}
/* in MCT only relevant for bitrate switching from non-MCT bitrates */
IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) )
{
- L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) );
+ L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) ); /* Q0 */
}
FOR( n = 0; n < nSubframes; n++ )
@@ -424,18 +415,18 @@ void stereo_mdct_core_enc_fx(
/* power spectrum: MDCT^2 + MDST^2 */
FOR( i = 0; i < L_subframeTCX; i++ )
{
- W_tmp = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] );
+ W_tmp = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); /* 2*q_spec+1 */
tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
- W_tmp = W_mac_32_32( W_mult_32_32( inv_mdst_spectrum_fx[ch][n][i], inv_mdst_spectrum_fx[ch][n][i] ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] );
+ W_tmp = W_mac_32_32( W_mult_32_32( inv_mdst_spectrum_fx[ch][n][i], inv_mdst_spectrum_fx[ch][n][i] ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); /* 2*q_spec+1 */
tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
@@ -446,62 +437,62 @@ void stereo_mdct_core_enc_fx(
IF( NE_16( hStereoMdct->mdct_stereo_mode[n], SMDCT_DUAL_MONO ) )
{
/* power spectrum: MDCT^2 + MDST^2 */
- W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] );
+ W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] ); /* 2*q_spec+1 */
tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_psi[n][0] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
FOR( i = 1; i < L_subframeTCX - 1; i++ )
{
- Word32 mdst_fx = L_sub( inv_spectrum_fx[ch][n][i + 1], inv_spectrum_fx[ch][n][i - 1] ); /* An MDST estimate */
+ Word32 mdst_fx = L_sub( inv_spectrum_fx[ch][n][i + 1], inv_spectrum_fx[ch][n][i - 1] ); /* An MDST estimate q_spec*/
- W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] );
+ W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); /* 2*q_spec+1 */
tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
}
- W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][L_subframeTCX - 1], inv_spectrum_fx[ch][n][L_subframeTCX - 1] );
+ W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][L_subframeTCX - 1], inv_spectrum_fx[ch][n][L_subframeTCX - 1] ); /* 2*q_spec+1 */
tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_psi[n][L_subframeTCX - 1] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
}
/* power spectrum: MDCT^2 + MDST^2 */
- W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][0], sts[ch]->hTcxEnc->spectrum_fx[n][0] );
+ W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][0], sts[ch]->hTcxEnc->spectrum_fx[n][0] ); /* 2*q_spec+1 */
tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][n * L_subframeTCX] = W_extract_h( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpec_fx[ch][n * L_subframeTCX] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_powSpec[n * L_subframeTCX] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
FOR( i = 1; i < L_subframeTCX - 1; i++ )
{
- Word32 mdst_fx = L_sub( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], sts[ch]->hTcxEnc->spectrum_fx[n][i - 1] ); /* An MDST estimate */
+ Word32 mdst_fx = L_sub( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], sts[ch]->hTcxEnc->spectrum_fx[n][i - 1] ); /* An MDST estimate q_spec*/
- W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] );
+ W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); /* 2*q_spec+1 */
tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
}
- W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1] );
+ W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1] ); /* 2*q_spec+1 */
tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpec_fx[ch][( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_powSpec[( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
@@ -532,8 +523,8 @@ void stereo_mdct_core_enc_fx(
{
FOR( i = 0; i < L_subframeTCX; i++ )
{
- powerSpecMsInv_fx[ch][n][i] = L_shr( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powSpec[ch] ) );
- powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) );
+ powerSpecMsInv_fx[ch][n][i] = L_shr( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powSpec[ch] ) ); /* q_powSpec */
+ powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) ); /* q_powSpec */
move32();
move32();
}
@@ -555,11 +546,11 @@ void stereo_mdct_core_enc_fx(
nSubframes = NB_DIV;
move16();
}
- L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
IF( st->last_core == ACELP_CORE )
{
- L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) );
+ L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) ); /* Q0 */
}
test();
test();
@@ -574,7 +565,7 @@ void stereo_mdct_core_enc_fx(
NE_32( imult3216( st->last_sr_core, st->L_frame ), imult3216( st->sr_core, st->L_frame_past ) ) || NE_16( st->last_core, TCX_20_CORE ), st->hTcxEnc->memQuantZeros, L_subframeTCX );
}
- st->hTcxEnc->measuredBwRatio = ONE_IN_Q14; /* No bandwidth limit for the noise filling */
+ st->hTcxEnc->measuredBwRatio = ONE_IN_Q14; /* No bandwidth limit for the noise filling Q14*/
move16();
}
@@ -596,7 +587,7 @@ void stereo_mdct_core_enc_fx(
nSubframes = 1;
move16();
}
- L_subframeTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
FOR( n = 0; n < nSubframes; n++ )
{
test();
@@ -619,18 +610,18 @@ void stereo_mdct_core_enc_fx(
n_sb = 1;
move16();
}
- length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb );
+ length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */
IF( GT_16( q_spec, q_powSpec[ch] ) )
{
- Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], length, sub( q_powSpec[ch], q_spec ) );
- Scale_sig32( inv_spectrum_fx[ch][n], length, sub( q_powSpec[ch], q_spec ) );
+ Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], length, sub( q_powSpec[ch], q_spec ) ); /* q_powSpec */
+ Scale_sig32( inv_spectrum_fx[ch][n], length, sub( q_powSpec[ch], q_spec ) ); /* q_powSpec */
sts[ch]->hTcxEnc->spectrum_e[n] = sub( Q31, q_powSpec[ch] );
move16();
}
ELSE
{
- Scale_sig32( &p_powerSpec_fx[ch][0], L_subframeTCX, sub( q_spec, q_powSpec[ch] ) );
- Scale_sig32( powerSpecMsInv_fx[ch][0], L_subframeTCX, sub( q_spec, q_powSpec[ch] ) );
+ Scale_sig32( &p_powerSpec_fx[ch][0], L_subframeTCX, sub( q_spec, q_powSpec[ch] ) ); /* q_spec */
+ Scale_sig32( powerSpecMsInv_fx[ch][0], L_subframeTCX, sub( q_spec, q_powSpec[ch] ) ); /* q_spec */
}
}
hIGFEnc[0]->spec_be_igf_e = p_orig_spectrum_e[0];
@@ -638,7 +629,7 @@ void stereo_mdct_core_enc_fx(
hIGFEnc[1]->spec_be_igf_e = p_orig_spectrum_e[1];
move16();
ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask,
- orig_spectrum_fx,
+ orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ),
p_powerSpec_fx, powerSpecMsInv_fx, inv_spectrum_fx, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate );
}
ELSE
@@ -651,17 +642,19 @@ void stereo_mdct_core_enc_fx(
{
st->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot;
}
- L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
Word16 q_spectrum;
q_spectrum = sub( Q31, p_orig_spectrum_e[ch] );
IF( st->hIGFEnc )
{
q_spectrum = s_min( q_spectrum, sub( Q31, st->hIGFEnc->spec_be_igf_e ) );
}
- Scale_sig32( orig_spectrum_fx[ch][n], N_TCX10_MAX, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) );
+ Scale_sig32( orig_spectrum_fx[ch][n], N_TCX10_MAX, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */
q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powSpec[ch], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
+ set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX );
+
+ ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
}
}
}
@@ -691,16 +684,18 @@ void stereo_mdct_core_enc_fx(
FOR( n = 0; n < nSubframes; n++ )
{
Word16 q_spectrum;
- L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
q_spectrum = sub( Q31, p_orig_spectrum_e[ch] );
IF( st->hIGFEnc )
{
q_spectrum = s_min( q_spectrum, sub( Q31, st->hIGFEnc->spec_be_igf_e ) );
}
- Scale_sig32( orig_spectrum_fx[ch][n], N_TCX10_MAX, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) );
+ Scale_sig32( orig_spectrum_fx[ch][n], N_TCX10_MAX, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */
q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powSpec[ch], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
+ set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX );
+
+ ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
}
}
}
@@ -719,7 +714,7 @@ void stereo_mdct_core_enc_fx(
move16();
IF( !hStereoMdct->isSBAStereoMode )
{
- stereo_bits = write_stereo_to_bitstream( hStereoMdct, sts, ms_mask, 0, hBstr );
+ stereo_bits = write_stereo_to_bitstream_fx( hStereoMdct, sts, ms_mask, 0, hBstr ); /* Q0 */
}
ELSE
{
@@ -741,11 +736,11 @@ void stereo_mdct_core_enc_fx(
n_sb = 1;
move16();
}
- L_subframeTCX = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb );
+ L_subframeTCX = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */
FOR( n = 0; n <= ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ) - 1; n++ )
{
q_com = L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[n], L_subframeTCX );
- Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], L_subframeTCX, q_com );
+ Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], L_subframeTCX, q_com ); /* Q31 - sts[ch]->hTcxEnc->spectrum_e + q_com */
sts[ch]->hTcxEnc->spectrum_e[n] = sub( sts[ch]->hTcxEnc->spectrum_e[n], q_com );
}
}
@@ -770,7 +765,7 @@ void stereo_mdct_core_enc_fx(
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- sts[ch]->total_brate = imult3216( L_deposit_l( add( sts[ch]->bits_frame_channel, sts[ch]->side_bits_frame_channel ) ), FRAMES_PER_SEC );
+ sts[ch]->total_brate = imult3216( L_deposit_l( add( sts[ch]->bits_frame_channel, sts[ch]->side_bits_frame_channel ) ), FRAMES_PER_SEC ); /* Q0 */
move32();
}
stereo_bits = add( stereo_bits, SMDCT_NBBITS_SPLIT_RATIO );
diff --git a/lib_enc/ivas_stereo_mdct_igf_enc.c b/lib_enc/ivas_stereo_mdct_igf_enc.c
index c200a748caf06abb39b9164a83d085cd4ea0f4c8..190255fd9be4f9e4b839cfdf2dc91f3f421be480 100644
--- a/lib_enc/ivas_stereo_mdct_igf_enc.c
+++ b/lib_enc/ivas_stereo_mdct_igf_enc.c
@@ -64,10 +64,10 @@ static Word16 calcCoh_fx( // Q15
const Word32 *sig1_fx, // Q( q_sig )
const Word32 *sig2_fx, // Q( q_sig )
const Word16 q_sig,
- const Word16 nSamples,
- Word32 *corr,
+ const Word16 nSamples, /* Q0 */
+ Word32 *corr, /* Q31-corr_e */
Word16 *corr_e,
- Word16 *predCoeff,
+ Word16 *predCoeff, /* Q31-predCoeff_e */
Word16 *predCoeff_e )
{
Word32 ener1_fx, ener2_fx, cEner_fx, cc_fx;
@@ -82,13 +82,13 @@ static Word16 calcCoh_fx( // Q15
move16();
q_cc = q_ener1;
move16();
- ener1_fx = dotp_fixed_o( sig1_fx, sig1_fx, nSamples, gB, &q_ener1 );
- ener2_fx = dotp_fixed_o( sig2_fx, sig2_fx, nSamples, gB, &q_ener2 );
- cEner_fx = Mpy_32_32( ener1_fx, ener2_fx );
+ ener1_fx = dotp_fixed_o( sig1_fx, sig1_fx, nSamples, gB, &q_ener1 ); /* q_ener1 */
+ ener2_fx = dotp_fixed_o( sig2_fx, sig2_fx, nSamples, gB, &q_ener2 ); /* q_ener2 */
+ cEner_fx = Mpy_32_32( ener1_fx, ener2_fx ); /* q_ener1+q_ener2-31 */
q_cEner = sub( 62, add( q_ener1, q_ener2 ) );
- cEner_fx = Sqrt32( cEner_fx, &q_cEner );
+ cEner_fx = Sqrt32( cEner_fx, &q_cEner ); /* Q31-q_cEner */
q_cEner = sub( Q31, q_cEner );
- cc_fx = dotp_fixed_o( sig1_fx, sig2_fx, nSamples, gB, &q_cc );
+ cc_fx = dotp_fixed_o( sig1_fx, sig2_fx, nSamples, gB, &q_cc ); /* q_cc */
IF( corr != NULL )
{
@@ -100,7 +100,7 @@ static Word16 calcCoh_fx( // Q15
IF( cEner_fx > 0 )
{
- coh_fx = BASOP_Util_Divide3232_Scale( cc_fx, cEner_fx, &coh_e );
+ coh_fx = BASOP_Util_Divide3232_Scale( cc_fx, cEner_fx, &coh_e ); /* Q15-coh_e */
coh_e = add( coh_e, sub( q_cEner, q_cc ) );
coh_fx = shl_sat( coh_fx, coh_e ); // Q15
}
@@ -111,7 +111,7 @@ static Word16 calcCoh_fx( // Q15
move32();
IF( ener1_fx > 0 )
{
- *predCoeff = BASOP_Util_Divide3232_Scale( cc_fx, ener1_fx, predCoeff_e );
+ *predCoeff = BASOP_Util_Divide3232_Scale( cc_fx, ener1_fx, predCoeff_e ); /* Q31-predCoeff_e */
move32();
*predCoeff_e = add( *predCoeff_e, sub( q_ener1, q_cc ) );
move16();
@@ -131,12 +131,12 @@ static Word16 calcCoh_fx( // Q15
static void IGF_MsStereoDecision_fx(
STEREO_MDCT_BAND_PARAMETERS *sfbParam,
H_IGF_GRID hGrid,
- const Word32 *specL_fx,
- const Word32 *specR_fx,
+ const Word32 *specL_fx, /* q_spec */
+ const Word32 *specR_fx, /* q_spec */
Word16 q_spec,
- Word16 *igfStereoMode, /* output*/
- Word16 *msMask, /* output*/
- const Word16 mdct_stereo_mode )
+ Word16 *igfStereoMode, /* output Q0*/
+ Word16 *msMask, /* output Q0*/
+ const Word16 mdct_stereo_mode /* Q0 */ )
{
Word16 sfb;
Word16 msMaskTrueSomewhere, msMaskFalseSomewhere;
@@ -150,18 +150,18 @@ static void IGF_MsStereoDecision_fx(
if ( EQ_16( mdct_stereo_mode, SMDCT_MS_FULL ) )
{
- thresh = 13762; /* lower threshold if core is already MS */
+ thresh = 13762; /* lower threshold if core is already MS TARGET_COH_THRESHOLD_FX*(0.7 in Q15)*/
move16();
}
FOR( tile_idx = 0; tile_idx < hGrid->nTiles; tile_idx++ )
{
- strt_cpy = hGrid->sbWrap[tile_idx];
+ strt_cpy = hGrid->sbWrap[tile_idx]; /* Q0 */
move16();
FOR( sfb = hGrid->sfbWrap[tile_idx]; sfb < hGrid->sfbWrap[tile_idx + 1]; sfb++ )
{
- Word16 width = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] );
+ Word16 width = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] ); /* Q0 */
Word32 cc_src_fx, cc_target_fx;
Word16 cc_src_e, cc_target_e;
Word16 pc_target_fx, pc_src_fx;
@@ -177,10 +177,10 @@ static void IGF_MsStereoDecision_fx(
Word16 coh_src = calcCoh_fx( &specL_fx[strt_cpy], &specR_fx[strt_cpy], q_spec, width, &cc_src_fx, &cc_src_e, &pc_src_fx, &pc_src_e );
Word16 coh_target = calcCoh_fx( &specL_fx[hGrid->swb_offset[sfb]], &specR_fx[hGrid->swb_offset[sfb]], q_spec, width, &cc_target_fx, &cc_target_e, &pc_target_fx, &pc_target_e );
- tmp1_e = BASOP_Util_Add_MantExp( pc_target_fx, pc_target_e, negate( pc_src_fx ), pc_src_e, &tmp1 );
- tmp2_e = BASOP_Util_Add_MantExp( pc_target_fx, pc_target_e, -16384, 1, &tmp2 );
+ tmp1_e = BASOP_Util_Add_MantExp( pc_target_fx, pc_target_e, negate( pc_src_fx ), pc_src_e, &tmp1 ); /* Q15-tmp1_e */
+ tmp2_e = BASOP_Util_Add_MantExp( pc_target_fx, pc_target_e, -16384, 1, &tmp2 ); /* Q15-tmp2_e */
- strt_cpy = add( strt_cpy, width );
+ strt_cpy = add( strt_cpy, width ); /* Q0 */
IF( GT_16( abs_s( coh_target ), thresh ) )
{
/* target is very coherent */
@@ -236,14 +236,14 @@ static void IGF_MsStereoDecision_fx(
case IGF_PATCH_LR:
msMask[sfb] = 0;
move16();
- numMsMaskFalse = add( numMsMaskFalse, 1 );
+ numMsMaskFalse = add( numMsMaskFalse, 1 ); /* Q0 */
msMaskFalseSomewhere = 1;
move16();
break;
case IGF_PATCH_MS:
msMask[sfb] = 1;
move16();
- numMsMaskTrue = add( numMsMaskTrue, 1 );
+ numMsMaskTrue = add( numMsMaskTrue, 1 ); /* Q0 */
msMaskTrueSomewhere = 1;
move16();
break;
@@ -302,14 +302,14 @@ static void IGF_MsStereoDecision_fx(
void IGFEncStereoEncoder_fx(
STEREO_MDCT_BAND_PARAMETERS *sfbParam, /* i/o: sfb parameters for the right channel */
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : IGF handle */
- const Word32 *mdctSpectrumL_fx, /* i : left spectrum */
- const Word32 *mdctSpectrumR_fx, /* i : right spectrum */
+ const Word32 *mdctSpectrumL_fx, /* i : left spectrum q_mdctSpectrum*/
+ const Word32 *mdctSpectrumR_fx, /* i : right spectrum q_mdctSpectrum*/
Word16 q_mdctSpectrum,
- Word16 *msMask, /* i/o: MS mask */
- Word16 *igfStereoMode, /* o : IGF stereo mode */
- const Word16 mdct_stereo_mode, /* i : MDCT stereo mode */
- const Word16 isTCX20, /* i : flag for indicating TCX20 */
- const Word16 isTransition /* i : flag for transtition */
+ Word16 *msMask, /* i/o: MS mask Q0*/
+ Word16 *igfStereoMode, /* o : IGF stereo mode Q0*/
+ const Word16 mdct_stereo_mode, /* i : MDCT stereo mode Q0*/
+ const Word16 isTCX20, /* i : flag for indicating TCX20 Q0*/
+ const Word16 isTransition /* i : flag for transtition Q0*/
)
{
Word16 igfGridIdx;
diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c
index 9148b89e2ae6696014a8f8812ed5d5323f820041..4c73ba2e72f9b30f911376a6b6f285dd242152f5 100644
--- a/lib_enc/ivas_stereo_mdct_stereo_enc.c
+++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c
@@ -77,7 +77,7 @@ static void MsStereoDecision_fx( STEREO_MDCT_BAND_PARAMETERS *sfbParam, Word32 *
static void dft_ana_init_fx(
DFT_ANA_HANDLE hDft_ana, /*i : DFT analysis handle */
- const Word32 input_Fs /*i : Input sampling frequency */
+ const Word32 input_Fs /*i : Input sampling frequency Q0*/
)
{
hDft_ana->N = extract_l( Mpy_32_16_1( input_Fs, 656 /* STEREO_DFT_HOP_MAX_ENC / 48000 in Q15 */ ) );
@@ -89,29 +89,29 @@ static void dft_ana_init_fx(
hDft_ana->dft_zp = extract_l( Mpy_32_16_1( input_Fs, 185 /* STEREO_DFT_ZP_MAX_ENC / 48000 in Q15 */ ) );
move16();
- hDft_ana->dft_trigo_32k_fx = dft_trigo_32k_fx;
+ hDft_ana->dft_trigo_32k_fx = dft_trigo_32k_fx; /* Q15 */
IF( EQ_32( input_Fs, 16000 ) )
{
- hDft_ana->dft_trigo_fx = dft_trigo_32k_fx;
+ hDft_ana->dft_trigo_fx = dft_trigo_32k_fx; /* Q15 */
hDft_ana->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP;
move16();
- hDft_ana->win_ana_fx = win_ana_16k_fx;
+ hDft_ana->win_ana_fx = win_ana_16k_fx; /* Q15 */
}
ELSE IF( EQ_32( input_Fs, 32000 ) )
{
- hDft_ana->dft_trigo_fx = dft_trigo_32k_fx;
+ hDft_ana->dft_trigo_fx = dft_trigo_32k_fx; /* Q15 */
hDft_ana->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_32k_STEP;
move16();
- hDft_ana->win_ana_fx = win_ana_32k_fx;
+ hDft_ana->win_ana_fx = win_ana_32k_fx; /* Q15 */
}
ELSE
{
assert( input_Fs == 48000 );
- hDft_ana->dft_trigo_fx = dft_trigo_48k_fx;
+ hDft_ana->dft_trigo_fx = dft_trigo_48k_fx; /* Q15 */
hDft_ana->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_48k_STEP;
move16();
- hDft_ana->win_ana_fx = win_ana_48k_fx;
+ hDft_ana->win_ana_fx = win_ana_48k_fx; /* Q15 */
}
return;
@@ -139,7 +139,7 @@ static void write_itd_data_fx(
IF( hItd->itd_fx[k_offset] != 0 )
{
- itd = hItd->itd_index[k_offset];
+ itd = hItd->itd_index[k_offset]; /* Q0 */
IF( GT_16( itd, 255 ) )
{
itd = sub( itd, 256 );
@@ -184,14 +184,14 @@ static void write_itd_data_fx(
void stereo_coder_tcx_fx(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
Encoder_State **sts, /* i/o: encoder state structure */
- Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV],
/* i/o: MDST spectrum */ // Q( q_spec ) (same as spectrum buffer in hTcxEnc)
Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV],
/* i/o: inverse spectrum */ // Q( q_spec ) (same as spectrum buffer in hTcxEnc)
Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV],
/* i/o: inverse MDST spectrum */ // Q( q_spec ) (same as spectrum buffer in hTcxEnc)
- const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */
+ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
Word16 q_spec )
{
STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL;
@@ -208,7 +208,7 @@ void stereo_coder_tcx_fx(
set16_fx( nAvailBitsMS, 0, NB_DIV );
nSubframes = ( sts[0]->core == TCX_20_CORE && sts[1]->core == TCX_20_CORE ) ? 1 : NB_DIV;
- L_frameTCX = sts[0]->hTcxEnc->L_frameTCX / nSubframes;
+ L_frameTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes );
set16_fx( &ms_mask[0][0], 0, MAX_SFB );
set16_fx( &ms_mask[1][0], 0, MAX_SFB );
@@ -224,7 +224,7 @@ void stereo_coder_tcx_fx(
hStereoMdct->global_ild[k] = s_max( 1, s_min( SMDCT_ILD_RANGE - 1, round_fx( L_mult( SMDCT_ILD_RANGE, nonQNrgRatio_fx[k] ) ) ) );
move16();
- nrgRatio_fx[k] = L_deposit_h( BASOP_Util_Divide1616_Scale( sub( SMDCT_ILD_RANGE, hStereoMdct->global_ild[k] ), hStereoMdct->global_ild[k], &nrgRatio_e[k] ) );
+ nrgRatio_fx[k] = L_deposit_h( BASOP_Util_Divide1616_Scale( sub( SMDCT_ILD_RANGE, hStereoMdct->global_ild[k] ), hStereoMdct->global_ild[k], &nrgRatio_e[k] ) ); /* Q31-nrgRatio_e[k] */
move32();
/*nonQNrgRatio[k] = max( 0.5f / SMDCT_ILD_RANGE, min( ( SMDCT_ILD_RANGE - 0.5f ) / SMDCT_ILD_RANGE, nonQNrgRatio[k] ) );
nonQNrgRatio[k] = 1.0f / nonQNrgRatio[k] - 1.0f;*/
@@ -233,11 +233,11 @@ void stereo_coder_tcx_fx(
}
ELSE
{
- nonQNrgRatio_fx[0] = nonQNrgRatio_fx[1] = GetChannelEnergyRatio_fx( sts, 0, nSubframes - 1, 1 );
+ nonQNrgRatio_fx[0] = nonQNrgRatio_fx[1] = GetChannelEnergyRatio_fx( sts, 0, nSubframes - 1, 1 ); /* Q15 */
move16();
hStereoMdct->global_ild[0] = s_max( 1, s_min( SMDCT_ILD_RANGE - 1, round_fx( L_mult( SMDCT_ILD_RANGE, nonQNrgRatio_fx[0] ) ) ) );
move16();
- nrgRatio_fx[0] = nrgRatio_fx[1] = L_deposit_h( BASOP_Util_Divide1616_Scale( sub( SMDCT_ILD_RANGE, hStereoMdct->global_ild[0] ), hStereoMdct->global_ild[0], &nrgRatio_e[0] ) ); /* nrgRatio = nrg[1]/nrg[0] */
+ nrgRatio_fx[0] = nrgRatio_fx[1] = L_deposit_h( BASOP_Util_Divide1616_Scale( sub( SMDCT_ILD_RANGE, hStereoMdct->global_ild[0] ), hStereoMdct->global_ild[0], &nrgRatio_e[0] ) ); /* nrgRatio = nrg[1]/nrg[0] (Q31-nrgRatio_e[0])*/
move32();
nrgRatio_e[1] = nrgRatio_e[0];
move16();
@@ -250,24 +250,24 @@ void stereo_coder_tcx_fx(
{
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( nrgRatio_fx[k], nrgRatio_e[k], ONE_IN_Q27, 4 ), 1 ) && LT_16( k, ( EQ_16( sts[1]->core, TCX_20_CORE ) ? 1 : NB_DIV ) ) )
{
- L_frameTCX = add( sts[1]->hTcxEnc->L_frameTCX, ( ( sts[1]->last_core == 0 ) ? shr( sts[1]->hTcxEnc->L_frameTCX, 2 ) : 0 ) );
- L_frameTCX = idiv1616( L_frameTCX, ( sts[1]->core == TCX_20_CORE ) ? 1 : NB_DIV );
+ L_frameTCX = add( sts[1]->hTcxEnc->L_frameTCX, ( ( sts[1]->last_core == 0 ) ? shr( sts[1]->hTcxEnc->L_frameTCX, 2 ) : 0 ) ); /* Q0 */
+ L_frameTCX = idiv1616( L_frameTCX, ( sts[1]->core == TCX_20_CORE ) ? 1 : NB_DIV ); /* Q0 */
e_tmp = nrgRatio_e[k];
- tmp = Inv16( extract_h( nrgRatio_fx[k] ), &e_tmp );
- tmp = shl( tmp, e_tmp );
+ tmp = Inv16( extract_h( nrgRatio_fx[k] ), &e_tmp ); /* Q15-e_tmp */
+ tmp = shl( tmp, e_tmp ); /* Q15 */
- v_multc_fixed_16( sts[1]->hTcxEnc->spectrum_fx[k], tmp, sts[1]->hTcxEnc->spectrum_fx[k], L_frameTCX );
- v_multc_fixed_16( mdst_spectrum_fx[1][k], tmp, mdst_spectrum_fx[1][k], L_frameTCX );
+ v_multc_fixed_16( sts[1]->hTcxEnc->spectrum_fx[k], tmp, sts[1]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* Q31-spectrum_e[k] */
+ v_multc_fixed_16( mdst_spectrum_fx[1][k], tmp, mdst_spectrum_fx[1][k], L_frameTCX ); /* q_spec */
}
ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( nrgRatio_fx[k], nrgRatio_e[k], ONE_IN_Q27, 4 ), -1 ) && LT_16( k, EQ_16( sts[0]->core, TCX_20_CORE ) ? 1 : NB_DIV ) )
{
- L_frameTCX = add( sts[0]->hTcxEnc->L_frameTCX, EQ_16( sts[0]->last_core, 0 ) ? shr( sts[0]->hTcxEnc->L_frameTCX, 2 ) : 0 );
- L_frameTCX = idiv1616( L_frameTCX, ( sts[0]->core == TCX_20_CORE ) ? 1 : NB_DIV );
+ L_frameTCX = add( sts[0]->hTcxEnc->L_frameTCX, EQ_16( sts[0]->last_core, 0 ) ? shr( sts[0]->hTcxEnc->L_frameTCX, 2 ) : 0 ); /* Q0 */
+ L_frameTCX = idiv1616( L_frameTCX, ( sts[0]->core == TCX_20_CORE ) ? 1 : NB_DIV ); /* Q0 */
/* This operation is resulting in some high MLDs in fixed point. */
- v_multc_fixed_16( sts[0]->hTcxEnc->spectrum_fx[k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), sts[0]->hTcxEnc->spectrum_fx[k], L_frameTCX );
- v_multc_fixed_16( mdst_spectrum_fx[0][k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), mdst_spectrum_fx[0][k], L_frameTCX );
+ v_multc_fixed_16( sts[0]->hTcxEnc->spectrum_fx[k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), sts[0]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* Q31-spectrum_e[k] */
+ v_multc_fixed_16( mdst_spectrum_fx[0][k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), mdst_spectrum_fx[0][k], L_frameTCX ); /* q_spec */
}
}
}
@@ -352,9 +352,9 @@ void stereo_coder_tcx_fx(
FOR( sfb--; sfb < sfbConf->nBandsStereoCore; sfb++ ) /* start one SFB early for the fade-in */
{
- const Word16 startLine = sfbConf->sfbOffset[sfb];
+ const Word16 startLine = sfbConf->sfbOffset[sfb]; /* Q0 */
move16();
- const Word16 endLine = sfbConf->sfbOffset[sfb + 1];
+ const Word16 endLine = sfbConf->sfbOffset[sfb + 1]; /* Q0 */
move16();
const Word16 sfbWidth = sub( endLine, startLine );
@@ -362,9 +362,9 @@ void stereo_coder_tcx_fx(
move16();
move16();
- nrgRatio_fx[0] = sum2_32_fx( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, &nrgRatio_e[0] );
+ nrgRatio_fx[0] = sum2_32_fx( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
move32();
- nrgRatio_fx[1] = sum2_32_fx( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, &nrgRatio_e[1] );
+ nrgRatio_fx[1] = sum2_32_fx( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
move32();
test();
@@ -373,29 +373,29 @@ void stereo_coder_tcx_fx(
Word32 tmp_fx;
Word16 tmp_e;
tmp_e = sub( Q31, q_spec );
- tmp_fx = sum2_32_fx( &mdst_spectrum_fx[0][k][startLine], sfbWidth, &tmp_e );
- nrgRatio_fx[0] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], tmp_fx, tmp_e, &nrgRatio_e[0] );
+ tmp_fx = sum2_32_fx( &mdst_spectrum_fx[0][k][startLine], sfbWidth, &tmp_e ); /* Q31-tmp_e */
+ nrgRatio_fx[0] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], tmp_fx, tmp_e, &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
tmp_e = sub( Q31, q_spec );
- tmp_fx = sum2_32_fx( &mdst_spectrum_fx[1][k][startLine], sfbWidth, &tmp_e );
- nrgRatio_fx[1] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[1], nrgRatio_e[1], tmp_fx, tmp_e, &nrgRatio_e[1] );
+ tmp_fx = sum2_32_fx( &mdst_spectrum_fx[1][k][startLine], sfbWidth, &tmp_e ); /* Q31-tmp_e */
+ nrgRatio_fx[1] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[1], nrgRatio_e[1], tmp_fx, tmp_e, &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
}
IF( ( nrgRatio_fx[0] > 0 ) && ( nrgRatio_fx[1] > 0 ) && BASOP_Util_Cmp_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], nrgRatio_fx[1], nrgRatio_e[1] ) )
{
Word16 fTemp_e, tmp_e;
- Word32 fTemp_fx = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], nrgRatio_fx[1], nrgRatio_e[1], &fTemp_e );
+ Word32 fTemp_fx = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], nrgRatio_fx[1], nrgRatio_e[1], &fTemp_e ); /* Q31-fTemp_e */
fTemp_e = sub( fTemp_e, 1 );
- nrgRatio_fx[0] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[0], &tmp_e );
+ nrgRatio_fx[0] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[0], &tmp_e ); /* Q31 - tmp_e - fTemp_e + nrgRatio_e[0] */
move32();
nrgRatio_e[0] = add( tmp_e, sub( fTemp_e, nrgRatio_e[0] ) );
move16();
- nrgRatio_fx[0] = Sqrt32( nrgRatio_fx[0], &nrgRatio_e[0] );
+ nrgRatio_fx[0] = Sqrt32( nrgRatio_fx[0], &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
move32();
- nrgRatio_fx[1] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[1], &tmp_e );
+ nrgRatio_fx[1] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[1], &tmp_e ); /* Q31 - tmp_e - fTemp_e + nrgRatio_e[1] */
move32();
nrgRatio_e[1] = add( tmp_e, sub( fTemp_e, nrgRatio_e[1] ) );
move16();
- nrgRatio_fx[1] = Sqrt32( nrgRatio_fx[1], &nrgRatio_e[1] );
+ nrgRatio_fx[1] = Sqrt32( nrgRatio_fx[1], &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
move32();
nrgRatio_fx[0] = L_max( ONE_IN_Q27, L_shl_sat( nrgRatio_fx[0], sub( nrgRatio_e[0], 2 ) ) ); // max( 0.25f, min( 4.f, nrgRatio[0] ) );
@@ -409,16 +409,16 @@ void stereo_coder_tcx_fx(
IF( ( LT_16( sfbWidth, 12 ) && LT_16( add( sfb, 1 ), sfbConf->nBandsStereoCore ) ) || GT_32( sts[0]->element_brate, IVAS_48k ) ) /* attenuate ILD alignment in the first SFB or at 64k */
{
- nrgRatio_fx[0] = BASOP_Util_fPow( nrgRatio_fx[0], nrgRatio_e[0], ONE_IN_Q29, 0, &nrgRatio_e[0] );
+ nrgRatio_fx[0] = BASOP_Util_fPow( nrgRatio_fx[0], nrgRatio_e[0], ONE_IN_Q29, 0, &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
move32();
- nrgRatio_fx[1] = BASOP_Util_fPow( nrgRatio_fx[1], nrgRatio_e[1], ONE_IN_Q29, 0, &nrgRatio_e[1] );
+ nrgRatio_fx[1] = BASOP_Util_fPow( nrgRatio_fx[1], nrgRatio_e[1], ONE_IN_Q29, 0, &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
move32();
}
ELSE
{
- nrgRatio_fx[0] = Sqrt32( nrgRatio_fx[0], &nrgRatio_e[0] );
+ nrgRatio_fx[0] = Sqrt32( nrgRatio_fx[0], &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
move32();
- nrgRatio_fx[1] = Sqrt32( nrgRatio_fx[1], &nrgRatio_e[1] );
+ nrgRatio_fx[1] = Sqrt32( nrgRatio_fx[1], &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
move32();
}
@@ -428,15 +428,15 @@ void stereo_coder_tcx_fx(
move32();
- v_multc_fixed( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth );
- v_multc_fixed( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth );
- scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
- scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ v_multc_fixed( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* q_spec+30-31 */
+ v_multc_fixed( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth ); /* q_spec+30-31 */
+ scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
- v_multc_fixed( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth );
- v_multc_fixed( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth );
- scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
- scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ v_multc_fixed( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* q_spec+30-31 */
+ v_multc_fixed( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth ); /* q_spec+30-31 */
+ scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
}
}
}
@@ -445,30 +445,30 @@ void stereo_coder_tcx_fx(
set16_fx( &ms_mask[k][0], 0, MAX_SFB );
IF( mct_on )
{
- nAvailBitsMS[k] = shl( sts[0]->bits_frame_channel, 1 );
+ nAvailBitsMS[k] = shl( sts[0]->bits_frame_channel, 1 ); /* Q0 */
move16();
}
ELSE
{
- nAvailBitsMS[k] = sts[0]->bits_frame_nominal;
+ nAvailBitsMS[k] = sts[0]->bits_frame_nominal; /* Q0 */
move16();
}
- nAvailBitsMS[k] = sub( nAvailBitsMS[k], add( sts[0]->side_bits_frame_channel, sts[1]->side_bits_frame_channel ) );
+ nAvailBitsMS[k] = sub( nAvailBitsMS[k], add( sts[0]->side_bits_frame_channel, sts[1]->side_bits_frame_channel ) ); /* Q0 */
move16();
IF( EQ_16( nSubframes, 2 ) )
{
- nAvailBitsMS[k] = sub( nAvailBitsMS[k], OFFSET_BITS_TCX10 );
+ nAvailBitsMS[k] = sub( nAvailBitsMS[k], OFFSET_BITS_TCX10 ); /* Q0 */
move16();
}
ELSE
{
- nAvailBitsMS[k] = sub( nAvailBitsMS[k], OFFSET_BITS_TCX20 );
+ nAvailBitsMS[k] = sub( nAvailBitsMS[k], OFFSET_BITS_TCX20 ); /* Q0 */
move16();
}
- nAvailBitsMS[k] = idiv1616( nAvailBitsMS[k], nSubframes );
+ nAvailBitsMS[k] = idiv1616( nAvailBitsMS[k], nSubframes ); /* Q0 */
move16();
MsStereoDecision_fx( sfbConf, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], inv_spectrum_fx[0][k], inv_spectrum_fx[1][k], q_spec, &hStereoMdct->mdct_stereo_mode[k], &ms_mask[k][0], nAvailBitsMS[k] );
@@ -512,21 +512,21 @@ void stereo_coder_tcx_fx(
FOR( k = 0; k < nSubframes; k++ )
{
sfbConf = EQ_16( sts[0]->core, TCX_20_CORE ) ? &hStereoMdct->stbParamsTCX20 : &hStereoMdct->stbParamsTCX10;
- ms_bands[k] = sum_s( ms_mask[k], sfbConf->nBandsStereoCore );
+ ms_bands[k] = sum_s( ms_mask[k], sfbConf->nBandsStereoCore ); /* Q0 */
move16();
- sw_uncorr[k] = sub( 32767, div_s( ms_bands[k], sfbConf->nBandsStereoCore ) );
+ sw_uncorr[k] = sub( 32767 /*Q15*/, div_s( ms_bands[k], sfbConf->nBandsStereoCore ) ); /* Q15 */
move16();
}
IF( EQ_16( sts[0]->core, TCX_20_CORE ) )
{
- sw_uncorr_mean = sw_uncorr[0];
+ sw_uncorr_mean = sw_uncorr[0]; /* Q15 */
move16();
}
ELSE
{
- sw_uncorr_mean = add( shr( sw_uncorr[0], 1 ), shr( sw_uncorr[1], 1 ) );
+ sw_uncorr_mean = add( shr( sw_uncorr[0], 1 ), shr( sw_uncorr[1], 1 ) ); /* Q15 */
}
- hStereoMdct->sw_uncorr = extract_l( GT_16( sw_uncorr_mean, 19661 ) );
+ hStereoMdct->sw_uncorr = extract_l( GT_16( sw_uncorr_mean, 19661 /*0.6 in Q15*/ ) );
move16();
}
@@ -543,13 +543,13 @@ void stereo_coder_tcx_fx(
void ms_processing_fx(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
Encoder_State **sts, /* i/o: Encoder state structure */
- Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const int16_t iSubframe, /* i : subframe number */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
+ const Word16 iSubframe, /* i : subframe number Q0*/
Word32 x_0_fx[],
/* i/o: spectrum 1 */ // Q( q_x )
Word32 x_1_fx[],
/* i/o: spectrum 1 */ // Q( q_x )
- Word16 maxSfb /* i : number of stereo frequency bands*/
+ Word16 maxSfb /* i : number of stereo frequency bands Q0*/
)
{
Word16 sfb;
@@ -565,7 +565,7 @@ void ms_processing_fx(
if ( EQ_16( maxSfb, -1 ) )
{
- maxSfb = sfbConf->sfbCnt;
+ maxSfb = sfbConf->sfbCnt; /* Q0 */
move16();
}
@@ -589,8 +589,8 @@ void ms_processing_fx(
void ms_inv_mask_processing_fx(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
Encoder_State **sts, /* i/o: Encoder state structure */
- Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const Word16 iSubframe, /* i : subframe number */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
+ const Word16 iSubframe, /* i : subframe number Q0*/
const Word32 x_0_fx[],
/* i : spectrum 1 */ // Q( q_x )
const Word32 x_1_fx[],
@@ -599,7 +599,7 @@ void ms_inv_mask_processing_fx(
/* o : inverse spectrum 1 */ // Q( q_x )
Word32 x_inv_1_fx[],
/* o : inverse spectrum 2 */ // Q( q_x )
- Word16 maxSfb /* i : number of stereo frequency bands*/
+ Word16 maxSfb /* i : number of stereo frequency bands Q0*/
)
{
Word16 sfb;
@@ -607,7 +607,7 @@ void ms_inv_mask_processing_fx(
Word16 nSubframes, L_subframeTCX;
nSubframes = ( sts[0]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV;
- L_subframeTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
sfbConf = ( sts[0]->core == TCX_20_CORE ) ? &hStereoMdct->stbParamsTCX20 : &hStereoMdct->stbParamsTCX10;
IF( EQ_16( sts[0]->last_core, ACELP_CORE ) )
@@ -618,14 +618,14 @@ void ms_inv_mask_processing_fx(
IF( EQ_16( maxSfb, -1 ) )
{
- maxSfb = sfbConf->sfbCnt;
+ maxSfb = sfbConf->sfbCnt; /* Q0 */
move16();
}
FOR( sfb = 0; sfb < maxSfb; sfb++ )
{
- Copy32( &x_0_fx[sfbConf->sfbOffset[sfb]], &x_inv_0_fx[sfbConf->sfbOffset[sfb]], sfbConf->sfbOffset[sfb + 1] - sfbConf->sfbOffset[sfb] );
- Copy32( &x_1_fx[sfbConf->sfbOffset[sfb]], &x_inv_1_fx[sfbConf->sfbOffset[sfb]], sfbConf->sfbOffset[sfb + 1] - sfbConf->sfbOffset[sfb] );
+ Copy32( &x_0_fx[sfbConf->sfbOffset[sfb]], &x_inv_0_fx[sfbConf->sfbOffset[sfb]], sfbConf->sfbOffset[sfb + 1] - sfbConf->sfbOffset[sfb] ); /* q_x */
+ Copy32( &x_1_fx[sfbConf->sfbOffset[sfb]], &x_inv_1_fx[sfbConf->sfbOffset[sfb]], sfbConf->sfbOffset[sfb + 1] - sfbConf->sfbOffset[sfb] ); /* q_x */
IF( EQ_16( ms_mask[iSubframe][sfb], 0 ) )
{
@@ -650,12 +650,12 @@ void ms_inv_mask_processing_fx(
*
*-------------------------------------------------------------------*/
-Word16 write_stereo_to_bitstream(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
- Encoder_State **sts, /* i/o: Encoder state structure */
- Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const Word16 mct_on, /* i : flag mct block (1) or stereo (0)*/
- BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
+Word16 write_stereo_to_bitstream_fx(
+ STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
+ Encoder_State **sts, /* i/o: Encoder state structure */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
+ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
+ BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
)
{
Word16 i, k, nSubframes;
@@ -787,8 +787,8 @@ Word16 write_stereo_to_bitstream(
*-------------------------------------------------------------------*/
static void convertToBwMS_fx(
- const Word16 startLine, /* i : start line of sfb */
- const Word16 stopLine, /* i : stop line of sfb */
+ const Word16 startLine, /* i : start line of sfb Q0*/
+ const Word16 stopLine, /* i : stop line of sfb Q0*/
Word32 x0[],
/* i/o: mid/left channel coefficients */ /* Q_x */
Word32 x1[],
@@ -801,11 +801,11 @@ static void convertToBwMS_fx(
FOR( j = startLine; j < stopLine; j++ )
{
- tmpValue_fx = x0[j];
+ tmpValue_fx = x0[j]; /*Q_x*/
move32();
- x0[j] = Mpy_32_32( L_add( x0[j], x1[j] ), norm_fac );
+ x0[j] = Mpy_32_32( L_add( x0[j], x1[j] ), norm_fac ); /* Q_x */
move32();
- x1[j] = Mpy_32_32( L_sub( tmpValue_fx, x1[j] ), norm_fac );
+ x1[j] = Mpy_32_32( L_sub( tmpValue_fx, x1[j] ), norm_fac ); /* Q_x */
move32();
}
@@ -819,12 +819,10 @@ static void convertToBwMS_fx(
*-------------------------------------------------------------------*/
void convertToMS_fx(
- const Word16 L_frame, /* i : frame length */
- Word32 x0[],
- /* i/o: mid/left channel coefficients */ // Q(q_x)
- Word32 x1[],
- /* i/o: side/right channel coefficients */ // Q(q_x)
- const Word32 norm_fac /* i : normalization factor */ // Q31
+ const Word16 L_frame, /* i : frame length Q0*/
+ Word32 x0[], /* i/o: mid/left channel coefficients Q(q_x)*/
+ Word32 x1[], /* i/o: side/right channel coefficients Q(q_x)*/
+ const Word32 norm_fac /* i : normalization factor Q31*/
)
{
convertToBwMS_fx( 0, L_frame, x0, x1, norm_fac );
@@ -840,14 +838,12 @@ void convertToMS_fx(
/*! r: SQ gain */
static Word32 SQ_gain_estimate_stereo_fx( // e_res
- Word32 xL_fx[],
- /* i : L vector to quantize */ // e_xL
+ Word32 xL_fx[], /* i : L vector to quantize Q31-e_xL*/
Word16 e_xL,
- Word32 xR_fx[],
- /* i : R vector to quantize */ // e_xR
+ Word32 xR_fx[], /* i : R vector to quantize Q31-e_xR*/
Word16 e_xR,
- const Word16 nbitsSQ, /* i : number of bits targeted */
- const Word16 lg, /* i : vector size (2048 max) */
+ const Word16 nbitsSQ, /* i : number of bits targeted Q0*/
+ const Word16 lg, /* i : vector size (2048 max) Q0*/
Word16 *e_res )
{
Word16 i, q, iter, e_ener, e_tmp;
@@ -855,24 +851,24 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
Word32 en_fx[N_MAX / 2]; // Q(26)
Word16 lg2, lg_4, lg2_4;
- lg_4 = shr( lg, 2 );
- lg2_4 = shl( lg_4, 1 );
- lg2 = shl( lg2_4, 2 );
+ lg_4 = shr( lg, 2 ); /* Q0 */
+ lg2_4 = shl( lg_4, 1 ); /* Q0 */
+ lg2 = shl( lg2_4, 2 ); /* Q0 */
i = 0;
move16();
- set32_fx( en_fx, 21474836 /* 0.01 in Q31 */, N_MAX / 2 );
+ set32_fx( en_fx, 21474836 /* 0.01 in Q31 */, idiv1616( N_MAX, 2 ) );
/* energy of quadruples with 9dB offset */
/* ignore that we may take no all lines into account, max. 3 lines at the upper end of the spectrum can be missed (if lg is not a multiple of 4, happens also in SQGain()*/
FOR( q = 0; q < lg_4; q++ )
{
- ener_fx = BASOP_Util_Add_Mant32Exp( 21474836, 0, Mpy_32_32( xL_fx[i], xL_fx[i] ), e_xL * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 1], xL_fx[i + 1] ), e_xL * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 2], xL_fx[i + 2] ), e_xL * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 3], xL_fx[i + 3] ), e_xL * 2, &e_ener );
- en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */
+ ener_fx = BASOP_Util_Add_Mant32Exp( 21474836 /*0.01 in Q15*/, 0, Mpy_32_32( xL_fx[i], xL_fx[i] ), e_xL * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 1], xL_fx[i + 1] ), e_xL * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 2], xL_fx[i + 2] ), e_xL * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 3], xL_fx[i + 3] ), e_xL * 2, &e_ener ); /* Q31-e_ener */
+ en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */
move32();
en_fx[q] = Mpy_32_16_1( L_add( e_ener * ONE_IN_Q25, en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25)
move32();
@@ -881,11 +877,11 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
i = 0;
FOR( ; q < lg2_4; q++ )
{
- ener_fx = BASOP_Util_Add_Mant32Exp( 21474836, 0, Mpy_32_32( xR_fx[i], xR_fx[i] ), e_xR * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 1], xR_fx[i + 1] ), e_xR * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 2], xR_fx[i + 2] ), e_xR * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 3], xR_fx[i + 3] ), e_xR * 2, &e_ener );
- en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */
+ ener_fx = BASOP_Util_Add_Mant32Exp( 21474836 /*0.01 Q15*/, 0, Mpy_32_32( xR_fx[i], xR_fx[i] ), e_xR * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 1], xR_fx[i + 1] ), e_xR * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 2], xR_fx[i + 2] ), e_xR * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 3], xR_fx[i + 3] ), e_xR * 2, &e_ener ); /* Q31-e_ener */
+ en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */
move32();
en_fx[q] = Mpy_32_16_1( L_add( e_ener * ONE_IN_Q25, en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25)
move32();
@@ -896,14 +892,14 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
target_fx = L_mult( 19660 /* 0.15 in Q17 */, sub( nbitsSQ, shr( lg2, 4 ) ) ); // Q(18)
fac_fx = 429496729; /* 12.8 in Q25 */
move32();
- offset_fx = fac_fx;
+ offset_fx = fac_fx; /* Q25 */
move32();
/* find offset (0 to 128 dB with step of 0.125dB) */
FOR( iter = 0; iter < 10; iter++ )
{
- fac_fx = L_shr( fac_fx, 1 );
- offset_fx = L_sub( offset_fx, fac_fx );
+ fac_fx = L_shr( fac_fx, 1 ); /* Q25 */
+ offset_fx = L_sub( offset_fx, fac_fx ); /* Q25 */
ener_fx = 0;
move32();
e_ener = 0;
@@ -911,19 +907,19 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
FOR( i = 0; i < lg2_4; i++ )
{
- tmp_32 = L_sub( en_fx[i], offset_fx );
+ tmp_32 = L_sub( en_fx[i], offset_fx ); /* Q25 */
e_tmp = 6;
move16();
/* avoid SV with 1 bin of amp < 0.5f */
- IF( GT_32( tmp_32, 10066329 ) )
+ IF( GT_32( tmp_32, 10066329 /*0.3 Q25*/ ) )
{
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, tmp_32, e_tmp, &e_ener );
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, tmp_32, e_tmp, &e_ener ); /* Q31-e_ener */
/* if ener is above target -> break and increase offset */
IF( L_shl_sat( ener_fx, sub( e_ener, Q13 ) ) > target_fx )
{
- offset_fx = L_add( offset_fx, fac_fx );
+ offset_fx = L_add( offset_fx, fac_fx ); /* Q25 */
BREAK;
}
}
@@ -933,7 +929,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
/* return gain */
tmp_32 = L_add( 12539858, Mpy_32_16_1( offset_fx, 13606 ) ); // Q23
- return BASOP_util_Pow2( tmp_32, Q8, e_res );
+ return BASOP_util_Pow2( tmp_32, Q8, e_res ); /* Q31-e_res */
}
/*-------------------------------------------------------------------*
@@ -943,23 +939,23 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
*-------------------------------------------------------------------*/
static Word16 QuantSpecEstimateBits_fx(
- Word32 *spec_fx,
+ Word32 *spec_fx, /* Q15-spec_e */
Word16 spec_e,
- Word16 G_fx,
+ Word16 G_fx, /* Q15-G_e */
Word16 G_e,
- const Word16 length,
- const Word16 nBitsAvailable,
- Word16 sqQ[] )
+ const Word16 length, /* Q0 */
+ const Word16 nBitsAvailable, /* Q0 */
+ Word16 sqQ[] /* Q0 */ )
{
Word16 stop, sqBits, nEncoded;
Word16 lastnz;
- tcx_scalar_quantization_ivas_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384, NULL, 1 );
+ tcx_scalar_quantization_ivas_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1 );
stop = 0;
move16();
- sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, length, &lastnz, &nEncoded, nBitsAvailable, &stop, 0, NULL );
+ sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, length, &lastnz, &nEncoded, nBitsAvailable, &stop, 0, NULL ); /*Q0*/
if ( stop != 0 )
{
@@ -976,15 +972,15 @@ static Word16 QuantSpecEstimateBits_fx(
*
*-------------------------------------------------------------------*/
-static void context_update(
+static void context_update_fx(
HANDLE_RC_CONTEXT_MEM ctxSrc,
HANDLE_RC_CONTEXT_MEM ctxTarget,
- const Word16 endLine )
+ const Word16 endLine /*Q0*/ )
{
Word16 last_nz;
/* check if last_nz of target is smaller than endLine, save and update */
- last_nz = s_max( ctxTarget->lastnz, endLine );
+ last_nz = s_max( ctxTarget->lastnz, endLine ); /* Q0 */
mvc2c( (UWord8 *) ctxSrc, (UWord8 *) ctxTarget, sizeof( RC_CONTEXT_MEM ) );
ctxTarget->lastnz = last_nz;
@@ -1003,7 +999,7 @@ static Word16 GetChannelEnergyRatio_fx( // Q15
Encoder_State **sts, /* i/o: Encoder state structure */
const Word16 iFirstSubframe,
const Word16 iLastSubframe,
- const UWord8 ratioInRmsDomain )
+ const UWord8 ratioInRmsDomain /* Q0 */ )
{
Word16 ch, n, i;
Word32 nrg_fx[2];
@@ -1023,11 +1019,11 @@ static Word16 GetChannelEnergyRatio_fx( // Q15
move16();
}
- Word16 L_subframeTCX = shr( st->hTcxEnc->L_frameTCX, sub( nSubframes, 1 ) );
+ Word16 L_subframeTCX = shr( st->hTcxEnc->L_frameTCX, sub( nSubframes, 1 ) ); /* Q0 */
if ( st->last_core == ACELP_CORE )
{
- L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) );
+ L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) ); /* Q0 */
}
assert( iFirstSubframe >= 0 && ( iFirstSubframe <= iLastSubframe ) );
@@ -1040,28 +1036,28 @@ static Word16 GetChannelEnergyRatio_fx( // Q15
{
FOR( i = 0; i < L_subframeTCX; i++ )
{
- nrg_fx[ch] = BASOP_Util_Add_Mant32Exp( nrg_fx[ch], nrg_e[ch], Mpy_32_32( st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ), shl( st->hTcxEnc->spectrum_e[n], 1 ), &nrg_e[ch] );
+ nrg_fx[ch] = BASOP_Util_Add_Mant32Exp( nrg_fx[ch], nrg_e[ch], Mpy_32_32( st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ), shl( st->hTcxEnc->spectrum_e[n], 1 ), &nrg_e[ch] ); /* Q31-nrg_e */
move32();
}
}
IF( ratioInRmsDomain && nrg_fx[ch] )
{
- nrg_fx[ch] = Sqrt32( nrg_fx[ch], &nrg_e[ch] );
+ nrg_fx[ch] = Sqrt32( nrg_fx[ch], &nrg_e[ch] ); /* Q31-nrg_e */
move32();
}
}
IF( L_add_sat( nrg_fx[0], nrg_fx[1] ) )
{
- nrg_fx[1] = BASOP_Util_Add_Mant32Exp( nrg_fx[0], nrg_e[0], nrg_fx[1], nrg_e[1], &nrg_e[1] );
+ nrg_fx[1] = BASOP_Util_Add_Mant32Exp( nrg_fx[0], nrg_e[0], nrg_fx[1], nrg_e[1], &nrg_e[1] ); /* Q31-nrg_e[1] */
move32();
IF( NE_16( nrg_e[1], nrg_e[0] ) )
{
- nrg_fx[0] = L_shr( nrg_fx[0], sub( nrg_e[1], nrg_e[0] ) );
+ nrg_fx[0] = L_shr( nrg_fx[0], sub( nrg_e[1], nrg_e[0] ) ); /* Q31-nrg_e[1] */
move32();
}
- return divide3232( nrg_fx[0], nrg_fx[1] );
+ return divide3232( nrg_fx[0], nrg_fx[1] ); /* Q15 */
}
return MIN_16;
@@ -1090,21 +1086,21 @@ void FindSplitRatio_fx(
IF( ratio_fx >= 0 )
{
- hCPE->hStereoMdct->split_ratio = round_fx( L_mult( SMDCT_BITRATE_RATIO_RANGE, ratio_fx ) );
+ hCPE->hStereoMdct->split_ratio = round_fx( L_mult( SMDCT_BITRATE_RATIO_RANGE, ratio_fx ) ); /* Q0 */
move16();
/* Tuning to get closer to the optimal split ratio */
IF( LT_32( L_mult0( 9, ratio_fx ), 8 * ONE_IN_Q15 ) && GT_16( hCPE->hStereoMdct->split_ratio, SMDCT_EQUAL_RATIO_RANGE + ( SMDCT_BITRATE_RATIO_RANGE >> 4 ) ) )
{
- hCPE->hStereoMdct->split_ratio = sub( hCPE->hStereoMdct->split_ratio, SMDCT_BITRATE_RATIO_RANGE >> 3 );
+ hCPE->hStereoMdct->split_ratio = sub( hCPE->hStereoMdct->split_ratio, SMDCT_BITRATE_RATIO_RANGE >> 3 ); /* Q0 */
move16();
}
IF( GT_32( L_mult0( 9, ratio_fx ), 1 * ONE_IN_Q15 ) && LT_16( hCPE->hStereoMdct->split_ratio, SMDCT_EQUAL_RATIO_RANGE - ( SMDCT_BITRATE_RATIO_RANGE >> 4 ) ) )
{
- hCPE->hStereoMdct->split_ratio = add( hCPE->hStereoMdct->split_ratio, SMDCT_BITRATE_RATIO_RANGE >> 3 );
+ hCPE->hStereoMdct->split_ratio = add( hCPE->hStereoMdct->split_ratio, SMDCT_BITRATE_RATIO_RANGE >> 3 ); /* Q0 */
move16();
}
- hCPE->hStereoMdct->split_ratio = s_min( SMDCT_BITRATE_RATIO_RANGE - 1, s_max( 1, hCPE->hStereoMdct->split_ratio ) );
+ hCPE->hStereoMdct->split_ratio = s_min( SMDCT_BITRATE_RATIO_RANGE - 1, s_max( 1, hCPE->hStereoMdct->split_ratio ) ); /* Q0 */
move16();
}
@@ -1126,11 +1122,11 @@ static void MsStereoDecision_fx(
Word32 *specS_fx,
/* scratch buffer for M, use buffer for inverse MS mask spectrum */ /* Q( q_spec ) */
Word16 q_spec,
- Word16 *mdct_stereo_mode, /* output */
- Word16 *msMask, /* output */
- const Word16 nBitsAvailable )
+ Word16 *mdct_stereo_mode, /* output Q0*/
+ Word16 *msMask, /* output Q0*/
+ const Word16 nBitsAvailable /*Q0*/ )
{
- Word16 length = sfbParam->sfbOffset[sfbParam->nBandsStereoCore];
+ Word16 length = sfbParam->sfbOffset[sfbParam->nBandsStereoCore]; /* Q0 */
Word16 bitsL, bitsR, bitsM, bitsS;
Word16 bitsBW, bitsLR, bitsMS;
@@ -1163,7 +1159,7 @@ static void MsStereoDecision_fx(
specM_e = sub( Q31, q_spec );
specS_e = sub( Q31, q_spec );
- GLR_fx = SQ_gain_estimate_stereo_fx( specL_fx, specL_e, specR_fx, specR_e, nBitsAvailable, length, &e_GLR );
+ GLR_fx = SQ_gain_estimate_stereo_fx( specL_fx, specL_e, specR_fx, specR_e, nBitsAvailable, length, &e_GLR ); /* Q31-e_GLR */
FOR( i = 0; i < length; i++ )
{
@@ -1173,12 +1169,12 @@ static void MsStereoDecision_fx(
move32();
}
- G_fx = extract_h( GLR_fx ); /* seems to be favourable to underestimate a bit */
+ G_fx = extract_h( GLR_fx ); /* seems to be favourable to underestimate a bit Q15-e_GLR*/
G_e = sub( e_GLR, 1 );
/* do the full spectrum estimates already here, as side effect we get the quantized spectra... */
- bitsLR = add( QuantSpecEstimateBits_fx( specL_fx, specL_e, G_fx, G_e, length, nBitsAvailable, quantSpecL ), QuantSpecEstimateBits_fx( specR_fx, specR_e, G_fx, G_e, length, nBitsAvailable, quantSpecR ) );
- bitsMS = add( QuantSpecEstimateBits_fx( specM_fx, specM_e, G_fx, G_e, length, nBitsAvailable, quantSpecM ), QuantSpecEstimateBits_fx( specS_fx, specS_e, G_fx, G_e, length, nBitsAvailable, quantSpecS ) );
+ bitsLR = add( QuantSpecEstimateBits_fx( specL_fx, specL_e, G_fx, G_e, length, nBitsAvailable, quantSpecL ), QuantSpecEstimateBits_fx( specR_fx, specR_e, G_fx, G_e, length, nBitsAvailable, quantSpecR ) ); /* Q0 */
+ bitsMS = add( QuantSpecEstimateBits_fx( specM_fx, specM_e, G_fx, G_e, length, nBitsAvailable, quantSpecM ), QuantSpecEstimateBits_fx( specS_fx, specS_e, G_fx, G_e, length, nBitsAvailable, quantSpecS ) ); /* Q0 */
/* clean-up MS scratch buffers */
set32_fx( specM_fx, 0, length );
@@ -1189,11 +1185,11 @@ static void MsStereoDecision_fx(
bitsBW = 0;
move16();
- RCcontextMapping_encode2_estimate_bandWise_start( quantSpecL, length, nBitsAvailable, ctxL );
- RCcontextMapping_encode2_estimate_bandWise_start( quantSpecR, length, nBitsAvailable, ctxR );
+ RCcontextMapping_encode2_estimate_bandWise_start_fx( quantSpecL, length, nBitsAvailable, ctxL );
+ RCcontextMapping_encode2_estimate_bandWise_start_fx( quantSpecR, length, nBitsAvailable, ctxR );
- bitsBW = add( bitsBW, RCcontextMapping_encode2_estimate_bandWise_start( quantSpecM, length, nBitsAvailable, ctxM ) );
- bitsBW = add( bitsBW, RCcontextMapping_encode2_estimate_bandWise_start( quantSpecS, length, nBitsAvailable, ctxS ) );
+ bitsBW = add( bitsBW, RCcontextMapping_encode2_estimate_bandWise_start_fx( quantSpecM, length, nBitsAvailable, ctxM ) ); /* Q0 */
+ bitsBW = add( bitsBW, RCcontextMapping_encode2_estimate_bandWise_start_fx( quantSpecS, length, nBitsAvailable, ctxS ) ); /* Q0 */
/*find_max_lastnz(ctxL,ctxR,ctxM,ctxS);*/
@@ -1204,32 +1200,32 @@ static void MsStereoDecision_fx(
const Word16 endline = sfbParam->sfbOffset[sfb + 1];
move16();
- bitsL = RCcontextMapping_encode2_estimate_bandWise( quantSpecL, startline, endline, ctxL );
- bitsR = RCcontextMapping_encode2_estimate_bandWise( quantSpecR, startline, endline, ctxR );
- bitsM = RCcontextMapping_encode2_estimate_bandWise( quantSpecM, startline, endline, ctxM );
- bitsS = RCcontextMapping_encode2_estimate_bandWise( quantSpecS, startline, endline, ctxS );
+ bitsL = RCcontextMapping_encode2_estimate_bandWise_fx( quantSpecL, startline, endline, ctxL );
+ bitsR = RCcontextMapping_encode2_estimate_bandWise_fx( quantSpecR, startline, endline, ctxR );
+ bitsM = RCcontextMapping_encode2_estimate_bandWise_fx( quantSpecM, startline, endline, ctxM );
+ bitsS = RCcontextMapping_encode2_estimate_bandWise_fx( quantSpecS, startline, endline, ctxS );
IF( LE_16( add( bitsM, bitsS ), add( bitsL, bitsR ) ) )
{
msMask[sfb] = 1;
move16();
nMSOn = add( nMSOn, 1 );
- context_update( ctxM, ctxL, endline );
- context_update( ctxS, ctxR, endline );
- bitsBW = add( bitsBW, add( bitsM, bitsS ) );
+ context_update_fx( ctxM, ctxL, endline );
+ context_update_fx( ctxS, ctxR, endline );
+ bitsBW = add( bitsBW, add( bitsM, bitsS ) ); /* Q0 */
}
ELSE
{
msMask[sfb] = 0;
move16();
- context_update( ctxL, ctxM, endline );
- context_update( ctxR, ctxS, endline );
- bitsBW = add( bitsBW, add( bitsL, bitsR ) );
+ context_update_fx( ctxL, ctxM, endline );
+ context_update_fx( ctxR, ctxS, endline );
+ bitsBW = add( bitsBW, add( bitsL, bitsR ) ); /* Q0 */
}
}
- bitsBW = add( bitsBW, sfbParam->nBandsStereoCore ); /* Signaling bits */
+ bitsBW = add( bitsBW, sfbParam->nBandsStereoCore ); /* Signaling bits Q0*/
IF( LT_16( bitsLR, bitsBW ) )
{
@@ -1273,17 +1269,17 @@ static void MsStereoDecision_fx(
void initMdctStereoEncData_fx(
STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */
const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 element_mode, /* i : element mode */
- const Word32 element_brate, /* i : element bitrate */
- const Word16 bwidth, /* i : bandwidth */
- const Word16 igf, /* i : flag indicating IGF activity */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word16 bwidth, /* i : bandwidth Q0*/
+ const Word16 igf, /* i : flag indicating IGF activity Q0*/
const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */
- const Word16 mem_init /* i : initialize memory after malloc */
+ const Word16 mem_init /* i : initialize memory after malloc Q0*/
)
{
Word16 tcx_coded_lines;
- tcx_coded_lines = getNumTcxCodedLines( bwidth );
+ tcx_coded_lines = getNumTcxCodedLines( bwidth ); /* Q0 */
/*initialize mdct stereo mode*/
set16_fx( hStereoMdct->mdct_stereo_mode, -1, 2 );
@@ -1301,22 +1297,7 @@ void initMdctStereoEncData_fx(
set16_fx( hStereoMdct->IGFStereoMode, -1, 2 );
-#ifdef DEBUG_FORCE_MDCT_STEREO_MODE
- /*set all other members to defined states */
- hStereoMdct->fDualMono = 0;
- hStereoMdct->fMSstereo = 0;
-
- if ( hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_LR )
- {
- hStereoMdct->fDualMono = 1;
- }
- else if ( hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_MS )
- {
- hStereoMdct->fMSstereo = 1;
- }
-#endif
-
- hStereoMdct->split_ratio = SMDCT_EQUAL_RATIO_RANGE;
+ hStereoMdct->split_ratio = SMDCT_EQUAL_RATIO_RANGE; /* Q0 */
move16();
set16_fx( hStereoMdct->global_ild, SMDCT_ILD_RANGE >> 1, 2 );
@@ -1355,9 +1336,11 @@ void initMdctStereoEncData_fx(
ivas_error initMdctItdHandling_fx(
STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */
- const Word32 input_Fs /* i : input sampling rate */
+ const Word32 input_Fs /* i : input sampling rate Q0*/
)
{
+ test();
+ test();
IF( hStereoMdct->hItd == NULL )
{
IF( ( hStereoMdct->hItd = (ITD_DATA_HANDLE) malloc( sizeof( ITD_DATA ) ) ) == NULL )
@@ -1366,6 +1349,8 @@ ivas_error initMdctItdHandling_fx(
}
}
+ test();
+ test();
IF( hStereoMdct->hDft_ana == NULL )
{
IF( ( hStereoMdct->hDft_ana = (DFT_ANA_HANDLE) malloc( sizeof( DFT_ANA ) ) ) == NULL )
diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c
index ba84be1a2000f4ada3bb3b6fc5e901d993dae781..a1e5592e530ba3eb58a1308473ff2151c020dbf8 100644
--- a/lib_enc/ivas_stereo_switching_enc.c
+++ b/lib_enc/ivas_stereo_switching_enc.c
@@ -54,7 +54,7 @@ static ivas_error allocate_CoreCoder_enc_fx(
ENC_CORE_HANDLE st /* i/o: Core encoder state structure */
)
{
- IF( st->hLPDmem == NULL && st->element_mode != IVAS_CPE_MDCT )
+ IF( st->hLPDmem == NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL )
{
@@ -63,7 +63,7 @@ static ivas_error allocate_CoreCoder_enc_fx(
LPDmem_enc_init_ivas_fx( st->hLPDmem );
}
- IF( st->hGSCEnc == NULL && st->element_mode != IVAS_CPE_MDCT )
+ IF( st->hGSCEnc == NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st->hGSCEnc = (GSC_ENC_HANDLE) malloc( sizeof( GSC_ENC_DATA ) ) ) == NULL )
{
@@ -221,10 +221,10 @@ static void deallocate_CoreCoder_enc_fx(
ivas_error stereo_memory_enc_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
- const Word16 max_bwidth, /* i : maximum audio bandwidth */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
+ const Word16 max_bwidth, /* i : maximum audio bandwidth Q0*/
const IVAS_FORMAT ivas_format, /* i : ivas format */
- const Word16 nchan_transport /* i : number transport chans */
+ const Word16 nchan_transport /* i : number transport chans Q0*/
)
{
Encoder_State *st;
@@ -241,7 +241,16 @@ ivas_error stereo_memory_enc_fx(
test();
IF( hCPE->hStereoTCA != NULL && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
+#ifdef FIX_1132_STACK_CORRUPTION
+ Word16 tmp = extract_h( abs( hCPE->hStereoDft->hItd->itd_fx[1] ) );
+ if ( hCPE->hStereoDft->hItd->itd_fx[1] < 0 )
+ {
+ tmp = negate( tmp );
+ }
+ set16_fx( hCPE->hStereoTCA->prevCorrLagStats, tmp, 3 );
+#else
set16_fx( hCPE->hStereoTCA->prevCorrLagStats, extract_h( hCPE->hStereoDft->hItd->itd_fx[1] ), 3 );
+#endif
IF( hCPE->hStereoDft->hItd->itd_fx[1] >= 0 )
{
hCPE->hStereoTCA->prevRefChanIndx = L_CH_INDX;
@@ -517,8 +526,8 @@ ivas_error stereo_memory_enc_fx(
// st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long;
// st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX;
- st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx;
- st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX;
+ st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; /* Q31-st->hTcxEnc->spectrum_e[0] */
+ st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; /* Q31-st->hTcxEnc->spectrum_e[1] */
st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0;
move16();
move16();
@@ -527,6 +536,8 @@ ivas_error stereo_memory_enc_fx(
set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX );
st->hTcxEnc->spectrum_long_e = 0;
st->hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */
+ move16();
+ move32();
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
@@ -560,6 +571,7 @@ ivas_error stereo_memory_enc_fx(
test();
hCPE->hStereoMdct->isSBAStereoMode = ( EQ_32( ivas_format, SBA_FORMAT ) && EQ_16( nchan_transport, 2 ) );
+ move16();
test();
test();
@@ -625,17 +637,17 @@ ivas_error stereo_memory_enc_fx(
}
static void v_multc_fixed_32_16(
- const Word16 x[], /* i : Input vector */
- const Word32 c, /* i : Constant */
- Word32 y[], /* o : Output vector that contains c*x */
- const Word16 N /* i : Vector length */
+ const Word16 x[], /* i : Input vector Qx*/
+ const Word32 c, /* i : Constant Q31*/
+ Word32 y[], /* o : Output vector that contains c*x Qx*/
+ const Word16 N /* i : Vector length Q0*/
)
{
Word16 i;
FOR( i = 0; i < N; i++ )
{
- y[i] = Mpy_32_16_1( c, x[i] );
+ y[i] = Mpy_32_16_1( c, x[i] ); /* Q16+Qx */
move32();
}
@@ -649,8 +661,8 @@ static void v_multc_fixed_32_16(
void stereo_switching_enc_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- Word16 old_input_signal_pri[], /* i : old input signal of primary channel */
- const Word16 input_frame, /* i : input frame length */
+ Word16 old_input_signal_pri[], /* i : old input signal of primary channel q_inp*/
+ const Word16 input_frame, /* i : input frame length Q0*/
const Word16 q_inp )
{
Word16 i, n, dft_ovl, offset;
@@ -668,16 +680,16 @@ void stereo_switching_enc_fx(
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Copy( sts[n]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl );
+ Copy( sts[n]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl ); /* sts[n]->q_inp */
}
}
/* save original stereo input (MDCT overlap part) for both channels in unused old input of right channel for possible DFT->MDCT transition */
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- Copy( sts[0]->input_fx + sub( (Word16) Mpy_32_32( sts[0]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[0]->encoderLookahead_FB ), sts[1]->input_fx - shl( sts[0]->encoderLookahead_FB, 1 ), sts[0]->encoderLookahead_FB );
+ Copy( sts[0]->input_fx + sub( (Word16) Mpy_32_32( sts[0]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[0]->encoderLookahead_FB ), sts[1]->input_fx - shl( sts[0]->encoderLookahead_FB, 1 ), sts[0]->encoderLookahead_FB ); /* sts[0]->q_inp */
- Copy( sts[1]->input_fx + sub( (Word16) Mpy_32_32( sts[1]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[1]->encoderLookahead_FB ), sts[1]->input_fx - sts[1]->encoderLookahead_FB, sts[1]->encoderLookahead_FB );
+ Copy( sts[1]->input_fx + sub( (Word16) Mpy_32_32( sts[1]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[1]->encoderLookahead_FB ), sts[1]->input_fx - sts[1]->encoderLookahead_FB, sts[1]->encoderLookahead_FB ); /* sts[1]->q_inp */
}
@@ -688,7 +700,7 @@ void stereo_switching_enc_fx(
/* window DFT synthesis overlap memory @input_Fs, primary channel */
FOR( i = 0; i < dft_ovl; i++ )
{
- hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), q_inp ); // ( ( Q31 + q_inp ) - Q15 ) - Q16 ) -> Q16
+ hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), add( q_inp, 1 ) ); // Q31 + q_inp - Q15 - (q_inp + 1) -> Q15
move32();
}
/* reset 48kHz BWE overlap memory */
@@ -710,7 +722,7 @@ void stereo_switching_enc_fx(
tmp_fx = usdequant_fx( hCPE->hStereoTCA->indx_ica_gD, STEREO_TCA_GDMIN_FX, STEREO_TCA_GDSTEP_FX );
FOR( i = 0; i < STEREO_DFT_BAND_MAX; i++ )
{
- hCPE->hStereoDft->side_gain_fx[STEREO_DFT_BAND_MAX + i] = L_deposit_h( tmp_fx );
+ hCPE->hStereoDft->side_gain_fx[STEREO_DFT_BAND_MAX + i] = L_deposit_h( tmp_fx ); /* Q31 */
move32();
}
}
@@ -722,22 +734,22 @@ void stereo_switching_enc_fx(
/* update DFT synthesis overlap memory @12.8kHz */
FOR( i = 0; i < STEREO_DFT_OVL_12k8; i++ )
{
- hCPE->hStereoDft->output_mem_dmx_12k8_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_12k8_fx[STEREO_DFT_OVL_12k8 - 1 - i], sts[0]->buf_speech_enc[L_FRAME32k + L_FRAME - STEREO_DFT_OVL_12k8 + i] ), q_inp );
+ hCPE->hStereoDft->output_mem_dmx_12k8_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_12k8_fx[STEREO_DFT_OVL_12k8 - 1 - i], sts[0]->buf_speech_enc[L_FRAME32k + L_FRAME - STEREO_DFT_OVL_12k8 + i] ), q_inp + 1 ); /* Q15 */
move32();
}
- Word16 q_dmx = Q16;
+ Word16 q_dmx = Q15;
move16();
/* update DFT synthesis overlap memory @16kHz, primary channel only */
L_lerp_fx( hCPE->hStereoDft->output_mem_dmx_fx, hCPE->hStereoDft->output_mem_dmx_16k_fx, STEREO_DFT_OVL_16k, dft_ovl, &q_dmx );
FOR( i = 0; i < STEREO_DFT_OVL_16k; i++ )
{
- hCPE->hStereoDft->output_mem_dmx_16k_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_16k_fx[i], sub( Q16, q_dmx ) ); // Q16
+ hCPE->hStereoDft->output_mem_dmx_16k_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_16k_fx[i], sub( Q15, q_dmx ) ); // Q15
move32();
}
FOR( i = 0; i < STEREO_DFT_OVL_MAX; i++ )
{
- hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_fx[i], sub( Q16, q_dmx ) ); // Q16
+ hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_fx[i], sub( Q15, q_dmx ) ); // Q15
move32();
}
@@ -782,7 +794,8 @@ void stereo_switching_enc_fx(
set_zero_fx( sts[1]->input32_fx - input_frame, input_frame );
set16_zero_fx( sts[1]->input_fx - input_frame, input_frame );
sts[1]->q_old_inp = Q15;
- hCPE->hStereoTD->tdm_last_ratio_fx = tdm_ratio_tabl_fx[LRTD_STEREO_LEFT_IS_PRIM];
+ hCPE->hStereoTD->tdm_last_ratio_fx = tdm_ratio_tabl_fx[LRTD_STEREO_LEFT_IS_PRIM]; /* Q31 */
+ move16();
move32();
hCPE->hStereoTD->tdm_last_ratio_idx = LRTD_STEREO_LEFT_IS_PRIM;
@@ -790,9 +803,9 @@ void stereo_switching_enc_fx(
test();
test();
- IF( LT_32( hCPE->hStereoTCA->instTargetGain_fx, 26843546 ) && ( hCPE->hCoreCoder[0]->vad_flag || hCPE->hCoreCoder[1]->vad_flag ) ) /* but if there is no content in the L channel -> the primary channel is forced to right */
+ IF( LT_32( hCPE->hStereoTCA->instTargetGain_fx, 26843546 /*Q29*/ ) && ( hCPE->hCoreCoder[0]->vad_flag || hCPE->hCoreCoder[1]->vad_flag ) ) /* but if there is no content in the L channel -> the primary channel is forced to right */
{
- hCPE->hStereoTD->tdm_last_ratio_fx = tdm_ratio_tabl_fx[LRTD_STEREO_RIGHT_IS_PRIM];
+ hCPE->hStereoTD->tdm_last_ratio_fx = tdm_ratio_tabl_fx[LRTD_STEREO_RIGHT_IS_PRIM]; /* Q31 */
move32();
hCPE->hStereoTD->tdm_last_ratio_idx = LRTD_STEREO_RIGHT_IS_PRIM;
move16();
@@ -806,10 +819,10 @@ void stereo_switching_enc_fx(
{
IF( sts[0]->cldfbAnaEnc != NULL )
{
- offset = sub( sts[0]->cldfbAnaEnc->p_filter_length, sts[0]->cldfbAnaEnc->no_channels );
+ offset = sub( sts[0]->cldfbAnaEnc->p_filter_length, sts[0]->cldfbAnaEnc->no_channels ); /* Q0 */
FOR( i = 0; i < offset; i++ )
{
- sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = L_deposit_h( old_input_signal_pri[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] );
+ sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = L_deposit_h( old_input_signal_pri[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ); /* Q16+q_inp */
move32();
}
sts[0]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp );
@@ -819,7 +832,7 @@ void stereo_switching_enc_fx(
IF( sts[0]->cldfbSynTd != NULL )
{
cldfb_reset_memory_fx( sts[0]->cldfbSynTd );
- sts[0]->currEnergyLookAhead_fx = 130996;
+ sts[0]->currEnergyLookAhead_fx = 130996; /* Q31 */
move32();
}
@@ -831,7 +844,7 @@ void stereo_switching_enc_fx(
test();
IF( hCPE->hStereoTD != NULL && EQ_16( hCPE->hStereoTD->tdm_last_ratio_idx, LRTD_STEREO_LEFT_IS_PRIM ) )
{
- v_multc_fixed_32_16( hCPE->hCoreCoder[1]->old_input_signal_fx + sub( input_frame, add( offset, NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset );
+ v_multc_fixed_32_16( hCPE->hCoreCoder[1]->old_input_signal_fx + sub( input_frame, add( offset, NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */
sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp );
move16();
}
@@ -839,7 +852,7 @@ void stereo_switching_enc_fx(
{
FOR( i = 0; i < offset; i++ )
{
- sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = L_shr( L_deposit_h( hCPE->hCoreCoder[1]->old_input_signal_fx[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ), 5 );
+ sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = L_shr( L_deposit_h( hCPE->hCoreCoder[1]->old_input_signal_fx[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ), 5 ); /* Q11+q_inp */
move32();
}
sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16 - 5, q_inp );
@@ -849,7 +862,7 @@ void stereo_switching_enc_fx(
IF( sts[1]->cldfbSynTd != NULL )
{
cldfb_reset_memory_fx( sts[1]->cldfbSynTd );
- sts[1]->currEnergyLookAhead_fx = 130996;
+ sts[1]->currEnergyLookAhead_fx = 130996; /* Q31 */
move32();
}
}
@@ -909,32 +922,32 @@ void stereo_switching_enc_fx(
{
Copy( sts[0]->hLPDmem->old_exc, sts[1]->hLPDmem->old_exc, L_EXC_MEM );
}
- Copy( sts[0]->lsf_old_fx, sts[1]->lsf_old_fx, M );
- Copy( sts[0]->lsp_old_fx, sts[1]->lsp_old_fx, M );
- Copy( sts[0]->lsf_old1_fx, sts[1]->lsf_old1_fx, M );
- Copy( sts[0]->lsp_old1_fx, sts[1]->lsp_old1_fx, M );
+ Copy( sts[0]->lsf_old_fx, sts[1]->lsf_old_fx, M ); /* Qlog2(2.56) */
+ Copy( sts[0]->lsp_old_fx, sts[1]->lsp_old_fx, M ); /* Q15 */
+ Copy( sts[0]->lsf_old1_fx, sts[1]->lsf_old1_fx, M ); /* Qlog2(2.56) */
+ Copy( sts[0]->lsp_old1_fx, sts[1]->lsp_old1_fx, M ); /* Q15 */
sts[1]->GSC_noisy_speech = 0;
move16();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
/* cross-fade overlap region of DFT Stereo downmix and original stereo channels */
- tmp_fx = div_s( 64, shl( sts[0]->encoderLookahead_FB, Q6 ) );
+ tmp_fx = div_s( 64, shl( sts[0]->encoderLookahead_FB, Q6 ) ); /* Q15 */
FOR( i = 0; i < sts[0]->encoderLookahead_FB; i++ )
{
- sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 );
+ sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 ); /* q_inp32+0-15+15-15-13 */
move32();
- sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-2 * sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 );
+ sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-2 * sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 ); /* q_inp32+0-15+15-15-13 */
move32();
}
/* restore continuous signal in right channel (part of old_output was used to store original left channel) */
- Copy32( sts[0]->input32_fx - sts[0]->hTcxEnc->L_frameTCX, sts[1]->input32_fx - sts[0]->hTcxEnc->L_frameTCX, sts[0]->hTcxEnc->L_frameTCX - sts[0]->encoderLookahead_FB );
+ Copy32( sts[0]->input32_fx - sts[0]->hTcxEnc->L_frameTCX, sts[1]->input32_fx - sts[0]->hTcxEnc->L_frameTCX, sub( sts[0]->hTcxEnc->L_frameTCX, sts[0]->encoderLookahead_FB ) ); /* sts[0]->q_inp32 */
- sts[1]->last_core = sts[0]->last_core;
+ sts[1]->last_core = sts[0]->last_core; /* Q0 */
move16();
- sts[1]->last_coder_type = sts[0]->last_coder_type;
+ sts[1]->last_coder_type = sts[0]->last_coder_type; /* Q0 */
move16();
- sts[1]->last_bwidth = sts[0]->last_bwidth;
+ sts[1]->last_bwidth = sts[0]->last_bwidth; /* Q0 */
move16();
}
}
@@ -949,7 +962,7 @@ void stereo_switching_enc_fx(
test();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && NE_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
- sts[1]->hTcxCfg->last_aldo = sts[0]->hTcxCfg->last_aldo;
+ sts[1]->hTcxCfg->last_aldo = sts[0]->hTcxCfg->last_aldo; /* Q0 */
move16();
sts[1]->hTcxCfg->tcx_curr_overlap_mode = sts[0]->hTcxCfg->tcx_curr_overlap_mode;
move16();
diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c
index fdf53370e97239e1b7f5e94d5c0e0c55d6db3c51..58e72c91e38992ca05fab77506bbfdfa492344d5 100644
--- a/lib_enc/ivas_stereo_td_analysis.c
+++ b/lib_enc/ivas_stereo_td_analysis.c
@@ -114,23 +114,23 @@
* Local function prototypes
*-------------------------------------------------------------------*/
-static Word16 stereo_tdm_ener_analysis_SM_fx( CPE_ENC_HANDLE hCPE, Encoder_State **sts, const Word16 input_frame, Word16 *tdm_SM_flag );
+static Word16 stereo_tdm_ener_analysis_SM_fx( CPE_ENC_HANDLE hCPE, Encoder_State **sts, const Word16 input_frame /*Q0*/, Word16 *tdm_SM_flag /*Q0*/ );
-static void Get_corr_n_fx( const Word16 L[], const Word16 R[], Word32 *ic_Lm, Word16 *q_ic_Lm, Word32 *ic_Rm, Word16 *q_ic_Rm, const Word16 len, Word32 *es_em, const Word16 tdm_SM_calc_flag );
+static void Get_corr_n_fx( const Word16 L[] /*q_in*/, const Word16 R[] /*q_in*/, Word32 *ic_Lm, Word16 *q_ic_Lm, Word32 *ic_Rm, Word16 *q_ic_Rm, const Word16 len, Word32 *es_em, const Word16 tdm_SM_calc_flag );
static Word16 stereo_smooth_LR_transition_fx( Word16 *tdm_prev_stable_idx, Word16 *tdm_ratio_transition_mov_flag, Word16 tdm_last_ratio_idx, Word16 *tdm_prev_desired_idx, Word16 *tdm_ratio_transition_cnt, const Word16 tdm_SM_flag, Word16 desired_idx );
-static Word16 limit_idx_Dwnmix_fx( const Word16 idx_in, const Word16 unclr_decision, const Word16 inst_idx, const Word16 previous_idx, const Word16 tdm_last_LRTD_PriCh_cnt, const Word16 tdm_last_LRTD_frame_cnt );
+static Word16 limit_idx_Dwnmix_fx( const Word16 idx_in /*Q0*/, const Word16 unclr_decision /*Q0*/, const Word16 inst_idx /*Q0*/, const Word16 previous_idx /*Q0*/, const Word16 tdm_last_LRTD_PriCh_cnt /*Q0*/, const Word16 tdm_last_LRTD_frame_cnt /*Q0*/ );
-static Word16 limit_idx_NoDwnmix_fx( const Word16 idx_in, const Word16 side_can_change, const Word32 d_lt_corr_raw, const Word16 q_d_lt_corr_raw );
+static Word16 limit_idx_NoDwnmix_fx( const Word16 idx_in /*Q0*/, const Word16 side_can_change /*Q0*/, const Word32 d_lt_corr_raw, const Word16 q_d_lt_corr_raw );
-static void Get_LR_rms_fx( const Word16 *Left_in, const Word16 *Right_in, const Word16 input_frame, Word32 *rms_L, Word16 *q_rms_L, Word32 *rms_R, Word16 *q_rms_R );
+static void Get_LR_rms_fx( const Word16 *Left_in /*q_inp*/, const Word16 *Right_in /*q_inp*/, const Word16 input_frame, Word32 *rms_L, Word16 *q_rms_L, Word32 *rms_R, Word16 *q_rms_R );
-static Word16 Get_dt_lt_ener_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono, const Word16 input_frame, const Word16 tdm_last_SM_flag, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, Word32 *tdm_lt_rms_L, Word32 *tdm_lt_rms_R, Word32 *tdm_last_ener_lt_L, Word32 *tdm_last_ener_lt_R, Word32 *tdm_LT_es_em, Word16 *tdm_hyst_cnt, Word16 *tdm_NOOP_SM_flag_loc, Word32 *ener_R_dt, Word32 *ener_L_dt, Word32 *corr_LM, Word16 *q_corr_LM, Word32 *corr_RM, Word16 *q_corr_RM );
+static Word16 Get_dt_lt_ener_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono, const Word16 input_frame, const Word16 tdm_last_SM_flag, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, Word32 *tdm_lt_rms_L /*Q16*/, Word32 *tdm_lt_rms_R /*Q16*/, Word32 *tdm_last_ener_lt_L /*Q16*/, Word32 *tdm_last_ener_lt_R /*Q16*/, Word32 *tdm_LT_es_em /*Q21*/, Word16 *tdm_hyst_cnt, Word16 *tdm_NOOP_SM_flag_loc, Word32 *ener_R_dt /*Q16*/, Word32 *ener_L_dt /*Q16*/, Word32 *corr_LM, Word16 *q_corr_LM, Word32 *corr_RM, Word16 *q_corr_RM );
-static void NOOP_decision_fx( CPE_ENC_HANDLE hCPE, const Word16 tdm_NOOP_flag_loc, const Word16 tmp_SM_flag, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, Word16 *tdm_SM_flag_loc );
+static void NOOP_decision_fx( CPE_ENC_HANDLE hCPE, const Word16 tdm_NOOP_flag_loc /*Q0*/, const Word16 tmp_SM_flag /*Q0*/, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, Word16 *tdm_SM_flag_loc /*Q0*/ );
-static Word32 Comp_diff_lt_corr_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, const Word32 ener_L_dt, const Word32 ener_R_dt, Word32 corr_LM, Word16 q_corr_LM, Word32 corr_RM, Word16 q_corr_RM, const Word32 tdm_lt_rms_L, const Word32 tdm_lt_rms_R, Word32 *tdm_lt_corr_LM, Word32 *tdm_lt_corr_RM, Word32 *tdm_last_diff_lt_corr, Word16 *q_tdm_last_diff_lt_corr, Word32 *inst_ratio_L_out, Word32 *diff_lt_corr, Word16 *q_d_lt_corr_raw );
+static Word32 Comp_diff_lt_corr_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono /*Q0*/, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, const Word32 ener_L_dt /*Q16*/, const Word32 ener_R_dt /*Q16*/, Word32 corr_LM, Word16 q_corr_LM, Word32 corr_RM, Word16 q_corr_RM, const Word32 tdm_lt_rms_L /*Q16*/, const Word32 tdm_lt_rms_R /*Q16*/, Word32 *tdm_lt_corr_LM /*Q24*/, Word32 *tdm_lt_corr_RM /*Q24*/, Word32 *tdm_last_diff_lt_corr, Word16 *q_tdm_last_diff_lt_corr, Word32 *inst_ratio_L_out /*Q24*/, Word32 *diff_lt_corr, Word16 *q_d_lt_corr_raw );
/*-------------------------------------------------------------------*
@@ -140,9 +140,9 @@ static Word32 Comp_diff_lt_corr_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono
Word16 stereo_tdm_ener_analysis_fx(
const Word16 ivas_format, /* i : IVAS format */
CPE_ENC_HANDLE hCPE, /* i : CPE structure */
- const Word16 input_frame, /* i : Number of samples */
- Word16 *tdm_SM_or_LRTD_Pri, /* o : channel combination scheme flag in TD stereo OR LRTD primary channel */
- Word16 *tdm_ratio_idx_SM /* o : TDM ratio index for SM mode */
+ const Word16 input_frame, /* i : Number of samples Q0*/
+ Word16 *tdm_SM_or_LRTD_Pri, /* o : channel combination scheme flag in TD stereo OR LRTD primary channel Q0*/
+ Word16 *tdm_ratio_idx_SM /* o : TDM ratio index for SM mode Q0*/
)
{
Word32 diff_lt_corr_fx /*Q24*/;
@@ -189,7 +189,7 @@ Word16 stereo_tdm_ener_analysis_fx(
* - evolution of the L and R to Mono gain
*----------------------------------------------------------------*/
- tdm_SM_flag_loc = hStereoTD->tdm_last_SM_flag;
+ tdm_SM_flag_loc = hStereoTD->tdm_last_SM_flag; /* Q0 */
move16();
tmp_SM_flag = Get_dt_lt_ener_fx( hCPE, 0, input_frame, hStereoTD->tdm_last_SM_flag, rms_L_fx, q_rms_L, rms_R_fx, q_rms_R,
@@ -218,7 +218,7 @@ Word16 stereo_tdm_ener_analysis_fx(
IF( GT_16( q_d_lt_corr_raw, 31 ) )
{
- d_lt_corr_raw_fx = L_shr( d_lt_corr_raw_fx, sub( q_d_lt_corr_raw, Q31 ) );
+ d_lt_corr_raw_fx = L_shr( d_lt_corr_raw_fx, sub( q_d_lt_corr_raw, Q31 ) ); /* Q31 */
q_d_lt_corr_raw = Q31;
move16();
}
@@ -232,7 +232,7 @@ Word16 stereo_tdm_ener_analysis_fx(
xtalk_classifier_td_fx( hCPE );
/* switch to LRTD on cross-talk segments where two speakers are weakly correlated */
- hStereoTD->prev_fr_LRTD_TD_dec = hCPE->hStereoClassif->lrtd_mode;
+ hStereoTD->prev_fr_LRTD_TD_dec = hCPE->hStereoClassif->lrtd_mode; /* Q0 */
move16();
/*----------------------------------------------------------------*
@@ -251,7 +251,7 @@ Word16 stereo_tdm_ener_analysis_fx(
}
}
- rms_thd_fx = RMS_MIN_Q16;
+ rms_thd_fx = RMS_MIN_Q16; /* Q16 */
move32();
IF( EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) )
{
@@ -326,7 +326,7 @@ Word16 stereo_tdm_ener_analysis_fx(
move16();
}
- if ( NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) )
+ IF( NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) )
{
side_can_change = 1;
move16();
@@ -353,8 +353,8 @@ Word16 stereo_tdm_ener_analysis_fx(
test();
test();
test();
- if ( ( ( LT_32( rms_L_fx, RMS_THR_Q16 ) && LT_32( rms_R_fx, RMS_THR_Q16 ) && LT_32( L_abs( L_sub( rms_R_fx, rms_L_fx ) ), RMS_THR_Q16 / 2 ) && GT_32( L_abs( d_lt_corr_raw_fx ), L_shr( 644245094 /*0.3f in Q31*/, sub( Q31, q_d_lt_corr_raw ) ) ) ) ||
- ( LT_16( abs_s( sub( sts[0]->old_corr_fx, sts[1]->old_corr_fx ) ), 4915 /*0.15f in Q15*/ ) && GT_16( sts[0]->old_corr_fx, 22937 /*0.7f in Q15*/ ) && LT_16( sts[0]->old_corr_fx, 27853 /*0.85f in Q15*/ ) && LT_32( L_abs( L_sub( rms_L_fx, rms_R_fx ) ), rms_thd_fx ) && GT_32( L_abs( d_lt_corr_raw_fx ), L_shr( 644245094 /*0.3f in Q31*/, sub( Q31, q_d_lt_corr_raw ) ) ) ) ) /* Both channels are low energy, clean background switching is allowed */
+ IF( ( ( LT_32( rms_L_fx, RMS_THR_Q16 ) && LT_32( rms_R_fx, RMS_THR_Q16 ) && LT_32( L_abs( L_sub( rms_R_fx, rms_L_fx ) ), RMS_THR_Q16 / 2 ) && GT_32( L_abs( d_lt_corr_raw_fx ), L_shr( 644245094 /*0.3f in Q31*/, sub( Q31, q_d_lt_corr_raw ) ) ) ) ||
+ ( LT_16( abs_s( sub( sts[0]->old_corr_fx, sts[1]->old_corr_fx ) ), 4915 /*0.15f in Q15*/ ) && GT_16( sts[0]->old_corr_fx, 22937 /*0.7f in Q15*/ ) && LT_16( sts[0]->old_corr_fx, 27853 /*0.85f in Q15*/ ) && LT_32( L_abs( L_sub( rms_L_fx, rms_R_fx ) ), rms_thd_fx ) && GT_32( L_abs( d_lt_corr_raw_fx ), L_shr( 644245094 /*0.3f in Q31*/, sub( Q31, q_d_lt_corr_raw ) ) ) ) ) /* Both channels are low energy, clean background switching is allowed */
)
{
side_can_change = 1;
@@ -388,7 +388,7 @@ Word16 stereo_tdm_ener_analysis_fx(
test();
test();
- if ( GE_32( hCPE->hStereoClassif->xtalk_wscore_fx, 107374182 /*0.05f in Q31*/ ) && hStereoTD->prev_fr_LRTD_TD_dec == 0 && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) )
+ IF( GE_32( hCPE->hStereoClassif->xtalk_wscore_fx, 107374182 /*0.05f in Q31*/ ) && hStereoTD->prev_fr_LRTD_TD_dec == 0 && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) )
{
side_can_change = 0;
move16();
@@ -478,9 +478,9 @@ Word16 stereo_tdm_ener_analysis_fx(
{
test();
test();
- if ( GE_32( hCPE->element_brate, IVAS_48k ) && sts[0]->hVAD->hangover_cnt != 0 && LT_32( L_max( hStereoTD->tdm_lt_rms_L_fx, hStereoTD->tdm_lt_rms_R_fx ), 33554432 /* 512.0f */ ) )
+ IF( GE_32( hCPE->element_brate, IVAS_48k ) && sts[0]->hVAD->hangover_cnt != 0 && LT_32( L_max( hStereoTD->tdm_lt_rms_L_fx, hStereoTD->tdm_lt_rms_R_fx ), 33554432 /* 512.0f */ ) )
{
- ratio_L_fx = check_bounds_l( ratio_L_fx, 644245094 /*0.3f in Q31*/, 1503238554 /*0.7f in Q31*/ );
+ ratio_L_fx = check_bounds_l( ratio_L_fx, 644245094 /*0.3f in Q31*/, 1503238554 /*0.7f in Q31*/ ); /* Q31 */
}
test();
@@ -512,7 +512,7 @@ Word16 stereo_tdm_ener_analysis_fx(
}
}
- idx = stereo_smooth_LR_transition_fx( &hStereoTD->tdm_prev_stable_idx, &hStereoTD->tdm_ratio_transition_mov_flag, hStereoTD->tdm_last_ratio_idx, &hStereoTD->tdm_prev_desired_idx, &hStereoTD->tdm_ratio_transition_cnt, tdm_SM_flag_loc, desired_idx );
+ idx = stereo_smooth_LR_transition_fx( &hStereoTD->tdm_prev_stable_idx, &hStereoTD->tdm_ratio_transition_mov_flag, hStereoTD->tdm_last_ratio_idx, &hStereoTD->tdm_prev_desired_idx, &hStereoTD->tdm_ratio_transition_cnt, tdm_SM_flag_loc, desired_idx ); /* Q0 */
/* Change the switching level in case of dual mono (in case the scenario still accept left right switching */
/* This logic is needed in case the content is exactly the same in the 2 channel and it is expected to get back to LRTD, to prevent the secondary channel to be completely empty */
@@ -577,19 +577,19 @@ Word16 stereo_tdm_ener_analysis_fx(
Word16 idx_offet;
idx_offet = 5;
move16();
- if ( GT_16( desired_idx, LRTD_STEREO_MID_IS_PRIM ) ) /* slightly Favor the 2nd channel */
+ IF( GT_16( desired_idx, LRTD_STEREO_MID_IS_PRIM ) ) /* slightly Favor the 2nd channel */
{
idx_offet = negate( idx_offet );
}
desired_idx = add( desired_idx, idx_offet );
- desired_idx = check_bounds_s_fx( desired_idx, 0, 30 );
+ desired_idx = check_bounds_s_fx( desired_idx, 0, 30 ); /* Q0 */
}
}
test();
IF( sts[1]->clas != UNVOICED_CLAS || sts[0]->clas != UNVOICED_CLAS )
{
- desired_idx = check_bounds_s_fx( desired_idx, 5, 25 );
+ desired_idx = check_bounds_s_fx( desired_idx, 5, 25 ); /* Q0 */
}
hStereoTD->tdm_inst_ratio_idx = desired_idx;
@@ -673,9 +673,9 @@ Word16 stereo_tdm_ener_analysis_fx(
move32();
hStereoTD->tdm_lt_corr_LM_SM_fx = 167772 /*0.01f Q24*/;
move32();
- hStereoTD->tdm_last_ratio_SM_fx = hStereoTD->tdm_last_ratio_fx;
+ hStereoTD->tdm_last_ratio_SM_fx = hStereoTD->tdm_last_ratio_fx; /* Q31 */
move32();
- hStereoTD->tdm_last_ratio_idx_SM = hStereoTD->tdm_last_ratio_idx;
+ hStereoTD->tdm_last_ratio_idx_SM = hStereoTD->tdm_last_ratio_idx; /* Q0 */
move16();
hStereoTD->tdm_lt_rms_L_SM_fx = 2621440; // 40.0f Q16
move32();
@@ -706,7 +706,7 @@ Word16 stereo_tdm_ener_analysis_fx(
move16();
}
- *tdm_ratio_idx_SM = stereo_tdm_ener_analysis_SM_fx( hCPE, sts, input_frame, &tdm_NOOP_flag );
+ *tdm_ratio_idx_SM = stereo_tdm_ener_analysis_SM_fx( hCPE, sts, input_frame, &tdm_NOOP_flag ); /* Q0 */
move16();
}
ELSE
@@ -723,15 +723,15 @@ Word16 stereo_tdm_ener_analysis_fx(
move16();
/* set channel combination scheme flag */
- *tdm_SM_or_LRTD_Pri = tdm_SM_flag_loc;
+ *tdm_SM_or_LRTD_Pri = tdm_SM_flag_loc; /* Q0 */
move16();
if ( EQ_16( hCPE->hStereoTD->tdm_LRTD_flag, 1 ) )
{
- *tdm_SM_or_LRTD_Pri = tdm_LRTD_pri_side;
+ *tdm_SM_or_LRTD_Pri = tdm_LRTD_pri_side; /* Q0 */
move16();
}
- hCPE->hStereoClassif->ratio_L_fx = ratio_L_fx;
+ hCPE->hStereoClassif->ratio_L_fx = ratio_L_fx; /* Q15 */
move32();
return idx;
@@ -744,12 +744,12 @@ Word16 stereo_tdm_ener_analysis_fx(
*-------------------------------------------------------------------*/
static void Get_LR_rms_fx(
- const Word16 *Left_in,
- const Word16 *Right_in,
- const Word16 input_frame,
- Word32 *rms_L,
+ const Word16 *Left_in, /* q_inp */
+ const Word16 *Right_in, /* q_inp */
+ const Word16 input_frame, /* Q0 */
+ Word32 *rms_L, /* q_rms_L */
Word16 *q_rms_L,
- Word32 *rms_R,
+ Word32 *rms_R, /* q_rms_R */
Word16 *q_rms_R )
{
Word32 ener_l, ener_r;
@@ -763,9 +763,9 @@ static void Get_LR_rms_fx(
move64();
W_ener_r_tmp = 0;
move64();
- ener_l = ONE_BY_100_Q31;
+ ener_l = ONE_BY_100_Q31; /* Q31 */
move32();
- ener_r = ONE_BY_100_Q31;
+ ener_r = ONE_BY_100_Q31; /* Q31 */
move32();
guard_bits = sub( 32, find_guarded_bits_fx( input_frame ) );
@@ -778,12 +778,12 @@ static void Get_LR_rms_fx(
ener_l_tmp = W_extract_h( W_shl( W_ener_l_tmp, guard_bits ) ); // guard_bits - 32
ener_r_tmp = W_extract_h( W_shl( W_ener_r_tmp, guard_bits ) ); // guard_bits - 32
- ener_l = BASOP_Util_Add_Mant32Exp( ener_l, 0, ener_l_tmp, sub( Q31, sub( guard_bits, 32 ) ), &exp_out_l );
- ener_r = BASOP_Util_Add_Mant32Exp( ener_r, 0, ener_r_tmp, sub( Q31, sub( guard_bits, 32 ) ), &exp_out_r );
+ ener_l = BASOP_Util_Add_Mant32Exp( ener_l, 0, ener_l_tmp, sub( Q31, sub( guard_bits, 32 ) ), &exp_out_l ); /* Q31-exp_out_l */
+ ener_r = BASOP_Util_Add_Mant32Exp( ener_r, 0, ener_r_tmp, sub( Q31, sub( guard_bits, 32 ) ), &exp_out_r ); /* Q31-exp_out_r */
- ener_l_tmp = BASOP_Util_Divide3232_Scale( ener_l, input_frame, &exp_diff );
+ ener_l_tmp = BASOP_Util_Divide3232_Scale( ener_l, input_frame, &exp_diff ); /* Q31- exp_out_l*/
exp_out_l = sub( add( exp_diff, exp_out_l ), Q15 );
- ener_r_tmp = BASOP_Util_Divide3232_Scale( ener_r, input_frame, &exp_diff );
+ ener_r_tmp = BASOP_Util_Divide3232_Scale( ener_r, input_frame, &exp_diff ); /* Q31-exp_out_r */
exp_out_r = sub( add( exp_diff, exp_out_r ), Q15 );
*rms_L = Sqrt32( ener_l_tmp, &exp_out_l ); // Q31 - exp_out_l
@@ -811,25 +811,25 @@ static void Get_LR_rms_fx(
static Word16 Get_dt_lt_ener_fx(
CPE_ENC_HANDLE hCPE,
- const Word16 IsSideMono,
- const Word16 input_frame,
- const Word16 tdm_last_SM_flag,
- const Word32 rms_L,
+ const Word16 IsSideMono, /* Q0 */
+ const Word16 input_frame, /* Q0 */
+ const Word16 tdm_last_SM_flag, /* Q0 */
+ const Word32 rms_L, /* q_rms_L */
const Word16 q_rms_L,
- const Word32 rms_R,
+ const Word32 rms_R, /* q_rms_R */
const Word16 q_rms_R,
- Word32 *tdm_lt_rms_L,
- Word32 *tdm_lt_rms_R,
- Word32 *tdm_last_ener_lt_L,
- Word32 *tdm_last_ener_lt_R,
- Word32 *tdm_LT_es_em,
- Word16 *tdm_hyst_cnt,
- Word16 *tdm_NOOP_SM_flag_loc,
- Word32 *ener_R_dt,
- Word32 *ener_L_dt,
- Word32 *corr_LM,
+ Word32 *tdm_lt_rms_L, /* Q16 */
+ Word32 *tdm_lt_rms_R, /* Q16 */
+ Word32 *tdm_last_ener_lt_L, /* Q16 */
+ Word32 *tdm_last_ener_lt_R, /* Q16 */
+ Word32 *tdm_LT_es_em, /* Q21 */
+ Word16 *tdm_hyst_cnt, /* Q0 */
+ Word16 *tdm_NOOP_SM_flag_loc, /* Q0 */
+ Word32 *ener_R_dt, /* Q16 */
+ Word32 *ener_L_dt, /* Q16 */
+ Word32 *corr_LM, /* q_corr_LM */
Word16 *q_corr_LM,
- Word32 *corr_RM,
+ Word32 *corr_RM, /* q_corr_RM */
Word16 *q_corr_RM )
{
Encoder_State **sts;
@@ -841,27 +841,27 @@ static Word16 Get_dt_lt_ener_fx(
sts = hCPE->hCoreCoder;
- Left_in_fx = sts[0]->input_fx; /* Left channel */
- Right_in_fx = sts[1]->input_fx; /* Right channel */
+ Left_in_fx = sts[0]->input_fx; /* Left channel sts[0]->q_inp*/
+ Right_in_fx = sts[1]->input_fx; /* Right channel sts[1]->q_inp*/
tmp = sub( getScaleFactor16( sts[0]->input_fx, input_frame ), 1 );
- Scale_sig( sts[0]->input_fx, input_frame, tmp );
+ Scale_sig( sts[0]->input_fx, input_frame, tmp ); /* sts[0]->q_inp + tmp */
sts[0]->q_inp = add( tmp, sts[0]->q_inp );
move16();
tmp = getScaleFactor16( sts[1]->input_fx, input_frame );
- Scale_sig( sts[1]->input_fx, input_frame, tmp );
+ Scale_sig( sts[1]->input_fx, input_frame, tmp ); /* sts[1]->q_inp + tmp */
sts[1]->q_inp = add( tmp, sts[1]->q_inp );
move16();
- Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[1]->q_inp ), sts[0]->q_inp ) );
- Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[1]->q_inp ), sts[1]->q_inp ) );
+ Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[1]->q_inp ), sts[0]->q_inp ) ); /* s_min( sts[0]->q_inp, sts[1]->q_inp ) */
+ Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[1]->q_inp ), sts[1]->q_inp ) ); /* s_min( sts[0]->q_inp, sts[1]->q_inp ) */
sts[1]->q_inp = s_min( sts[0]->q_inp, sts[1]->q_inp );
move16();
sts[0]->q_inp = sts[1]->q_inp;
move16();
- tdm_SM_flag_loc = tdm_last_SM_flag;
+ tdm_SM_flag_loc = tdm_last_SM_flag; /* Q0 */
move16();
test();
@@ -916,7 +916,7 @@ static Word16 Get_dt_lt_ener_fx(
Get_corr_n_fx( Left_in_fx, Right_in_fx, corr_LM, q_corr_LM, corr_RM, q_corr_RM, input_frame, &es_em_fx, IsSideMono );
- hCPE->hStereoClassif->xtalk_fv_fx[E_diff_corrLM_corrRM] = BASOP_Util_Add_Mant32Exp( *corr_LM, sub( Q31, *q_corr_LM ), L_negate( *corr_RM ), sub( Q31, *q_corr_RM ), &exp_diff );
+ hCPE->hStereoClassif->xtalk_fv_fx[E_diff_corrLM_corrRM] = BASOP_Util_Add_Mant32Exp( *corr_LM, sub( Q31, *q_corr_LM ), L_negate( *corr_RM ), sub( Q31, *q_corr_RM ), &exp_diff ); /* Q31-exp_diff */
move32();
hCPE->hStereoClassif->xtalk_fv_fx[E_diff_corrLM_corrRM] = L_shl( hCPE->hStereoClassif->xtalk_fv_fx[E_diff_corrLM_corrRM], sub( Q15, sub( Q31, exp_diff ) ) ); // Q15
move32();
@@ -937,8 +937,15 @@ static Word16 Get_dt_lt_ener_fx(
tmp_SM_flag = 0;
move16();
- if ( LT_16( s_min( sts[0]->old_corr_fx, sts[1]->old_corr_fx ), 27853 /* 0.85f in Q15 */ ) && LT_16( s_max( sts[0]->old_corr_fx, sts[1]->old_corr_fx ), 30147 /* 0.92f in Q15 */ ) &&
- ( GT_32( *tdm_LT_es_em, ONE_IN_Q22 /* 2.0f in Q21 */ ) || GT_32( es_em_fx, 5242880 /* 2.5f in Q21 */ ) ) && ( LE_16( sts[0]->hVAD->hangover_cnt, 1 ) && LE_16( sts[1]->hVAD->hangover_cnt, 3 ) && sts[0]->tdm_LRTD_flag == 0 ) )
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( LT_16( s_min( sts[0]->old_corr_fx, sts[1]->old_corr_fx ), 27853 /* 0.85f in Q15 */ ) && LT_16( s_max( sts[0]->old_corr_fx, sts[1]->old_corr_fx ), 30147 /* 0.92f in Q15 */ ) &&
+ ( GT_32( *tdm_LT_es_em, ONE_IN_Q22 /* 2.0f in Q21 */ ) || GT_32( es_em_fx, 5242880 /* 2.5f in Q21 */ ) ) && ( LE_16( sts[0]->hVAD->hangover_cnt, 1 ) && LE_16( sts[1]->hVAD->hangover_cnt, 3 ) && sts[0]->tdm_LRTD_flag == 0 ) )
{
tmp_SM_flag = 1;
move16();
@@ -951,6 +958,9 @@ static Word16 Get_dt_lt_ener_fx(
IF( NE_16( tmp_SM_flag, tdm_SM_flag_loc ) )
{
+ test();
+ test();
+ test();
IF( GE_16( *tdm_hyst_cnt, 2 ) && EQ_16( tmp_SM_flag, 1 ) && ( GT_16( sts[0]->tdm_pc, PC_LIMIT ) || GT_16( sts[1]->tdm_pc, PC_LIMIT ) ) )
{
tdm_hyst_cnt++;
@@ -975,7 +985,7 @@ static Word16 Get_dt_lt_ener_fx(
move16();
}
- return tmp_SM_flag;
+ return tmp_SM_flag; /* Q0 */
}
@@ -987,13 +997,13 @@ static Word16 Get_dt_lt_ener_fx(
static void NOOP_decision_fx(
CPE_ENC_HANDLE hCPE,
- const Word16 tdm_NOOP_flag_loc,
- const Word16 tmp_SM_flag,
- const Word32 rms_L,
+ const Word16 tdm_NOOP_flag_loc, /* Q0 */
+ const Word16 tmp_SM_flag, /* Q0 */
+ const Word32 rms_L, /* q_rms_L */
const Word16 q_rms_L,
- const Word32 rms_R,
+ const Word32 rms_R, /* q_rms_R */
const Word16 q_rms_R,
- Word16 *tdm_SM_flag_loc )
+ Word16 *tdm_SM_flag_loc /* Q0 */ )
{
Word16 tdm_NOOP_switch_flag;
STEREO_TD_ENC_DATA_HANDLE hStereoTD;
@@ -1008,6 +1018,14 @@ static void NOOP_decision_fx(
move16();
IF( hCPE->hCoreCoder[0]->sp_aud_decision0 == 0 )
{
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
IF( ( ( GT_16( hStereoTD->tdm_SM_last2_clas[0], VOICED_TRANSITION ) && ( hStereoTD->tdm_SM_last_clas[0] == UNVOICED_CLAS || EQ_16( hStereoTD->tdm_SM_last_clas[0], VOICED_TRANSITION ) ) ) ||
( GT_16( hStereoTD->tdm_SM_last2_clas[1], VOICED_TRANSITION ) && ( hStereoTD->tdm_SM_last_clas[1] == UNVOICED_CLAS || EQ_16( hStereoTD->tdm_SM_last_clas[1], VOICED_TRANSITION ) ) ) ) &&
( !( EQ_16( sts[0]->last_coder_type_raw, VOICED ) || EQ_16( sts[1]->last_coder_type_raw, VOICED ) ) && GT_16( hStereoTD->tdm_NOOP_cnt, 5 ) ) )
@@ -1082,6 +1100,8 @@ static void NOOP_decision_fx(
}
}
+ test();
+ test();
IF( GT_16( hStereoTD->tdm_SM_flag, 0 ) && EQ_16( tdm_NOOP_switch_flag, 1 ) && NE_16( *tdm_SM_flag_loc, tmp_SM_flag ) )
{
*tdm_SM_flag_loc = !( *tdm_SM_flag_loc );
@@ -1130,25 +1150,25 @@ static void NOOP_decision_fx(
static Word32 Comp_diff_lt_corr_fx(
CPE_ENC_HANDLE hCPE,
- const Word16 IsSideMono,
- const Word32 rms_L,
+ const Word16 IsSideMono, /* Q0 */
+ const Word32 rms_L, /* q_rms_L */
const Word16 q_rms_L,
- const Word32 rms_R,
+ const Word32 rms_R, /* q_rms_R */
const Word16 q_rms_R,
- const Word32 ener_L_dt,
- const Word32 ener_R_dt,
- Word32 corr_LM,
+ const Word32 ener_L_dt, /* Q16 */
+ const Word32 ener_R_dt, /* Q16 */
+ Word32 corr_LM, /* q_corr_LM */
Word16 q_corr_LM,
- Word32 corr_RM,
+ Word32 corr_RM, /* q_corr_RM */
Word16 q_corr_RM,
- const Word32 tdm_lt_rms_L,
- const Word32 tdm_lt_rms_R,
- Word32 *tdm_lt_corr_LM,
- Word32 *tdm_lt_corr_RM,
- Word32 *tdm_last_diff_lt_corr,
+ const Word32 tdm_lt_rms_L, /* Q16 */
+ const Word32 tdm_lt_rms_R, /* Q16 */
+ Word32 *tdm_lt_corr_LM, /* Q24 */
+ Word32 *tdm_lt_corr_RM, /* Q24 */
+ Word32 *tdm_last_diff_lt_corr, /* q_tdm_last_diff_lt_corr */
Word16 *q_tdm_last_diff_lt_corr,
- Word32 *inst_ratio_L_out,
- Word32 *diff_lt_corr,
+ Word32 *inst_ratio_L_out, /* Q24 */
+ Word32 *diff_lt_corr, /* q_d_lt_corr_raw */
Word16 *q_d_lt_corr_raw )
{
Encoder_State **sts;
@@ -1177,7 +1197,9 @@ static Word32 Comp_diff_lt_corr_fx(
* adaptation rate factor is lower. This prevent stereo image
* move on speech offset
*----------------------------------------------------------------*/
-
+ test();
+ test();
+ test();
IF( IsSideMono == 0 && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) && ( GT_32( L_shr( tdm_lt_rms_R, Q1 ), tdm_lt_rms_L ) || GT_32( L_shr( tdm_lt_rms_L, Q1 ), tdm_lt_rms_R ) ) )
{
adaprate_fx = L_add( Mpy_32_32( M_ADAP_FX_Q31, L_max( tdm_lt_rms_R, tdm_lt_rms_L ) ), B_ADAP_FX_Q16 ); // Q16
@@ -1193,7 +1215,10 @@ static Word32 Comp_diff_lt_corr_fx(
* In case of unvoiced content (expect when it is part of an onset),
* the adaptation rate is minimal.
*----------------------------------------------------------------*/
-
+ test();
+ test();
+ test();
+ test();
IF( GT_16( sts[0]->ini_frame, 2 ) &&
( ( LE_16( sts[0]->last_clas, VOICED_TRANSITION ) && sts[0]->hVAD->hangover_cnt == 0 ) ||
( LE_16( sts[1]->last_clas, VOICED_TRANSITION ) && sts[1]->hVAD->hangover_cnt == 0 ) ) )
@@ -1203,9 +1228,14 @@ static Word32 Comp_diff_lt_corr_fx(
d_lt_corr_raw_fx = 0;
move32();
+
IF( IsSideMono == 0 )
{
- if ( NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) || ( ( LT_32( tdm_lt_rms_R, ONE_IN_Q16 ) || LT_32( tdm_lt_rms_L, ONE_IN_Q16 ) ) && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) && LT_32( L_max( tdm_lt_rms_R, tdm_lt_rms_L ), TEN_IN_Q16 ) ) )
+ test();
+ test();
+ test();
+ test();
+ IF( NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) || ( ( LT_32( tdm_lt_rms_R, ONE_IN_Q16 ) || LT_32( tdm_lt_rms_L, ONE_IN_Q16 ) ) && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) && LT_32( L_max( tdm_lt_rms_R, tdm_lt_rms_L ), TEN_IN_Q16 ) ) )
{
adaprate_fx = 64225; /* 0.98f in Q16 */ /* speed up the adaptation of the long term values to the current values after coming from DFT */
move32();
@@ -1242,13 +1272,13 @@ static Word32 Comp_diff_lt_corr_fx(
corr_LM = BASOP_Util_Add_Mant32Exp( Mpy_32_32( adaprate_fx, corr_LM ), sub( Q31, sub( q_corr_LM, Q15 ) ), Mpy_32_32( madaprate_fx, *tdm_lt_corr_LM ), Q31 - Q9, &exp_diff ); // Q31 - exp_diff
q_corr_LM = sub( Q31, exp_diff );
- L_tmp = Mpy_32_32( ALP_REF_FX_Q31, *tdm_lt_corr_LM ); // Q24
- L_tmp1 = Mpy_32_32( BET_REF_FX_Q31, corr_LM ); // q_corr_LM
- diff_lt_corr_LM_tmp_fx = BASOP_Util_Add_Mant32Exp( L_tmp, Q31 - Q24, L_tmp1, sub( Q31, q_corr_LM ), &exp_diff );
+ L_tmp = Mpy_32_32( ALP_REF_FX_Q31, *tdm_lt_corr_LM ); // Q24
+ L_tmp1 = Mpy_32_32( BET_REF_FX_Q31, corr_LM ); // q_corr_LM
+ diff_lt_corr_LM_tmp_fx = BASOP_Util_Add_Mant32Exp( L_tmp, Q31 - Q24, L_tmp1, sub( Q31, q_corr_LM ), &exp_diff ); /* Q31-exp_diff */
q_diff_lt_corr_LM_tmp = sub( Q31, exp_diff );
- L_tmp = Mpy_32_32( ALP_REF_FX_Q31, *tdm_lt_corr_RM ); // Q24
- L_tmp1 = Mpy_32_32( BET_REF_FX_Q31, corr_RM ); // q_corr_RM
- diff_lt_corr_RM_tmp_fx = BASOP_Util_Add_Mant32Exp( L_tmp, Q31 - Q24, L_tmp1, sub( Q31, q_corr_RM ), &exp_diff );
+ L_tmp = Mpy_32_32( ALP_REF_FX_Q31, *tdm_lt_corr_RM ); // Q24
+ L_tmp1 = Mpy_32_32( BET_REF_FX_Q31, corr_RM ); // q_corr_RM
+ diff_lt_corr_RM_tmp_fx = BASOP_Util_Add_Mant32Exp( L_tmp, Q31 - Q24, L_tmp1, sub( Q31, q_corr_RM ), &exp_diff ); /* Q31-exp_diff */
q_diff_lt_corr_RM_tmp = sub( Q31, exp_diff );
diff_lt_corr_tmp_fx = BASOP_Util_Add_Mant32Exp( diff_lt_corr_LM_tmp_fx, sub( Q31, q_diff_lt_corr_LM_tmp ), L_negate( diff_lt_corr_RM_tmp_fx ), sub( Q31, q_diff_lt_corr_RM_tmp ), &exp_diff ); // (Q31 - exp_diff)
q_diff_lt_corr_tmp = sub( Q31, exp_diff );
@@ -1267,7 +1297,7 @@ static Word32 Comp_diff_lt_corr_fx(
move16();
shift = sub( q_d_lt_corr, Q31 );
}
- *tdm_last_diff_lt_corr = diff_lt_corr_tmp_fx;
+ *tdm_last_diff_lt_corr = diff_lt_corr_tmp_fx; /* q_tdm_last_diff_lt_corr */
move32();
*q_tdm_last_diff_lt_corr = q_diff_lt_corr_tmp;
move16();
@@ -1275,7 +1305,18 @@ static Word32 Comp_diff_lt_corr_fx(
/*----------------------------------------------------------------*
* Correct the estimation depending of channels energies evolution
*----------------------------------------------------------------*/
-
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
IF( EQ_16( IsSideMono, 1 ) &&
( ( LT_32( L_shl( rms_L, sub( Q21, q_rms_L ) ), RMS_MIN2_FX_Q21 ) &&
LT_32( L_shl( rms_R, sub( Q21, q_rms_R ) ), RMS_MIN2_FX_Q21 ) ) &&
@@ -1307,9 +1348,9 @@ static Word32 Comp_diff_lt_corr_fx(
)
{
/* Use estimated results */
- *tdm_lt_corr_LM = L_shl( diff_lt_corr_LM_tmp_fx, sub( Q24, q_diff_lt_corr_LM_tmp ) );
+ *tdm_lt_corr_LM = L_shl( diff_lt_corr_LM_tmp_fx, sub( Q24, q_diff_lt_corr_LM_tmp ) ); /* Q24 */
move32();
- *tdm_lt_corr_RM = L_shl( diff_lt_corr_RM_tmp_fx, sub( Q24, q_diff_lt_corr_RM_tmp ) );
+ *tdm_lt_corr_RM = L_shl( diff_lt_corr_RM_tmp_fx, sub( Q24, q_diff_lt_corr_RM_tmp ) ); /* Q24 */
move32();
}
ELSE
@@ -1340,23 +1381,26 @@ static Word32 Comp_diff_lt_corr_fx(
*-------------------------------------------------------------------*/
static Word16 limit_idx_Dwnmix_fx(
- const Word16 idx_in,
- const Word16 unclr_decision,
- const Word16 inst_idx,
- const Word16 previous_idx,
- const Word16 tdm_last_LRTD_PriCh_cnt,
- const Word16 tdm_last_LRTD_frame_cnt )
+ const Word16 idx_in, /* Q0 */
+ const Word16 unclr_decision, /* Q0 */
+ const Word16 inst_idx, /* Q0 */
+ const Word16 previous_idx, /* Q0 */
+ const Word16 tdm_last_LRTD_PriCh_cnt, /* Q0 */
+ const Word16 tdm_last_LRTD_frame_cnt /* Q0 */ )
{
Word16 idx;
idx = idx_in;
move16();
- idx = check_bounds_s_fx( idx, 1, 29 );
+ idx = check_bounds_s_fx( idx, 1, 29 ); /* Q0 */
+ test();
IF( EQ_16( unclr_decision, 1 ) && GT_16( tdm_last_LRTD_frame_cnt, 1 ) )
{
IF( tdm_last_LRTD_PriCh_cnt > 0 )
{
+ test();
+ test();
IF( LE_16( idx, LRTD_STEREO_MID_IS_PRIM ) && LT_16( inst_idx, LRTD_STEREO_MID_IS_PRIM + 2 ) )
{
idx = s_min( 1, idx );
@@ -1386,7 +1430,7 @@ static Word16 limit_idx_Dwnmix_fx(
}
}
- return idx;
+ return idx; /* Q0 */
}
@@ -1396,9 +1440,9 @@ static Word16 limit_idx_Dwnmix_fx(
*-------------------------------------------------------------------*/
static Word16 limit_idx_NoDwnmix_fx(
- const Word16 idx_in, /* i : Index */
- const Word16 side_can_change, /* i : Primary and secondary channel allowed to change ? */
- const Word32 d_lt_corr_raw, /* i : Raw corrrelation differences */
+ const Word16 idx_in, /* i : Index Q0*/
+ const Word16 side_can_change, /* i : Primary and secondary channel allowed to change ? Q0*/
+ const Word32 d_lt_corr_raw, /* i : Raw corrrelation differences q_d_lt_corr_raw*/
const Word16 q_d_lt_corr_raw /* i : Q-factor of Raw corrrelation differences */
)
{
@@ -1406,11 +1450,14 @@ static Word16 limit_idx_NoDwnmix_fx(
idx = idx_in;
move16();
+
+ test();
+ test();
IF( side_can_change == 0 && GT_16( idx_in, 10 ) && LT_16( idx_in, 20 ) )
{
idx = 30;
move16();
- if ( LT_32( d_lt_corr_raw, L_negate( L_shl( 214748365 /* 0.1f in Q31 */, sub( q_d_lt_corr_raw, Q31 ) ) ) ) )
+ IF( LT_32( d_lt_corr_raw, L_negate( L_shl( 214748365 /* 0.1f in Q31 */, sub( q_d_lt_corr_raw, Q31 ) ) ) ) )
{
idx = 0;
move16();
@@ -1430,7 +1477,7 @@ static Word16 limit_idx_NoDwnmix_fx(
}
}
- return idx;
+ return idx; /* Q0 */
}
@@ -1443,8 +1490,8 @@ static Word16 limit_idx_NoDwnmix_fx(
static Word16 stereo_tdm_ener_analysis_SM_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
Encoder_State **sts, /* i/o: Encoder static variables structure */
- const Word16 input_frame, /* i : Number of samples */
- Word16 *tdm_SM_flag /* i/o: channel combination scheme flag */
+ const Word16 input_frame, /* i : Number of samples Q0*/
+ Word16 *tdm_SM_flag /* i/o: channel combination scheme flag Q0*/
)
{
Word32 rms_R_fx, rms_L_fx;
@@ -1473,7 +1520,7 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
*----------------------------------------------------------------*/
/* Simple logic to set SM flag, should be done in the frequency domain for low SM correlation signal, especially for music item such as Music_1_org_s */
- tdm_SM_flag_loc = hStereoTD->tdm_last_SM_flag_noop;
+ tdm_SM_flag_loc = hStereoTD->tdm_last_SM_flag_noop; /* Q0 */
move16();
/*----------------------------------------------------------------*
@@ -1515,27 +1562,38 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
* When the energies of channels are low enough, compute the ratio
* of L and R needed to create new mono/side signals
*----------------------------------------------------------------*/
-
+ test();
+ test();
+ test();
IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) ||
- ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) )
+ ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) ) /* Q20 */
{
- if ( ( LT_16( sts[0]->old_corr_fx, CORR_THRES_FX_Q15 ) && LT_16( sts[1]->old_corr_fx, CORR_THRES_FX_Q15 ) ) ||
- ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) ) )
+ test();
+ test();
+ test();
+ IF( ( LT_16( sts[0]->old_corr_fx, CORR_THRES_FX_Q15 ) && LT_16( sts[1]->old_corr_fx, CORR_THRES_FX_Q15 ) ) ||
+ ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) ) )
{
side_can_change = 1;
move16();
}
}
+ test();
+ test();
+ test();
IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) ||
- ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) )
+ ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) ) /* Q21 */
{
+ test();
+ test();
+ test();
IF( ( ( NE_16( hStereoTD->tdm_last_SM_flag_noop, tdm_SM_flag_loc ) ) && hStereoTD->tdm_noop_cnt == 0 ) ||
EQ_16( hStereoTD->tdm_noop_mov_flag, 1 ) || NE_16( hStereoTD->tdm_prev_desired_idx_SM, hStereoTD->tdm_prev_stable_idx_SM ) )
{
hStereoTD->tdm_noop_mov_flag = 1;
move16();
- if ( hStereoTD->tdm_last_ratio_idx_SM != 0 && NE_16( hStereoTD->tdm_last_ratio_idx_SM, ( TDM_NQ - 1 ) ) )
+ IF( hStereoTD->tdm_last_ratio_idx_SM != 0 && NE_16( hStereoTD->tdm_last_ratio_idx_SM, ( TDM_NQ - 1 ) ) )
{
side_can_change = 1;
move16();
@@ -1543,7 +1601,8 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
}
}
- if ( side_can_change == 0 && EQ_16( tdm_SM_flag_loc, 1 ) && GT_32( es_em_fx, 31457280 /* 15.0f in Q21 */ ) )
+ test();
+ IF( side_can_change == 0 && EQ_16( tdm_SM_flag_loc, 1 ) && GT_32( es_em_fx, 31457280 /* 15.0f in Q21 */ ) )
{
side_can_change = 1;
move16();
@@ -1584,7 +1643,7 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
}
}
- idx = stereo_smooth_LR_transition_fx( &hStereoTD->tdm_prev_stable_idx_SM, &hStereoTD->tdm_noop_mov_flag, hStereoTD->tdm_last_ratio_idx_SM, &hStereoTD->tdm_prev_desired_idx_SM, &hStereoTD->tdm_noop_cnt, tdm_SM_flag_loc, desired_idx );
+ idx = stereo_smooth_LR_transition_fx( &hStereoTD->tdm_prev_stable_idx_SM, &hStereoTD->tdm_noop_mov_flag, hStereoTD->tdm_last_ratio_idx_SM, &hStereoTD->tdm_prev_desired_idx_SM, &hStereoTD->tdm_noop_cnt, tdm_SM_flag_loc, desired_idx ); /* Q0 */
idx = extract_l( L_add( Mpy_32_32( 1717986918 /* 0.8f in Q31 */, idx ), Mpy_32_32( 429496729 /* 0.2f in Q31 */, hStereoTD->tdm_last_ratio_idx_SM ) ) ); // (Q31, Q0) -> Q0
@@ -1598,6 +1657,9 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
move16();
}
+ test();
+ test();
+ test();
IF( ( EQ_16( hStereoTD->tdm_noop_mov_flag, 1 ) && GE_16( hStereoTD->tdm_noop_cnt, 31 ) ) || ( ( EQ_16( hStereoTD->tdm_last_SM_flag_noop, tdm_SM_flag_loc ) ) && ( EQ_16( idx, hStereoTD->tdm_prev_stable_idx_SM ) ) ) )
{
hStereoTD->tdm_noop_cnt = 0;
@@ -1606,6 +1668,7 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
move16();
}
+ test();
if ( hStereoTD->tdm_noop_mov_flag == 0 || tdm_SM_flag_loc == 0 )
{
hStereoTD->tdm_prev_stable_idx_SM = idx;
@@ -1634,11 +1697,11 @@ Word16 tdm_lp_comparison_fx(
Word32 *speech_buff, /* i : Current speech frame Q_speech */
const Word16 *A_PCh_fx, /* i : primary channel LP coefficients Q12*/
const Word16 *A_SCh_fx, /* i : secondary channel LP coeff. Q12*/
- const Word16 m, /* i : filter length */
+ const Word16 m, /* i : filter length Q0*/
const Word16 *isp_PCh_fx, /* i : primary channel LSPs Q15 */
const Word16 *isp_SCh_fx, /* i : secondary channel LSPs Q15 */
- const Word16 L_frame, /* i : frame length */
- const Word32 element_brate_wo_meta, /* i : element bitrate without metadata*/
+ const Word16 L_frame, /* i : frame length Q0*/
+ const Word32 element_brate_wo_meta, /* i : element bitrate without metadata Q0*/
Word16 Q_speech )
{
Word32 ener_sig_fx, pred_gain_reuse_PCh_fx, log10_fx, predgain_SCh_fx;
@@ -1657,7 +1720,7 @@ Word16 tdm_lp_comparison_fx(
// residu( A_SCh, m, speech, res, L_frame );
Word16 gb = find_guarded_bits_fx( L_frame );
- scale_sig32( speech_buff, L_FRAME + M, gb1 );
+ scale_sig32( speech_buff, L_FRAME + M, gb1 ); /* Q_speech + gb1 */
Word16 exp = sub( 31, Q_speech );
Word32 sum2_value = sum2_32_exp_fx( speech_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb
IF( LT_16( exp, -5 ) ) /*maximum q to prevent 0.01 from saturating is 37, since we are adding it headroom of 1 is required*/
@@ -1666,28 +1729,28 @@ Word16 tdm_lp_comparison_fx(
exp = -5;
move16();
}
- sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q31 - Q15, &exp );
- Word32 temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) );
- ener_sig_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
+ sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q16, &exp ); /* Q31-exp */
+ Word32 temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) ); /* Q25 */
+ ener_sig_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
// ener_sig = log10f( sum2_f( speech, L_frame ) + 0.01f );
exp = sub( 31, sub( Q_speech, gb1 ) );
- sum2_value = sum2_32_exp_fx( res_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb
- sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q31 - Q15, &exp );
- temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) );
- log10_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
- predgain_SCh_fx = Mpy_32_32( L_sub( ener_sig_fx, log10_fx ), 1342177280 ); // Q27+Q25-31 = Q21
+ sum2_value = sum2_32_exp_fx( res_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb
+ sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q16, &exp ); /* Q31-exp */
+ temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) ); /* Q25 */
+ log10_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
+ predgain_SCh_fx = Mpy_32_32( L_sub( ener_sig_fx, log10_fx ), 1342177280 ); // Q27+Q25-31 = Q21
// pred_gain_reuse_PCh = 10.0f * ( ener_sig - log10f( sum2_f( res, L_frame ) + 0.01f ) );
// predgain_SCh = 10.0f * ( ener_sig - log10f( sum2_f( res, L_frame ) + 0.01f ) );
/* Find prediction gain when resuing the Primary Channel LP filter */
// residu( A_PCh, m, speech, res, L_frame );
- scale_sig32( speech_buff, L_FRAME + M, negate( gb1 ) );
+ scale_sig32( speech_buff, L_FRAME + M, negate( gb1 ) ); /* Q_speech */
residu_ivas_fx( A_PCh_fx, sub( 14, norm_s( A_PCh_fx[0] ) ), m, speech_fx, res_fx, L_frame );
exp = sub( 31, sub( Q_speech, gb1 ) );
sum2_value = sum2_32_exp_fx( res_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb
- sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q31 - Q15, &exp );
- temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) );
- log10_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
+ sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q16, &exp );
+ temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) ); /* Q25 */
+ log10_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
pred_gain_reuse_PCh_fx = Mpy_32_32( L_sub( ener_sig_fx, log10_fx ), 1342177280 ); // Q27+Q25-31 = Q21
// pred_gain_reuse_PCh = 10.0f * ( ener_sig - log10f( sum2_f( res, L_frame ) + 0.01f ) );
@@ -1699,7 +1762,7 @@ Word16 tdm_lp_comparison_fx(
FOR( i = 0; i < m; i++ )
{
// ftmp = isp_SCh[i] - isp_PCh[i];
- ftmp_fx = L_deposit_h( sub( isp_SCh_fx[i], isp_PCh_fx[i] ) );
+ ftmp_fx = L_deposit_h( sub( isp_SCh_fx[i], isp_PCh_fx[i] ) ); /* Q31 */
// dist += ftmp * ftmp;
dist_fx = L_add( dist_fx, L_shr( Mpy_32_32( ftmp_fx, ftmp_fx ), gb ) ); // Q31-gb
}
@@ -1738,9 +1801,9 @@ Word16 tdm_lp_comparison_fx(
test();
test();
- if ( ( GE_32( element_brate_wo_meta, IVAS_48k ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_HR_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, gb ) ) ) ) ||
- ( EQ_16( hStereoClassif->lrtd_mode, 1 ) && LT_32( element_brate_wo_meta, IVAS_16k4 ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_HR_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, add( gb, 1 ) ) ) ) ) ||
- ( EQ_16( hStereoClassif->lrtd_mode, 1 ) && GE_32( element_brate_wo_meta, IVAS_16k4 ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_LRTD_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, gb + 2 ) ) ) ) || st->tc_cnt > 0 )
+ IF( ( GE_32( element_brate_wo_meta, IVAS_48k ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_HR_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, gb ) ) ) ) ||
+ ( EQ_16( hStereoClassif->lrtd_mode, 1 ) && LT_32( element_brate_wo_meta, IVAS_16k4 ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_HR_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, add( gb, 1 ) ) ) ) ) ||
+ ( EQ_16( hStereoClassif->lrtd_mode, 1 ) && GE_32( element_brate_wo_meta, IVAS_16k4 ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_LRTD_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, gb + 2 ) ) ) ) || st->tc_cnt > 0 )
{
LP_mode = 0;
move16();
@@ -1776,14 +1839,14 @@ void tdm_ol_pitch_comparison_fx(
st0 = hCPE->hCoreCoder[0]; /* Encoder structure - primary channel */
st1 = hCPE->hCoreCoder[1]; /* Encoder structure - secondary channel */
- if ( GT_32( hCPE->element_brate, IVAS_13k2 ) )
+ IF( GT_32( hCPE->element_brate, IVAS_13k2 ) )
{
diff_thr = 3;
move16();
}
test();
- if ( GE_32( hCPE->element_brate, IVAS_48k ) || EQ_16( hCPE->hStereoTD->tdm_LRTD_flag, 1 ) )
+ IF( GE_32( hCPE->element_brate, IVAS_48k ) || EQ_16( hCPE->hStereoTD->tdm_LRTD_flag, 1 ) )
{
diff_thr = 1;
move16();
@@ -1819,12 +1882,12 @@ void tdm_ol_pitch_comparison_fx(
test();
IF( GE_16( voicmin[0], 29491 /* 0.9f in Q15 */ ) && GE_16( voicmin[1], 29491 /* 0.9f in Q15 */ ) && GE_16( voicmin[2], 27853 /* 0.85f in Q15 */ ) && GE_16( voicmin[3], 27853 /* 0.85f in Q15 */ ) )
{
- tmp_diff = add( abs_s( sub( st0->pitch[0], st1->pitch[0] ) ), add( abs_s( sub( st0->pitch[1], st1->pitch[1] ) ), abs_s( sub( st0->pitch[2], st1->pitch[2] ) ) ) );
+ tmp_diff = add( abs_s( sub( st0->pitch[0], st1->pitch[0] ) ), add( abs_s( sub( st0->pitch[1], st1->pitch[1] ) ), abs_s( sub( st0->pitch[2], st1->pitch[2] ) ) ) ); /* Q0 */
}
}
ELSE
{
- tmp_diff = abs_s( sub( add( st0->pitch[0], add( st0->pitch[1], st0->pitch[2] ) ), add( st1->pitch[0], add( st1->pitch[1], st1->pitch[2] ) ) ) );
+ tmp_diff = abs_s( sub( add( st0->pitch[0], add( st0->pitch[1], st0->pitch[2] ) ), add( st1->pitch[0], add( st1->pitch[1], st1->pitch[2] ) ) ) ); /* Q0 */
}
IF( LE_16( tmp_diff, diff_thr ) )
@@ -1833,23 +1896,23 @@ void tdm_ol_pitch_comparison_fx(
move16();
/* 1/4 pitch precision update*/
- Copy( st0->pitch, st1->pitch, 3 );
- Copy( st0->voicing_fx, st1->voicing_fx, 3 );
+ Copy( st0->pitch, st1->pitch, 3 ); /* Q0 */
+ Copy( st0->voicing_fx, st1->voicing_fx, 3 ); /* Q15 */
/* Update some parameters accordingly */
- st1->old_corr_fx = st0->old_corr_fx;
- st1->old_thres_fx = st0->old_thres_fx;
- st1->delta_pit = st0->delta_pit;
+ st1->old_corr_fx = st0->old_corr_fx; /* Q15 */
+ st1->old_thres_fx = st0->old_thres_fx; /* Q15 */
+ st1->delta_pit = st0->delta_pit; /* Q0 */
move16();
move16();
move16();
/* Updates for adaptive lag window memory */
- st1->old_pitch_la = st0->old_pitch_la;
+ st1->old_pitch_la = st0->old_pitch_la; /* Q0 */
move16();
/* 1/4 pitch precision update*/
- Copy( pitch_fr[0], pitch_fr[1], NB_SUBFR );
- Copy( voicing_fr[0], voicing_fr[1], NB_SUBFR );
+ Copy( pitch_fr[0], pitch_fr[1], NB_SUBFR ); /* Q6 */
+ Copy( voicing_fr[0], voicing_fr[1], NB_SUBFR ); /* Q15 */
}
}
@@ -1863,15 +1926,15 @@ void tdm_ol_pitch_comparison_fx(
*-------------------------------------------------------------------*/
static void Get_corr_n_fx(
- const Word16 L[], /* i : Left signal */
- const Word16 R[], /* i : Right signal */
- Word32 *ic_Lm, /* o : Left signal */
+ const Word16 L[], /* i : Left signal q_in*/
+ const Word16 R[], /* i : Right signal q_in*/
+ Word32 *ic_Lm, /* o : Left signal q_ic_Lm*/
Word16 *q_ic_Lm, /* o : Q factor of Left signal */
- Word32 *ic_Rm, /* o : Right signal */
+ Word32 *ic_Rm, /* o : Right signal q_ic_Rm*/
Word16 *q_ic_Rm, /* o : Q factor of Right signal */
- const Word16 len, /* i : segment length */
+ const Word16 len, /* i : segment length Q0*/
Word32 *es_em, /* o : return the difference between the side and mono energy */
- const Word16 tdm_SM_calc_flag /* i : Flag that indicates that it is for SM mode */
+ const Word16 tdm_SM_calc_flag /* i : Flag that indicates that it is for SM mode Q0*/
)
{
Word32 corrL, corrR, ener;
@@ -1892,7 +1955,7 @@ static void Get_corr_n_fx(
move64();
W_ener_side = EPSILON_FX;
move64();
- guard_bits = sub( 32, find_guarded_bits_fx( len ) );
+ guard_bits = sub( 32, find_guarded_bits_fx( len ) ); /* Q0 */
/*----------------------------------------------------------------*
* Find the normalized correlation between: left/mono and right/mono based
@@ -1910,8 +1973,8 @@ static void Get_corr_n_fx(
W_ener_side = W_mac0_16_16( W_ener_side, side_i, side_i ); // (q_in + q_in )
}
/* Scaling back to the original proposal */
- corrL = W_extract_h( W_shl( W_corrL, guard_bits ) );
- corrR = W_extract_h( W_shl( W_corrR, guard_bits ) );
+ corrL = W_extract_h( W_shl( W_corrL, guard_bits ) ); /* 2*q_in + guard_bits - 32 */
+ corrR = W_extract_h( W_shl( W_corrR, guard_bits ) ); /* 2*q_in + guard_bits - 32 */
ener = W_extract_h( W_shl( W_ener, guard_bits ) );
ener_side = W_extract_h( W_shl( W_ener_side, guard_bits ) );
}
@@ -1927,8 +1990,8 @@ static void Get_corr_n_fx(
W_ener_side = W_mac0_16_16( W_ener_side, side_i, side_i ); // (q_in + q_in )
}
/* Scaling back to the original proposal */
- corrL = W_extract_h( W_shl( W_corrL, guard_bits ) );
- corrR = W_extract_h( W_shl( W_corrR, guard_bits ) );
+ corrL = W_extract_h( W_shl( W_corrL, guard_bits ) ); /* 2*q_in + guard_bits - 32 */
+ corrR = W_extract_h( W_shl( W_corrR, guard_bits ) ); /* 2*q_in + guard_bits - 32 */
ener = W_extract_h( W_shl( W_ener, guard_bits ) );
ener_side = W_extract_h( W_shl( W_ener_side, guard_bits ) );
}
@@ -1976,9 +2039,9 @@ static void Get_corr_n_fx(
/* *es_em = 10 * ( log10f( sqrtf( ener_side / len ) ) - log10f( sqrtf( ener / len ) ) );
is simplified to
*es_em = 10 * ( log10f( sqrtf( ener_side / ener ) ) ); */
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( ener_side, ener, &exp_diff ); // (Q31 - exp_diff)
- L_tmp = Sqrt32( L_tmp, &exp_diff );
- L_tmp = BASOP_Util_Log2( L_tmp );
+ L_tmp = BASOP_Util_Divide3232_Scale_cadence( ener_side, ener, &exp_diff ); // (Q31 - exp_diff)
+ L_tmp = Sqrt32( L_tmp, &exp_diff ); /* (Q31 - exp_diff) */
+ L_tmp = BASOP_Util_Log2( L_tmp ); /* Q25 */
*es_em = Mpy_32_32( Mpy_32_32( L_add( L_tmp, L_shl( exp_diff, Q25 ) ), LOG10_2_Q31 ), TEN_IN_Q27 ); // (Q25, Q27) -> Q21
move32();
}
@@ -1994,24 +2057,24 @@ static void Get_corr_n_fx(
/*! r: smoothed position */
static Word16 stereo_smooth_LR_transition_fx(
- Word16 *tdm_prev_stable_idx, /* i/o: Previous Transmitted ratio index */
- Word16 *tdm_ratio_transition_mov_flag, /* i/o: Flag that indicates that L-R energy is changing */
- Word16 tdm_last_ratio_idx, /* i : last TDM ratio index */
- Word16 *tdm_prev_desired_idx, /* i/o: Previous Transmitted ratio index */
- Word16 *tdm_ratio_transition_cnt, /* i/o: Counter */
- const Word16 tdm_SM_flag, /* i : channel combination scheme flag for current frame */
- Word16 desired_idx /* i : desired final position */
+ Word16 *tdm_prev_stable_idx, /* i/o: Previous Transmitted ratio index Q0*/
+ Word16 *tdm_ratio_transition_mov_flag, /* i/o: Flag that indicates that L-R energy is changing Q0*/
+ Word16 tdm_last_ratio_idx, /* i : last TDM ratio index Q0*/
+ Word16 *tdm_prev_desired_idx, /* i/o: Previous Transmitted ratio index Q0*/
+ Word16 *tdm_ratio_transition_cnt, /* i/o: Counter Q0*/
+ const Word16 tdm_SM_flag, /* i : channel combination scheme flag for current frame Q0*/
+ Word16 desired_idx /* i : desired final position Q0*/
)
{
Word16 idx;
- if ( EQ_16( tdm_SM_flag, 1 ) )
+ IF( EQ_16( tdm_SM_flag, 1 ) )
{
desired_idx = 15;
move16();
}
- if ( NE_16( desired_idx, *tdm_prev_stable_idx ) )
+ IF( NE_16( desired_idx, *tdm_prev_stable_idx ) )
{
*tdm_ratio_transition_mov_flag = 1;
move16();
diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c
index b944816a9d18dc9bd1d78318126c41ab82e54c40..e8a81147a844e71cf9b809d1772a2017861d388e 100644
--- a/lib_enc/ivas_tcx_core_enc.c
+++ b/lib_enc/ivas_tcx_core_enc.c
@@ -347,7 +347,7 @@ void stereo_tcx_core_enc(
*--------------------------------------------------------------------------------*/
/* TCX20/TCX10 and coder type */
- writeTCXMode( st, hBstr, 0, /* MCT_flag */ &nbits_start );
+ writeTCXMode_fx( st, hBstr, 0, /* MCT_flag */ &nbits_start );
/* write last_core for error concealment */
q_ind_val = 0;
@@ -361,10 +361,10 @@ void stereo_tcx_core_enc(
push_next_indice( hBstr, q_ind_val, 1 );
/* write TCX overlap mode (1 bit: full, 2 bits: half or no overlap) */
- writeTCXWindowing( hBstr, st->hTcxCfg->tcx_curr_overlap_mode );
+ writeTCXWindowing_fx( hBstr, st->hTcxCfg->tcx_curr_overlap_mode );
IF( EQ_16( st->core, TCX_10_CORE ) )
{
- writeTCXWindowing( hBstr, st->hTcxCfg->tcx_last_overlap_mode );
+ writeTCXWindowing_fx( hBstr, st->hTcxCfg->tcx_last_overlap_mode );
}
assert( nbits_header == ( hBstr->nb_bits_tot - nbits_start ) );
@@ -586,6 +586,8 @@ void stereo_tcx_core_enc(
Scale_sig( st->hTdCngEnc->cng_exc2_buf, HO_HIST_SIZE * L_FFT, sub( add( shl( Q_new, 1 ), s ), Q_exc ) );
}
Q_exc = add( shl( Q_new, 1 ), s ); // 2 * Q_new + s
+ st->hLPDmem->q_lpd_old_exc = Q_exc;
+ move16();
IF( st->enableTcxLpc )
{
@@ -712,12 +714,10 @@ void stereo_tcx_core_enc(
move16();
Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( s_min( curr_q_syn, st->hLPDmem->q_mem_syn ), st->hLPDmem->q_mem_syn ) );
Scale_sig( st->hLPDmem->mem_syn3, M, sub( s_min( curr_q_syn, st->hLPDmem->q_mem_syn ), st->hLPDmem->q_mem_syn ) );
- st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
+ st->hLPDmem->q_mem_syn = s_min( curr_q_syn, st->hLPDmem->q_mem_syn );
move16();
st->hLPDmem->q_lpd_syn = Q_new;
move16();
- st->hLPDmem->q_lpd_old_exc = Q_new;
- move16();
IF( st->hTdCngEnc != NULL )
{
FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
@@ -1060,6 +1060,8 @@ Word16 ivas_acelp_tcx20_switching_fx(
ener = Mpy_32_16_1( Mpy_32_16_1( ener, 0x78AE ), getInvFrameLen( L_frame ) ); /* 0x78AE -> sqrt(2)/12 (Q18) */
ener_e = sub( s, 9 );
+ x_fx = hTcxEnc->spectrum_long_fx;
+
IF( !flag_16k_smc )
{
const Word16 *bands;
diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c
index 69d0f1ab936ae73ea6c4c06b57a716fe761552c4..281e131f7390017a89e5b9cdf8fbac510946f70b 100644
--- a/lib_enc/lib_enc.c
+++ b/lib_enc/lib_enc.c
@@ -150,7 +150,7 @@ ivas_error IVAS_ENC_Open(
init_encoder_config( st_ivas->hEncoderConfig );
/* initialize pointers to handles to NULL */
- ivas_initialize_handles_enc( st_ivas );
+ ivas_initialize_handles_enc_fx( st_ivas );
st_ivas->ind_list = NULL;
st_ivas->ind_list_metadata = NULL;
@@ -185,6 +185,9 @@ ivas_error IVAS_ENC_Open_fx(
( *phIvasEnc )->hCoreCoder = NULL;
( *phIvasEnc )->isConfigured = false;
+#ifdef DEBUGGING
+ ( *phIvasEnc )->cmd_stereo = false;
+#endif
( *phIvasEnc )->switchingActive = false;
( *phIvasEnc )->maxBandwidthUser = false;
resetIsmMetadataProvidedFlags( *phIvasEnc );
@@ -213,7 +216,7 @@ ivas_error IVAS_ENC_Open_fx(
init_encoder_config( st_ivas->hEncoderConfig );
/* initialize pointers to handles to NULL */
- ivas_initialize_handles_enc( st_ivas );
+ ivas_initialize_handles_enc_fx( st_ivas );
st_ivas->ind_list = NULL;
st_ivas->ind_list_metadata = NULL;
@@ -243,7 +246,7 @@ void IVAS_ENC_Close(
if ( ( *phIvasEnc )->isConfigured )
{
- ivas_destroy_enc( ( *phIvasEnc )->st_ivas );
+ ivas_destroy_enc_fx( ( *phIvasEnc )->st_ivas );
}
else
{
@@ -432,7 +435,6 @@ ivas_error IVAS_ENC_ConfigureForMASAObjects(
BREAK;
default:
return IVAS_ERR_INVALID_MASA_CONFIG;
- BREAK;
}
st_ivas = hIvasEnc->st_ivas;
@@ -733,7 +735,6 @@ ivas_error IVAS_ENC_ConfigureForMasa(
BREAK;
default:
return IVAS_ERR_INVALID_MASA_CONFIG;
- BREAK;
}
hIvasEnc->maxBandwidthUser = max_bwidth_user;
diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c
index 9df21a2001573db739f00716b94511c95fec1ac0..259987bba43611a9f4c89041ea1a1ce51cc65533 100644
--- a/lib_enc/nelp_enc_fx.c
+++ b/lib_enc/nelp_enc_fx.c
@@ -31,7 +31,6 @@
*******************************************************************************************************/
#include
-#include "control.h"
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "prot.h" /* Function prototypes */
diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c
index 2b8bded71038a4a6429a3d3c4721f502e5fe4c25..a52147004c2f8b19f42064d291e990a49da3ed3c 100644
--- a/lib_enc/nois_est_fx.c
+++ b/lib_enc/nois_est_fx.c
@@ -748,6 +748,119 @@ void noise_est_down_fx(
return;
}
+void noise_est_down_ivas_fx(
+ const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) q_fr_bands */
+ const Word16 q_fr_bands, /* i : Q of fr_bands */
+ Word32 bckr[], /* i/o: per band background noise energy estimate q_fr_bands */
+ Word32 tmpN[], /* o : temporary noise update q_fr_bands */
+ Word32 enr[], /* o : averaged energy over both subframes */
+ const Word16 min_band, /* i : minimum critical band */
+ const Word16 max_band, /* i : maximum critical band */
+ Word16 *totalNoise, /* o : noise estimate over all critical bands */
+ Word16 Etot, /* i : Energy of current frame */
+ Word16 *Etot_last, /* i/o: Energy of last frame Q8 */
+ Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */
+)
+
+{
+ Word32 Ltmp, L_tmp;
+ const Word32 *pt1, *pt2;
+ Word16 i;
+ Word16 e_Noise, f_Noise;
+ Word32 e_min;
+ Word32 totalNoise_temp;
+ Word32 L_Etot, L_Etot_last, L_Etot_v_h2, L_Etot_v;
+ Word64 sum;
+ Word16 q_sum;
+
+ e_min = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands
+
+ L_Etot = L_shl( Etot, 16 ); /*Q24 for later AR1 computations*/
+ L_Etot_last = L_shl( *Etot_last, 16 );
+ L_Etot_v_h2 = L_shl( *Etot_v_h2, 16 );
+
+ /*-----------------------------------------------------------------*
+ * Estimate total noise energy
+ *-----------------------------------------------------------------*/
+
+ totalNoise_temp = L_deposit_l( 0 );
+ sum = 0;
+ move64();
+ FOR( i = min_band; i <= max_band; i++ )
+ {
+ sum = W_mac_32_32( sum, bckr[i], 1 ); // q_fr_bands+1
+ }
+ q_sum = add( q_fr_bands, 1 );
+ IF( sum == 0 )
+ {
+ sum = W_mult0_32_32( E_MIN_FXQ31, add( sub( max_band, min_band ), 1 ) ); // Q31
+ q_sum = Q31;
+ move16();
+ }
+ e_Noise = W_norm( sum );
+ totalNoise_temp = W_extract_h( W_shl( sum, e_Noise ) ); // q_sum+e_Noise-32
+ e_Noise = sub( 63, add( e_Noise, q_sum ) ); // 31-(q_sum+e_Noise-32)
+
+ /*totalNoise = 10.0f * (float)log10( *totalNoise );*/
+ f_Noise = Log2_norm_lc( totalNoise_temp ); // exponent of log => 30-0 = 30
+ e_Noise = sub( e_Noise, 1 ); // 30-(31-e_Noise) = e_Noise-1
+ Ltmp = L_mac( L_deposit_h( e_Noise ), f_Noise, 1 ); // Q16
+ Ltmp = Mpy_32_16_1( Ltmp, LG10 ); // Q14 (16+13-15)
+ Ltmp = L_shl( Ltmp, 10 ); // Q26
+ *totalNoise = round_fx( Ltmp ); /*Q8*/
+ move16();
+
+ /*-----------------------------------------------------------------*
+ * Average energy per frame for each frequency band
+ *-----------------------------------------------------------------*/
+
+ pt1 = fr_bands;
+ pt2 = fr_bands + NB_BANDS;
+
+ FOR( i = 0; i < NB_BANDS; i++ )
+ {
+ /* enr[i] = 0.5f * ( *pt1++ + *pt2++ ); */
+ enr[i] = W_extract_h( W_mac_32_32( W_mult_32_32( *pt1, ONE_IN_Q30 ), *pt2, ONE_IN_Q30 ) ); // q_fr_bands+30+1-32+1 = q_fr_bands
+ move32();
+ pt1++;
+ pt2++;
+ }
+
+ /*-----------------------------------------------------------------*
+ * Background noise energy update
+ *-----------------------------------------------------------------*/
+
+ FOR( i = 0; i < NB_BANDS; i++ )
+ {
+ /* tmpN[i] = (1-ALPHA) * bckr[i] + ALPHA * enr[i]; */
+ /* handle div by zero in find_tilt_fx */
+ tmpN[i] = L_max( Madd_32_16( Mpy_32_16_1( bckr[i], ALPHAM1_FX ), enr[i], ALPHA_FX ), e_min ); // q_fr_bands
+ move32();
+
+ /* if( tmpN[i] < bckr[i] ) { bckr[i] = tmpN[i]; }*/
+ /* Defend to increase noise estimate: keep as it is or decrease */
+ bckr[i] = L_max( L_min( bckr[i], tmpN[i] ), e_min ); // q_fr_bands
+ move32();
+ }
+
+ /*------------------------------------------------------------------*
+ * Energy variation update
+ *------------------------------------------------------------------*/
+ /*Etot_v = (float) fabs(*Etot_last - Etot);*/
+ L_Etot_v = L_abs( L_sub( L_Etot_last, L_Etot ) ); /* Q24 */
+
+ /* *Etot_v_h2 = (1.0f-0.02f) * *Etot_v_h2 + 0.02f * min(3.0f, Etot_v); */
+ L_tmp = L_min( 50331648 /* 3.0f in Q24 */, L_Etot_v ); // Q24
+ L_tmp = Mult_32_16( L_tmp, 655 /*.02 in Q15 */ ); // Q24
+ L_Etot_v_h2 = Madd_32_16( L_tmp, L_Etot_v_h2, 32113 /* 0.98 in Q15 */ ); // Q24
+
+ /* if (*Etot_v_h2 < 0.1f) { *Etot_v_h2 = 0.1f; } */
+ *Etot_v_h2 = s_max( round_fx( L_Etot_v_h2 ), 26 /* 0.1 in Q8*/ ); // Q8
+ move16();
+
+ return;
+}
+
/*-----------------------------------------------------------------*
* noise_est_fx()
*
@@ -3497,7 +3610,8 @@ void noise_est_ivas_fx(
/* st->bckr[i] = st->bckr[i] + updt_step * (tmpN[i]-st->bckr[i]);*/
/* 32 bit state update */
Ltmp = L_sub( tmpN[i], hNoiseEst->bckr_fx[i] ); /*Q_new+Q_SCALE*/
- Ltmp = Mult_32_16( Ltmp, updt_step ); /* Q_new+Q_SCALE+15+1 -16*/
+ Ltmp = Mult_32_16( Ltmp, updt_step );
+ /* Q_new+Q_SCALE+15+1 -16*/
hNoiseEst->bckr_fx[i] = L_add( Ltmp, hNoiseEst->bckr_fx[i] );
move32();
}
diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c
index ea09805be3b3cdaf5cdf45ff52fbf2a35c491850..f0c37afe5b6220786030c58cb28ef4b486006411 100644
--- a/lib_enc/pit_enc_fx.c
+++ b/lib_enc/pit_enc_fx.c
@@ -781,7 +781,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
}
ELSE IF( EQ_16( nBits, 10 ) )
{
- *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR );
+ *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR );
}
pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
@@ -1129,7 +1129,196 @@ Word16 delta_pit_enc_fx( /* o : pitch index
*
* Find the closed loop pitch period with 1/4 subsample resolution.
*-------------------------------------------------------------------*/
+Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t0_min, /* i : minimum value in the searched range. Q0*/
+ const Word16 t0_max, /* i : maximum value in the searched range. Q0*/
+ Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */
+ const Word16 i_subfr, /* i : flag to first subframe */
+ const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */
+ const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */
+ const Word16 t0_fr1, /* i : minimum value for resolution 1 */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 L_subfr /* i : size of subframe */
+)
+{
+ Word16 i;
+ Word16 t_min, t_max;
+ Word16 max_val, t0, t1, fraction, step, temp;
+ Word16 *corr;
+ Word16 corr_v[15 + 2 * L_INTERPOL1 + 1]; /* Total length = t0_max-t0_min+1+2*L_inter */
+ Word16 pit_min;
+ Word16 cor_max;
+
+ /* initialization */
+ IF( limit_flag == 0 )
+ {
+ IF( EQ_16( L_frame, L_FRAME ) )
+ {
+ pit_min = PIT_MIN;
+ move16();
+ }
+ ELSE /* L_frame == L_FRAME16k */
+ {
+ pit_min = PIT16k_MIN;
+ move16();
+ }
+ }
+ ELSE
+ {
+ IF( EQ_16( L_frame, L_FRAME ) )
+ {
+ pit_min = PIT_MIN_EXTEND;
+ move16();
+ IF( EQ_16( limit_flag, 2 ) )
+ {
+ pit_min = PIT_MIN_DOUBLEEXTEND;
+ move16();
+ }
+ }
+ ELSE /* L_frame == L_FRAME16k */
+ {
+ pit_min = PIT16k_MIN_EXTEND;
+ move16();
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * - Find interval to compute normalized correlation
+ * - allocate memory to normalized correlation vector
+ * - Compute normalized correlation between target and filtered
+ * excitation
+ *-----------------------------------------------------------------*/
+
+ t_min = sub( t0_min, L_INTERPOL1 );
+ t_max = add( t0_max, L_INTERPOL1 );
+ corr = &corr_v[-t_min];
+ move16();
+ move16(); /* corr[t_min..t_max] */
+
+ norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr, L_subfr );
+
+ /*-----------------------------------------------------------------*
+ * Find integer pitch
+ *-----------------------------------------------------------------*/
+
+ max_val = corr[t0_min];
+ move16();
+ t0 = t0_min;
+ move16();
+
+ FOR( i = add( t0_min, 1 ); i <= t0_max; i++ )
+ {
+ if ( corr[i] >= max_val )
+ {
+ t0 = i;
+ move16();
+ }
+ max_val = s_max( corr[i], max_val );
+ }
+
+ IF( EQ_16( t0_fr1, pit_min ) )
+ {
+ /* don't search fraction (for 7b/4b quant) */
+ test();
+ IF( ( i_subfr == 0 ) && ( GE_16( t0, t0_fr2 ) ) )
+ {
+ i = shl( shr( t0, 1 ), 1 ); /* 2 samples resolution */
+ if ( GT_16( add( i, 2 ), PIT_MAX ) )
+ {
+ i = sub( i, 2 );
+ }
+ IF( GT_16( corr[i], corr[i + 2] ) )
+ {
+ t0 = i;
+ move16();
+ }
+ ELSE
+ {
+ t0 = add( i, 2 );
+ }
+ }
+ *pit_frac = 0;
+ move16();
+
+ return ( t0 );
+ }
+
+ test();
+ IF( ( i_subfr == 0 ) && ( GE_16( t0, t0_fr1 ) ) )
+ {
+ *pit_frac = 0;
+ move16();
+
+ return ( t0 );
+ }
+
+ /*------------------------------------------------------------------*
+ * Search fractionnal pitch with 1/4 subsample resolution.
+ * search the fractions around t0 and choose the one which maximizes
+ * the interpolated normalized correlation.
+ *-----------------------------------------------------------------*/
+
+ t1 = t0;
+ move16();
+ step = 1;
+ move16(); /* 1/4 subsample resolution */
+ fraction = 1;
+ move16();
+ test();
+ test();
+ IF( ( ( i_subfr == 0 ) && ( GE_16( t0, t0_fr2 ) ) ) || ( EQ_16( t0_fr2, pit_min ) ) )
+ {
+ step = 2;
+ move16(); /* 1/2 subsample resolution */
+ fraction = 2;
+ move16();
+ }
+
+ IF( EQ_16( t0, t0_min ) ) /* Limit case */
+ {
+ fraction = 0;
+ move16();
+ cor_max = Interpol_4( &corr[t0], fraction );
+ }
+ ELSE
+ {
+ t0 = sub( t0, 1 );
+ cor_max = Interpol_4( &corr[t0], fraction );
+ FOR( i = add( fraction, step ); i <= 3; i = (Word16) ( i + step ) )
+ {
+ temp = Interpol_4( &corr[t0], i );
+ IF( GT_16( temp, cor_max ) )
+ {
+ cor_max = temp;
+ move16();
+ fraction = i;
+ move16();
+ }
+ }
+ }
+
+ FOR( i = 0; i <= 3; i = (Word16) ( i + step ) )
+ {
+ temp = Interpol_4( &corr[t1], i );
+ IF( GT_16( temp, cor_max ) )
+ {
+ cor_max = temp;
+ move16();
+ fraction = i;
+ move16();
+ t0 = t1;
+ move16();
+ }
+ }
+
+ *pit_frac = fraction;
+ move16();
+ return ( t0 );
+}
Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */
const Word16 exc[], /* i : excitation buffer Q_new*/
const Word16 xn[], /* i : target signal Q_new-1+shift*/
@@ -1329,6 +1518,120 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag
* excitation divided by the square root of energy of filtered
* excitation)
*---------------------------------------------------------------------*/
+void norm_corr_ivas_fx(
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t_min, /* i : minimum value of searched range */
+ const Word16 t_max, /* i : maximum value of searched range */
+ Word16 ncorr[], /* o : normalized correlation Q15 */
+ const Word16 L_subfr /* i : subframe size */
+)
+{
+ Word16 i, k, t;
+ Word16 corr, exp_corr, norm, exp_norm, exp, scale;
+ Word16 excf[L_FRAME16k];
+ Word32 L_tmp;
+ Word64 W_tmp;
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+#endif
+
+ k = negate( t_min );
+
+ /*-----------------------------------------------------------------*
+ * compute the filtered excitation for the first delay t_min
+ *-----------------------------------------------------------------*/
+
+ conv_fx( &exc[k], h, excf, L_subfr );
+
+ /* Compute rounded down 1/sqrt(energy of xn[]) */
+#ifdef BASOP_NOGLOB
+ L_tmp = L_mac_o( 1, xn[0], xn[0], &Overflow );
+#else
+ L_tmp = L_mac( 1, xn[0], xn[0] );
+#endif
+ FOR( i = 1; i < L_subfr; i++ )
+ {
+#ifdef BASOP_NOGLOB
+ L_tmp = L_mac_o( L_tmp, xn[i], xn[i], &Overflow );
+#else /* BASOP_NOGLOB */
+ L_tmp = L_mac( L_tmp, xn[i], xn[i] );
+#endif
+ }
+ exp = norm_l( L_tmp );
+ exp = sub( 30, exp );
+
+ exp = add( exp, 2 ); /* energy of xn[] x 2 + rounded up */
+ scale = negate( shr( exp, 1 ) ); /* (1< 0; i-- )
+ {
+ /* saturation can occur in add() */
+ /*excf[i] = add(mult(exc[k], h[i]), excf[i - 1]); move16(); */
+#ifdef BASOP_NOGLOB
+ excf[i] = round_fx_sat( L_mac_sat( L_mult( excf[i - 1], 32767 ), exc[k], h[i] ) );
+#else
+ excf[i] = round_fx( L_mac( L_mult( excf[i - 1], 32767 ), exc[k], h[i] ) );
+#endif
+ }
+ excf[0] = mult_r( exc[k], h[0] );
+ move16();
+ }
+ }
+
+ return;
+}
void norm_corr_fx(
const Word16 exc[], /* i : excitation buffer Q_new*/
diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c
index 82b00ead0b1b92e3a5ec90ed7fbc5389dc8eab07..65c28d26019e28e7d8c847c865226e71afeb4038 100644
--- a/lib_enc/pitch_ol_fx.c
+++ b/lib_enc/pitch_ol_fx.c
@@ -46,21 +46,6 @@
/*-----------------------------------------------------------------*
* Local function prototypes
*-----------------------------------------------------------------*/
-static Word32 Dot_product12_o_ivas( /* (o) Q31: normalized result (1 < val <= -1) */
- const Word16 x[], /* (i) 12bits: x vector */
- const Word16 y[], /* (i) 12bits: y vector */
- const Word16 lg, /* (i) : vector length */
- Word16 *exp, /* (o) : exponent of result (0..+30) */
- Flag *Overflow_out /* o : propagating the Overflow flag to upper level, set to NULL to ignore internal overflows */
-);
-static Word32 Dot_product12_ivas( /* (o) Q31: normalized result (1 < val <= -1) */
- const Word16 x[], /* (i) 12bits: x vector */
- const Word16 y[], /* (i) 12bits: y vector */
- const Word16 lg, /* (i) : vector length */
- Word16 *exp /* (o) : exponent of result (0..+30) */
-);
-static Word32 Dot_product12_OL_ivas( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );
-static Word32 Dot_product12_OL_back_ivas( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );
static void LP_Decim2_Copy( const Word16 x[], Word16 y[], Word16 l, Word16 mem[] );
@@ -73,191 +58,7 @@ static Word16 pitch_coherence_fx( Word16 pitch0, Word16 pitch1, Word16 fac_max,
static Word32 Dot_product12_OL( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );
static Word32 Dot_product12_OL_back( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );
-#ifdef BASOP_NOGLOB
-static Word32 Dot_product12_o_ivas( /* (o) Q31: normalized result (1 < val <= -1) */
- const Word16 x[], /* (i) 12bits: x vector */
- const Word16 y[], /* (i) 12bits: y vector */
- const Word16 lg, /* (i) : vector length */
- Word16 *exp, /* (o) : exponent of result (0..+30) */
- Flag *Overflow_out /* o : propagating the Overflow flag to upper level, set to NULL to ignore internal overflows */
-)
-#else /* BASOP_NOGLOB */
-Word32 Dot_product12_ivas( /* (o) Q31: normalized result (1 < val <= -1) */
- const Word16 x[], /* (i) 12bits: x vector */
- const Word16 y[], /* (i) 12bits: y vector */
- const Word16 lg, /* (i) : vector length */
- Word16 *exp /* (o) : exponent of result (0..+30) */
-)
-#endif /* BASOP_NOGLOB */
-{
- Word16 i, sft;
- Word32 L_sum;
-#ifdef BASOP_NOGLOB
- Flag Overflow_ignored = 0;
-#endif /* BASOP_NOGLOB */
-
-#ifdef BASOP_NOGLOB
- L_sum = L_mac_o( 0, x[0], y[0], &Overflow_ignored );
-#else
- L_sum = L_mac( 1, x[0], y[0] );
-#endif
- FOR( i = 1; i < lg; i++ )
- {
-#ifdef BASOP_NOGLOB
- L_sum = L_mac_o( L_sum, x[i], y[i], Overflow_out ? Overflow_out : &Overflow_ignored );
-#else /* BASOP_NOGLOB */
- L_sum = L_mac( L_sum, x[i], y[i] );
-#endif /* BASOP_NOGLOB */
- }
-
- /* Normalize acc in Q31 */
-
- sft = norm_l( L_sum );
- L_sum = L_shl( L_sum, sft );
-
- *exp = sub( 30, sft );
- move16(); /* exponent = 0..30 */
-
- return L_sum;
-}
-static Word32 Dot_product12_ivas( /* (o) Q31: normalized result (1 < val <= -1) */
- const Word16 x[], /* (i) 12bits: x vector */
- const Word16 y[], /* (i) 12bits: y vector */
- const Word16 lg, /* (i) : vector length */
- Word16 *exp /* (o) : exponent of result (0..+30) */
-)
-{
- /* Ignore internal overflows */
- return Dot_product12_o_ivas( x, y, lg, exp, NULL );
-}
-/*---------------------------------------------------------------------*
- * Dot_product12_OL_back()
- *
- * two different length dot products of x and y, computed backward
- *---------------------------------------------------------------------*/
-static Word32 Dot_product12_OL_back_ivas( /* o : Q31: normalized result (1 < val <= -1) */
- Word16 *sum1, /* o : Q31: normalized result 2 */
- const Word16 x[], /* i : 12bits: x vector */
- const Word16 y[], /* i : 12bits: y vector */
- const Word16 lg, /* i : vector length */
- const Word16 lg2, /* i : vector length 2 */
- Word16 *exp, /* o : exponent of result (0..+30) */
- Word16 *exp2 /* o : exponent of result 2 (0..+30) */
-)
-{
- Word16 i, sft;
- Word32 L_sum, L_sum2;
- Flag Overflow_ignored = 0;
-
- L_sum = L_mac( 0, x[0], y[0] );
- IF( LE_16( lg, lg2 ) )
- {
- FOR( i = 1; i < lg; i++ )
- {
- L_sum = L_mac_o( L_sum, x[-i], y[-i], &Overflow_ignored );
- }
- /* sets to 'L_sum' in 1 clock */
- L_sum2 = L_sum;
- move32();
- FOR( ; i < lg2; i++ )
- {
- L_sum2 = L_mac_o( L_sum2, x[-i], y[-i], &Overflow_ignored );
- }
- }
- ELSE
- {
- FOR( i = 1; i < lg2; i++ )
- {
- L_sum = L_mac_o( L_sum, x[-i], y[-i], &Overflow_ignored );
- }
- /* sets to 'L_sum' in 1 clock */
- L_sum2 = L_sum;
- move32();
- FOR( ; i < lg; i++ )
- {
- L_sum = L_mac_o( L_sum, x[-i], y[-i], &Overflow_ignored );
- }
- }
-
- /* Q31 */
- sft = norm_l( L_sum );
- L_sum = L_shl( L_sum, sft );
- *exp = sub( 30, sft );
- move16(); /* exponent = 0..30 */
-
- sft = norm_l( L_sum2 );
- L_sum2 = L_shl( L_sum2, sft );
- *exp2 = sub( 30, sft );
- move16(); /* exponent = 0..30 */
-
- *sum1 = extract_h( L_shr( L_sum2, 1 ) );
-
- return L_sum;
-}
-/*---------------------------------------------------------------------*
- * Dot_product12_OL
- *
- * two different length dot products of x and y
- *---------------------------------------------------------------------*/
-static Word32 Dot_product12_OL_ivas( /* o : Q31: normalized result (1 < val <= -1) */
- Word16 *sum1, /* o : Q31: normalized result 2 */
- const Word16 x[], /* i : 12bits: x vector */
- const Word16 y[], /* i : 12bits: y vector */
- const Word16 lg, /* i : vector length */
- const Word16 lg2, /* i : vector length 2 */
- Word16 *exp, /* o : exponent of result (0..+30) */
- Word16 *exp2 /* o : exponent of result 2 (0..+30) */
-)
-{
- Word16 i, sft;
- Word32 L_sum, L_sum2;
- Flag Overflow_ignored = 0;
- L_sum = L_mac( 0, x[0], y[0] );
- IF( LE_16( lg, lg2 ) )
- {
- FOR( i = 1; i < lg; i++ )
- {
- L_sum = L_mac_o( L_sum, x[i], y[i], &Overflow_ignored );
- }
- /* sets to 'L_sum' in 1 clock */
- L_sum2 = L_sum;
- move32();
- FOR( ; i < lg2; i++ )
- {
- L_sum2 = L_mac_o( L_sum2, x[i], y[i], &Overflow_ignored );
- }
- }
- ELSE
- {
- FOR( i = 1; i < lg2; i++ )
- {
- L_sum = L_mac_o( L_sum, x[i], y[i], &Overflow_ignored );
- }
- /* sets to 'L_sum' in 1 clock */
- L_sum2 = L_sum;
- move32();
- FOR( ; i < lg; i++ )
- {
- L_sum = L_mac_o( L_sum, x[i], y[i], &Overflow_ignored );
- }
- }
-
- /* Q31 */
- sft = norm_l( L_sum );
- L_sum = L_shl( L_sum, sft );
- *exp = sub( 30, sft );
- move16(); /* exponent = 0..30 */
-
- sft = norm_l( L_sum2 );
- L_sum2 = L_shl( L_sum2, sft );
- *exp2 = sub( 30, sft );
- move16(); /* exponent = 0..30 */
-
- *sum1 = extract_h( L_shr( L_sum2, 1 ) );
-
- return L_sum;
-}
/*-----------------------------------------------------------------*
* pitch_ol_init()
*
@@ -1287,7 +1088,7 @@ void pitch_ol_ivas_fx(
Word16 *old_pitch, /* i/o: pitch of the 2nd half-frame of previous frame (i.e. pitch[1]) Q0 */
Word16 *old_corr, /* i/o: correlation of old_pitch (i.e. voicing[1] or corr_mean) Q15 */
Word16 corr_shift, /* i : normalized correlation correction Q15 */
- Word16 *old_thres, /* i/o: maximum correlation weighting with respect to past frame pitch Q15 */
+ Word16 *old_thres, /* i/o: maximum correlation weighting with respect to past frame pitch Q14 */
Word16 *delta_pit, /* i/o: old pitch extrapolation correction in range [-14,+14] Q0 */
Word16 *st_old_wsp2, /* i/o: weighted speech memory qwsp */
const Word16 *wsp, /* i : weighted speech for current frame and look-ahead qwsp */
@@ -1295,7 +1096,8 @@ void pitch_ol_ivas_fx(
const Word16 relE, /* i : relative frame energy Q8 */
const Word16 last_class, /* i : frame classification of last frame */
const Word16 bwidth, /* i : bandwidth */
- const Word16 Opt_SC_VBR /* i : SC-VBR flag */
+ const Word16 Opt_SC_VBR, /* i : SC-VBR flag */
+ Word16 qwsp /* i : Q factor for wsp Q0 */
)
{
Word16 ftmp, old_wsp2[( L_WSP - L_INTERPOL ) / OPL_DECIM], *wsp2;
@@ -1303,11 +1105,11 @@ void pitch_ol_ivas_fx(
Word16 scale1[2 * DELTA_COH - 1];
Word16 scaled_buf[2 * LEN_X + 3 * ( DELTA_COH - 1 )];
- Word16 scaled_buf_exp[2 * LEN_X + 3 * ( DELTA_COH - 1 )], exp_sect[8], exp_sect1[8], exp_sect0;
- Word16 cor_buf[2 * LEN_X];
- Word16 *pt_exp1, *pt_exp2, *pt_exp3, *pt_exp4;
+ Word16 scaled_buf_exp[2 * LEN_X + 3 * ( DELTA_COH - 1 )];
+ Word16 cor_buf[2 * LEN_X], cor_buf_exp[2 * LEN_X];
Word16 *pt1, *pt2, *pt3, *pt4, *pt5, *pt6;
- Word16 *pt_cor0, *pt_cor1, *pt_cor2, *pt_cor3, *pt_cor4, *pt_cor5, *pt_cor6;
+ Word16 *pt_cor0, *pt_cor1, *pt_cor2, *pt_cor3, *pt_cor4;
+ Word16 *pt_cor0_exp, *pt_cor1_exp, *pt_cor2_exp, *pt_cor3_exp, *pt_cor4_exp;
Word16 thres1[6];
Word16 diff, cnt, ind, ind1, offset, offset1, offset_la, offset_la1, coh_flag, coh_flag1;
Word16 ind_corX, ind1_corX;
@@ -1316,10 +1118,11 @@ void pitch_ol_ivas_fx(
Word16 len_temp;
Word16 pitchX[NHFR][2 * NSECT], pitch_tmp[2 * NHFR], ind_tmp[2 * NHFR], tmp_buf[NHFR + 1];
- Word16 enr0[NSECT], enr0_exp[NSECT], enr0_1[NSECT], enr0_1_exp[NSECT], enr1, enr1_exp, enr2_exp;
- Word32 enr, enr2, Ltmp;
+ Word16 enr0_exp[NSECT], enr0_1_exp[NSECT], enr1_exp;
+ Word32 enr0[NSECT], enr0_1[NSECT], enr1;
+ Word64 temp, temp1;
+ Word32 Ltmp;
Word16 fac, tmp16, tmp16_2;
- Word16 qCorX, qScaledX;
Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT], cor_tmp[2 * NHFR], cor_mean;
const Word16 *len, *len1, *sublen, *sublen1, *pit_max, *sec_length, *sec_length1;
@@ -1327,6 +1130,8 @@ void pitch_ol_ivas_fx(
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
#endif
+ Word16 new_q;
+ new_q = sub( 63, shl( qwsp, 1 ) );
/*--------------------------------------------------------------*
* Initialization
@@ -1354,7 +1159,7 @@ void pitch_ol_ivas_fx(
test();
test();
IF( ( ( NE_16( bwidth, NB ) ) && ( GT_16( *old_pitch, PIT_MIN ) ) ) ||
- ( ( EQ_16( bwidth, NB ) ) && ( ( GT_16( *old_pitch, PIT_MIN2_1 ) ) || ( LT_16( *old_thres, 3277 ) ) ) ) ) /* 0.1 inQ15*/
+ ( ( EQ_16( bwidth, NB ) ) && ( ( GT_16( *old_pitch, PIT_MIN2_1 ) ) || ( LT_16( *old_thres, 1638 /* 0.1 in Q14*/ ) ) ) ) )
{
pit_min = PIT_MIN / OPL_DECIM;
move16();
@@ -1423,21 +1228,16 @@ void pitch_ol_ivas_fx(
pt1 = scale1 + DELTA_COH - 1;
pt2 = pt1;
- tmp16 = mult( negate( *old_thres ), MAX_16 / DELTA_COH );
- k = *old_thres;
- move16();
+ tmp16 = mult( *old_thres, -32768 / DELTA_COH ); // Q14
+ k = add( *old_thres, ONE_IN_Q14 ); // Q14
FOR( i = 0; i < DELTA_COH; i++ )
{
- /*
- * *pt1 = ( -(*old_thres)/DELTA_COH * i + *old_thres+1.0f );
- * To keep Q15 values, the following code does not add 1 to the result.
- * A scaling factor must be applied accordingly (see next use of scale1)
- */
- *pt1 = k;
+ *pt1 = k; // Q14
+ *pt2-- = *pt1++; // Q14
move16();
- k = add( k, tmp16 );
- *pt2-- = *pt1++;
move16();
+
+ k = add( k, tmp16 ); // Q14
}
/*-----------------------------------------------------------------------------*
@@ -1454,9 +1254,13 @@ void pitch_ol_ivas_fx(
* Loop for all three half-frames (current frame + look-ahead)
*-----------------------------------------------------------------*/
pt_cor0 = scaled_buf + DELTA_COH - 1;
+ pt_cor0_exp = scaled_buf_exp + DELTA_COH - 1;
pt_cor2 = pt_cor0 - pit_min + old_tmp;
+ pt_cor2_exp = pt_cor0_exp - pit_min + old_tmp;
+
pt_cor4 = pt_cor0 - pit_min1 + old_tmp + ( DELTA_COH - 1 ) + len_x;
+ pt_cor4_exp = pt_cor0_exp - pit_min1 + old_tmp + ( DELTA_COH - 1 ) + len_x;
FOR( i = 0; i < NHFR; i++ ) /* i = 0, 1, 2 */
{
@@ -1464,15 +1268,14 @@ void pitch_ol_ivas_fx(
pt2 = pt1 - pit_min; /* *pt2 -> Q12 */
pt4 = pt1 - pit_min1; /* *pt4 -> Q12 */
- enr = 0;
+ temp = 0;
+ move64();
pt_cor1 = pt_cor0;
- pt_cor3 = pt_cor0 + ( DELTA_COH - 1 ) + len_x;
+ pt_cor1_exp = pt_cor0_exp;
- pt_exp1 = scaled_buf_exp + DELTA_COH - 1;
- pt_exp2 = pt_exp1;
- pt_exp3 = scaled_buf_exp + 2 * ( DELTA_COH - 1 ) + len_x;
- pt_exp4 = pt_exp3;
+ pt_cor3 = pt_cor0 + ( DELTA_COH - 1 ) + len_x;
+ pt_cor3_exp = pt_cor0_exp + ( DELTA_COH - 1 ) + len_x;
IF( LT_16( i, NHFR - 1 ) ) /* First two half-frames (current frame) */
{
@@ -1488,72 +1291,83 @@ void pitch_ol_ivas_fx(
/* 1st set */
k = (Word16) ( pt1 - pt3 );
move16();
- Flag overflow = 0;
FOR( k = add( k, len[j] ); k > 0; k-- )
{
- enr = L_mac0_o( enr, *pt3, *pt3, &overflow );
+ temp = W_mac0_16_16( temp, *pt3, *pt3 ); // 2*qwsp
pt3++;
}
- /* keep Q15 normalized result */
- cnt = norm_l( enr );
- enr0[j] = extract_h( L_shl( enr, cnt ) );
- enr0_exp[j] = sub( 30, cnt );
- move16();
+ IF( temp == 0 )
+ {
+ enr0[j] = 21474836; // 0.01 in Q31
+ enr0_exp[j] = 0;
+ move32();
+ move16();
+ }
+ ELSE
+ {
+ cnt = W_norm( temp );
+ enr0[j] = W_extract_h( W_shl( temp, cnt ) ); // 2*qwsp+cnt-32
+ enr0_exp[j] = sub( new_q, cnt ); // 31-(2*qwsp+cnt-32)
+ move32();
+ move16();
+ }
/* Reduce complexity (length of 'enr2' section is equal or larger than 'enr') */
pt5 = pt3;
- enr2 = enr; /* sets to 'enr' in 1 clock */
- move32();
/* 2nd set */
k = (Word16) ( pt1 - pt5 );
move16();
+ temp1 = temp;
+ move64();
FOR( k = add( k, len1[j] ); k > 0; k-- )
{
- enr2 = L_mac0_o( enr2, *pt5, *pt5, &overflow );
+ temp1 = W_mac0_16_16( temp1, *pt5, *pt5 ); // 2*qwsp
pt5++;
}
- cnt = norm_l( enr2 );
- enr0_1[j] = extract_h( L_shl( enr2, cnt ) );
- enr0_1_exp[j] = sub( 30, cnt );
- move16();
+ IF( temp1 == 0 )
+ {
+ enr0_1[j] = 21474836; // 0.01 in Q31
+ enr0_1_exp[j] = 0;
+ move32();
+ move16();
+ }
+ ELSE
+ {
+ cnt = W_norm( temp1 );
+ enr0_1[j] = W_extract_h( W_shl( temp1, cnt ) ); // 2*qwsp+cnt-32
+ enr0_1_exp[j] = sub( new_q, cnt ); // 31-(2*qwsp+cnt-32)
+ move32();
+ move16();
+ }
}
/*----------------------------------------------------------*
* Find correlation for the non-overlapping pitch lag values
*----------------------------------------------------------*/
- exp_sect[subsect0] = 0;
- move16();
- pt_cor5 = pt_cor1;
- pt_cor6 = pt_cor3;
-
- tmp16 = exp_sect[subsect0];
- move16();
k = (Word16) ( pt2 - pt1 + pit_max[subsect0] );
+ move16();
- IF( k >= 0 )
+ FOR( ; k >= 0; k-- )
{
- len_temp = sublen[0];
- move16();
-
- FOR( ; k >= 0; k-- )
+ temp = 0;
+ move64();
+ FOR( m = 0; m < sublen[0]; m++ )
{
- /* Keep Q15 normalized result */
- /* shr by 1 to make room for scaling in the neighbourhood of the extrapolated pitch */
- /* Update exponent to reflect shr by 1 */
- *pt_cor1 = extract_h( L_shr( Dot_product12_ivas( pt1, pt2--, len_temp, pt_exp1 ), 1 ) );
-
- /* save the biggest exponent */
- tmp16 = s_max( tmp16, *pt_exp1 );
-
- pt_cor1++;
- pt_exp1++;
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
}
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt ); // 15-(2*qwsp+cnt-32-16)
+ move16();
+ move16();
+
+ pt2--;
+ pt_cor1++;
+ pt_cor1_exp++;
}
- exp_sect[subsect0] = tmp16;
- move16();
/*----------------------------------------------------------*
* For each subsection, find the correlation
@@ -1566,44 +1380,73 @@ void pitch_ol_ivas_fx(
k = (Word16) ( pt2 - pt1 );
move16();
k = add( k, pit_max[j + 1] );
- exp_sect[j + 1] = 0;
- move16();
- exp_sect1[j] = 0;
- move16();
- IF( k >= 0 )
+ /* Keep Q15 normalized result */
+ IF( LT_16( sublen[j], sublen1[j] ) )
{
- ind = exp_sect[j + 1];
- move16();
- ind1 = exp_sect1[j];
- move16();
+ FOR( ; k >= 0; k-- )
+ {
+ temp = W_mult0_16_16( pt1[0], pt2[0] ); // 2*qwsp
+ FOR( m = 1; m < sublen[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt );
+ move16();
+ move16();
+ FOR( ; m < sublen1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor3 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor3_exp = sub( new_q, cnt );
+ move16();
+ move16();
+
+ pt_cor1++;
+ pt_cor1_exp++;
+ pt_cor3++;
+ pt_cor3_exp++;
+ pt2--;
+ }
+ }
+ ELSE
+ {
FOR( ; k >= 0; k-- )
{
- /* Keep Q15 normalized result */
- /* shr by 1 to make room for scaling in the neighbourhood of the extrapolated pitch */
- /* Update exponent to reflect shr by 1 (done in Dot_product12_OL() for pt_cor3/pt_exp3) */
- *pt_cor1 = extract_h( L_shr( Dot_product12_OL_ivas( pt_cor3, pt1, pt2--, sublen[j], sublen1[j], pt_exp1, pt_exp3 ), 1 ) );
- /* The line above replaces:
- * *pt_cor1 = shr(extract_h(Dot_product12(pt1, pt2, Sublen[j], pt_exp1)),1); move16();
- * *pt_cor3 = shr(extract_h(Dot_product12(pt1, pt2--, Sublen1[j+i*7], pt_exp3)),1); move16();
- */
+ temp = W_mult0_16_16( pt1[0], pt2[0] ); // 2*qwsp
+ FOR( m = 1; m < sublen1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor3 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor3_exp = sub( new_q, cnt );
+ move16();
+ move16();
- /* save the biggest exponent */
- ind = s_max( ind, *pt_exp1 );
- ind1 = s_max( ind1, *pt_exp3 );
+ FOR( ; m < sublen[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt );
+ move16();
+ move16();
pt_cor1++;
- pt_exp1++;
+ pt_cor1_exp++;
pt_cor3++;
- pt_exp3++;
+ pt_cor3_exp++;
+ pt2--;
}
- exp_sect[j + 1] = ind;
- move16();
- exp_sect1[j] = ind1;
- move16();
- } /* IF (k >= 0) */
- } /* FOR (j = subsect0; ... */
+ }
+ } /* FOR (j = subsect0; ... */
}
ELSE /* 3rd half-frame (look-ahead) */
{
@@ -1614,7 +1457,6 @@ void pitch_ol_ivas_fx(
/*-----------------------------------------------------------------*
* For each section in both sets, find fixed vector energy
*-----------------------------------------------------------------*/
- Flag overflow = 0;
FOR( j = sect0; j < NSECT; j++ ) /* loop for each section */
{
/* 1st set */
@@ -1623,93 +1465,91 @@ void pitch_ol_ivas_fx(
FOR( k = add( k, len[j] ); k > 0; k-- )
{
- enr = L_mac0_o( enr, *pt3, *pt3, &overflow );
+ temp = W_mac0_16_16( temp, *pt3, *pt3 );
pt3--;
}
-
- cnt = norm_l( enr );
- enr0[j] = extract_h( L_shl( enr, cnt ) ); /*qwsp+cnt-16*/
- enr0_exp[j] = sub( 30, cnt );
- move16();
+ IF( temp == 0 )
+ {
+ enr0[j] = 21474836; // 0.01 in Q31
+ enr0_exp[j] = 0;
+ move32();
+ move16();
+ }
+ ELSE
+ {
+ cnt = W_norm( temp );
+ enr0[j] = W_extract_h( W_shl( temp, cnt ) ); // 2*qwsp+cnt-32
+ enr0_exp[j] = sub( new_q, cnt ); // 31-(2*qwsp+cnt-32)
+ move32();
+ move16();
+ }
/* Reduce complexity (length of 'enr2' section is equal or larger than 'enr') */
pt5 = pt3;
- enr2 = enr;
- move16();
+ temp1 = temp;
+ move64();
/* 2nd set */
k = (Word16) ( pt5 - pt6 );
move16();
-
FOR( k = add( k, len1[j] ); k > 0; k-- )
{
- enr2 = L_mac0_o( enr2, *pt5, *pt5, &overflow );
+ temp1 = W_mac0_16_16( temp1, *pt5, *pt5 ); // 2*qwsp
pt5--;
}
-
- cnt = norm_l( enr2 );
- enr0_1[j] = extract_h( L_shl( enr2, cnt ) ); /*qwsp+cnt-16*/
- enr0_1_exp[j] = sub( 30, cnt );
- move16();
+ IF( temp1 == 0 )
+ {
+ enr0_1[j] = 21474836; // 0.01 in Q31
+ enr0_1_exp[j] = 0;
+ move32();
+ move16();
+ }
+ ELSE
+ {
+ cnt = W_norm( temp1 );
+ temp1 = W_shl( temp1, cnt ); // 2*qwsp+cnt
+ enr0_1[j] = W_extract_h( temp1 ); // 2*qwsp+cnt-32
+ enr0_1_exp[j] = sub( new_q, cnt ); // 31-(2*qwsp+cnt-32)
+ move32();
+ move16();
+ }
}
- /* Set pointers */
+ /* Set pointers: same as IF/ELSE block */
+ pt2 = pt6 - pit_min;
+ k = 2;
+ move16();
IF( sect0 != 0 )
{
pt2 = pt6 - add( pit_max[1], 1 );
k = sub( pit_max[2], pit_max[1] );
move16();
}
- ELSE
- {
- pt2 = pt6 - pit_min;
- k = 2;
- move16();
- }
/*-----------------------------------------------------------------*
* Find correlation for the non-overlapping pitch lag values
*-----------------------------------------------------------------*/
- exp_sect[subsect0] = 0;
- move16();
- pt_cor5 = pt_cor1;
- pt_cor6 = pt_cor3;
- tmp16 = exp_sect[subsect0];
+ len_temp = sublen[0];
move16();
- IF( k > 0 )
+ FOR( ; k > 0; k-- )
{
- len_temp = sublen[0];
- move16();
-
- FOR( ; k > 0; k-- )
+ temp = 0;
+ move64();
+ FOR( m = 0; m < len_temp; m++ )
{
- /* Following lines are equivalent of Dot_product12() but with a backward incrementing */
- Ltmp = L_deposit_l( 1 );
- FOR( m = 0; m < len_temp; m++ )
- {
- Ltmp = L_mac_o( Ltmp, pt6[-m], pt2[-m], &overflow );
- }
-
- /* Normalize acc in Q31 */
- tmp16_2 = norm_l( Ltmp );
- Ltmp = L_shl( Ltmp, tmp16_2 );
- *pt_exp1 = sub( 30, tmp16_2 );
- move16(); /* exponent = 0..30 */
-
- /* Save result */
- *pt_cor1 = extract_h( L_shr( Ltmp, 1 ) );
-
- /* Save the biggest exponent */
- tmp16 = s_max( tmp16, *pt_exp1 );
-
- pt_cor1++;
- pt_exp1++;
- pt2--;
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
}
- exp_sect[subsect0] = tmp16;
+ tmp16_2 = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, tmp16_2 ) ) ); // 2*qwsp+tmp16_2
+ *pt_cor1_exp = sub( new_q, tmp16_2 ); // 2*qwsp+tmp16_2-32-16
move16();
+ move16();
+
+ pt_cor1++;
+ pt_cor1_exp++;
+ pt2--;
}
/*-----------------------------------------------------------------*
@@ -1718,125 +1558,115 @@ void pitch_ol_ivas_fx(
FOR( j = subsect0; j < NSUBSECT; j++ )
{
- exp_sect[j + 1] = 0;
- move16();
- exp_sect1[j] = 0;
- move16();
-
- ind = exp_sect[j + 1];
- move16();
- ind1 = exp_sect1[j];
- move16();
-
k = sub( pit_max[j + 1], pit_max[j] );
- FOR( ; k > 0; k-- )
+ IF( LT_16( sublen[j], sublen1[j] ) )
{
- *pt_cor1 = extract_h( L_shr( Dot_product12_OL_back_ivas( pt_cor3, pt6, pt2--, sublen[j], sublen1[j], pt_exp1, pt_exp3 ), 1 ) );
-
- /* Save the biggest exponent */
- ind = s_max( ind, *pt_exp1 );
- ind1 = s_max( ind1, *pt_exp3 );
-
- pt_cor1++;
- pt_exp1++;
- pt_cor3++;
- pt_exp3++;
- }
- exp_sect[j + 1] = ind;
- move16();
- exp_sect1[j] = ind1;
- move16();
- }
- } /* 3rd half-frame (look-ahead) */
+ FOR( ; k > 0; k-- )
+ {
+ temp = W_mult0_16_16( pt6[0], pt2[0] ); // 2*qwsp
+ FOR( m = 1; m < sublen[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt );
+ move16();
+ move16();
- /* Scale all values in each section to the same exponent for upcoming Find_max() */
- offset = 0;
- move16();
- offset1 = 0;
- move16();
- exp_sect1[7] = 0; /* padding */
- move16();
- FOR( j = sect0; j < NSECT; j++ )
- {
- exp_sect0 = s_max( exp_sect[j * 2], exp_sect[j * 2 + 1] );
+ FOR( ; m < sublen1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor3 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor3_exp = sub( new_q, cnt );
+ move16();
+ move16();
- /* scaling of exp for track 1 */
- offset = add( offset, sec_length[j] );
- k = (Word16) ( pt_cor0 - pt_cor5 );
- move16();
- FOR( k = add( k, offset ); k > 0; k-- )
- {
- cnt = sub( exp_sect0, *pt_exp2 );
- tmp16 = s_min( 15, cnt );
- if ( cnt > 0 )
- {
- tmp16 = shr( *pt_cor5, tmp16 );
+ pt_cor1++;
+ pt_cor1_exp++;
+ pt_cor3++;
+ pt_cor3_exp++;
+ pt2--;
+ }
}
- if ( cnt > 0 )
+ ELSE
{
- *pt_cor5 = tmp16;
- move16();
- }
- *pt_exp2 = s_max( *pt_exp2, exp_sect0 );
- move16();
- pt_cor5++;
- pt_exp2++;
- }
+ FOR( ; k > 0; k-- )
+ {
+ temp = W_mult0_16_16( pt6[0], pt2[0] ); // 2*qwsp
+ FOR( m = 1; m < sublen1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor3 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor3_exp = sub( new_q, cnt );
+ move16();
+ move16();
- exp_sect0 = s_max( exp_sect1[j * 2], exp_sect1[j * 2 + 1] );
+ FOR( ; m < sublen[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt );
+ move16();
+ move16();
- /* scaling of exp for track 2 */
- offset1 = add( offset1, sec_length1[j] );
- k = (Word16) ( pt_cor0 - pt_cor6 + ( DELTA_COH - 1 ) );
- move16();
- k = add( k, len_x );
- FOR( k = add( k, offset1 ); k > 0; k-- )
- {
- cnt = sub( exp_sect0, *pt_exp4 );
- tmp16 = s_min( 15, cnt );
- if ( cnt > 0 )
- {
- tmp16 = shr( *pt_cor6, tmp16 );
- }
- if ( cnt > 0 )
- {
- *pt_cor6 = tmp16;
- move16();
+ pt_cor1++;
+ pt_cor1_exp++;
+ pt_cor3++;
+ pt_cor3_exp++;
+ pt2--;
+ }
}
- *pt_exp4 = s_max( *pt_exp4, exp_sect0 );
- move16();
- pt_cor6++;
- pt_exp4++;
}
- } /* FOR (j = sect0; ... */
+ } /* 3rd half-frame (look-ahead) */
- Copy( pt_cor0, cor_buf, len_x ); /* Save unscaled correlation vector */
+ /* Scale all values in each section to the same exponent for upcoming Find_max() */
+ Copy( pt_cor0, cor_buf, len_x ); /* Save unscaled correlation vector */
+ Copy( pt_cor0_exp, cor_buf_exp, len_x ); /* Save unscaled correlation vector */
Copy( pt_cor0 + ( DELTA_COH - 1 ) + len_x, cor_buf + len_x, len_x1 );
+ Copy( pt_cor0_exp + ( DELTA_COH - 1 ) + len_x, cor_buf_exp + len_x, len_x1 );
/*-----------------------------------------------------------------*
* Scale correlation function in the neighbourhood of
* the extrapolated pitch
*-----------------------------------------------------------------*/
pt_cor1 = pt_cor2 - ( DELTA_COH - 1 );
+ pt_cor1_exp = pt_cor2_exp - ( DELTA_COH - 1 );
pt_cor3 = pt_cor4 - ( DELTA_COH - 1 );
+ pt_cor3_exp = pt_cor4_exp - ( DELTA_COH - 1 );
pt2 = scale1;
FOR( k = 0; k < 2 * DELTA_COH - 1; k++ )
{
- /* all Q15 here */
- *pt_cor1 = add( *pt_cor1, mult( *pt_cor1, *pt2 ) );
+ *pt_cor1 = mult( *pt_cor1, *pt2 ); // *pt_cor1_exp+1
+ *pt_cor1_exp = add( *pt_cor1_exp, 1 ); // *pt_cor1_exp+1
+ move16();
+ move16();
+
+ *pt_cor3 = mult( *pt_cor3, *pt2++ ); // *pt_cor3_exp+1
+ *pt_cor3_exp = add( *pt_cor3_exp, 1 ); // *pt_cor1_exp+1
move16();
- *pt_cor3 = add( *pt_cor3, mult( *pt_cor3, *pt2++ ) );
move16();
pt_cor1++;
+ pt_cor1_exp++;
pt_cor3++;
+ pt_cor3_exp++;
}
/* Update for next half-frame & look-ahead */
pt_cor2 = pt_cor0 - pit_min + old_tmp1;
+ pt_cor2_exp = pt_cor0_exp - pit_min + old_tmp1;
+
pt_cor4 = pt_cor0 - pit_min1 + old_tmp1 + ( DELTA_COH - 1 ) + len_x;
+ pt_cor4_exp = pt_cor0_exp - pit_min1 + old_tmp1 + ( DELTA_COH - 1 ) + len_x;
/*-----------------------------------------------------------------*
* For each section, find maximum correlation and compute
@@ -1844,11 +1674,11 @@ void pitch_ol_ivas_fx(
*-----------------------------------------------------------------*/
pt_cor1 = pt_cor0;
- pt_exp1 = scaled_buf_exp + DELTA_COH - 1;
+ pt_cor1_exp = pt_cor0_exp;
offset = 0;
move16();
pt_cor3 = pt_cor0 + ( DELTA_COH - 1 ) + len_x;
- pt_exp3 = scaled_buf_exp + 2 * ( DELTA_COH - 1 ) + len_x;
+ pt_cor3_exp = pt_cor0_exp + ( DELTA_COH - 1 ) + len_x;
offset1 = 0;
move16();
@@ -1871,93 +1701,88 @@ void pitch_ol_ivas_fx(
}
/* 1st set of candidates */
- ind = add( maximum_fx( pt_cor1, sec_length[j], &ftmp ), offset );
+ ind = add( maximum_exp_fx( pt_cor1, pt_cor1_exp, sec_length[j] ), offset );
pitchX[i][j] = add( ind, pit_min );
move16();
pt2 = pt1 - pitchX[i][j] + /*-*/ offset_la; /* selected moving vector */
enr1_exp = 0;
move16();
-#ifdef BASOP_NOGLOB
- enr1 = add_o( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1, &Overflow );
-#else
- enr1 = add( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1 );
-#endif
- enr2 = L_mult( enr0[j], enr1 );
- enr2_exp = norm_l( enr2 );
- enr2 = L_shl( enr2, enr2_exp );
- enr2_exp = sub( 31, add( sub( 28, add( enr0_exp[j], enr1_exp ) ), add( enr2_exp, 1 ) ) );
+ /* enr1 = dotp( pt2, pt2, len[j] ) + 0.01f; */
+ temp = 167772 /*0.01f in Q24*/;
+ move64();
+ FOR( m = 0; m < len[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt2[m], pt2[m] ); // 2*qwsp
+ }
+ temp = W_shl( temp, sub( Q24, shl( qwsp, 1 ) ) ); // Q24
+ enr1_exp = W_norm( temp );
+ enr1 = W_extract_h( W_shl( temp, enr1_exp ) ); // enr1_exp+24-32
+ enr1_exp = sub( 39, enr1_exp ); // 31-(enr1_exp+24-32)
- enr2 = Isqrt_lc( enr2, &enr2_exp ); /* 1/sqrt(energy) */ /*31-enr2_exp*/
- enr1_exp = norm_l( enr2 );
- enr1 = extract_h( L_shl( enr2, enr1_exp ) ); /*31-enr2_exp+enr1_exp-16*/
- enr1_exp = sub( enr2_exp, enr1_exp ); /*15-enr1_exp*/
+ enr1 = Mpy_32_32( enr0[j], enr1 );
+ enr1_exp = add( enr0_exp[j], enr1_exp );
- Ltmp = L_mult0( cor_buf[ind], enr1 );
- qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp1[ind] ) );
+ enr1 = ISqrt32( enr1, &enr1_exp ); /* 1/sqrt(energy) */ /*31-enr2_exp*/
+
+ Ltmp = Mpy_32_16_1( enr1, cor_buf[ind] );
#ifdef BASOP_NOGLOB
- corX[i][j] = extract_h( L_shr_o( Ltmp, sub( qCorX, 31 ), &Overflow ) );
-#else /* BASOP_NOGLOB */
- corX[i][j] = extract_h( L_shr( Ltmp, sub( qCorX, 31 ) ) );
-#endif /* BASOP_NOGLOB */
- qCorX = 31;
+ corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15
+#else /* BASOP_NOGLOB */
+ corX[i][j] = extract_h( L_shl( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) );
+#endif /* BASOP_NOGLOB */
move16();
- Ltmp = L_mult0( pt_cor0[ind], enr1 );
- qScaledX = add( sub( 15, enr1_exp ), sub( 14, pt_exp1[ind] ) );
- scaledX[i][j] = round_fx( L_shl( Ltmp, sub( 16 + 12, qScaledX ) ) );
- qScaledX = 12;
+ Ltmp = Mpy_32_16_1( enr1, pt_cor0[ind] );
+ scaledX[i][j] = round_fx( L_shl( Ltmp, sub( add( enr1_exp, pt_cor0_exp[ind] ), 3 ) ) ); // Q12
move16();
pt_cor1 += sec_length[j];
- move16();
+ pt_cor1_exp += sec_length[j];
offset = add( offset, sec_length[j] );
/* 2nd set of candidates */
- ind1 = add( maximum_fx( pt_cor3, sec_length1[j], &ftmp ), offset1 );
+ ind1 = add( maximum_exp_fx( pt_cor3, pt_cor3_exp, sec_length1[j] ), offset1 );
pitchX[i][j + NSECT] = add( ind1, pit_min1 );
move16();
pt4 = pt1 - pitchX[i][j + NSECT] + /*-*/ offset_la1;
move16(); /* selected moving vector */
enr1_exp = 0;
move16();
-#ifdef BASOP_NOGLOB
- enr1 = add_o( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1, &Overflow );
-#else
- enr1 = add( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1 );
-#endif
- enr2 = L_mult( enr0_1[j], enr1 );
- enr2_exp = norm_l( enr2 );
- enr2 = L_shl( enr2, enr2_exp );
+ /* enr1 = dotp(pt4, pt4, len1[j]) + 0.01f; */
+ temp = 167772 /*0.01f in Q24*/;
+ move64();
+ FOR( m = 0; m < len1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt4[m], pt4[m] ); // 2*qwsp
+ }
+ temp = W_shl( temp, sub( Q24, shl( qwsp, 1 ) ) ); // Q24
+ enr1_exp = W_norm( temp );
+ enr1 = W_extract_h( W_shl( temp, enr1_exp ) ); // enr1_exp+24-32
+ enr1_exp = sub( 39, enr1_exp ); // 31-(enr1_exp+24-32)
- enr2_exp = sub( 31, add( sub( 28, add( enr0_1_exp[j], enr1_exp ) ), add( enr2_exp, 1 ) ) );
- enr2 = Isqrt_lc( enr2, &enr2_exp ); /* 1/sqrt(energy) */ /*31-enr2_exp*/
- enr1_exp = norm_l( enr2 );
- enr1 = extract_h( L_shl( enr2, enr1_exp ) ); /*31-enr2_exp+enr1_exp-16*/
- enr1_exp = sub( enr2_exp, enr1_exp ); /*15-enr1_exp*/
+ enr1 = Mpy_32_32( enr0_1[j], enr1 );
+ enr1_exp = add( enr0_1_exp[j], enr1_exp );
- Ltmp = L_mult0( cor_buf[ind1 + len_x], enr1 );
+ enr1 = ISqrt32( enr1, &enr1_exp ); /* 1/sqrt(energy) */ /*31-enr1_exp*/
- qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp3[ind1] ) );
+ Ltmp = Mpy_32_16_1( enr1, cor_buf[ind1 + len_x] );
#ifdef BASOP_NOGLOB
- corX[i][j + NSECT] = extract_h( L_shr_o( Ltmp, qCorX - 31, &Overflow ) );
-#else /* BASOP_NOGLOB */
- corX[i][j + NSECT] = extract_h( L_shr( Ltmp, qCorX - 31 ) );
-#endif /* BASOP_NOGLOB */
- qCorX = 31;
+ corX[i][j + NSECT] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ), &Overflow ) ); // Q15
+#else /* BASOP_NOGLOB */
+ corX[i][j + NSECT] = extract_h( L_shl( Ltmp, add( enr1_exp, cor_buf_exp_len_x1[ind1] ) ) );
+#endif /* BASOP_NOGLOB */
move16();
- Ltmp = L_mult0( pt_cor0[ind1 + ( DELTA_COH - 1 ) + len_x], enr1 );
- qScaledX = add( sub( 15, enr1_exp ), sub( 14, pt_exp3[ind1] ) );
- scaledX[i][j + NSECT] = round_fx( L_shl( Ltmp, sub( 16 + 12, qScaledX ) ) );
- /*scaledX[i][j+NSECT] = saturate(L_shr(Ltmp, qScaledX-12));*/
- qScaledX = 12;
+ Ltmp = Mpy_32_16_1( enr1, pt_cor0[ind1 + ( DELTA_COH - 1 ) + len_x] );
+ scaledX[i][j + NSECT] = round_fx( L_shl( Ltmp, sub( add( enr1_exp, pt_cor0_exp[ind1 + ( DELTA_COH - 1 ) + len_x] ), 3 ) ) ); // Q12
move16();
+ /*scaledX[i][j+NSECT] = saturate(L_shr(Ltmp, qScaledX-12));*/
pt_cor3 += sec_length1[j];
- move16();
+ pt_cor3_exp += sec_length1[j];
offset1 = add( offset1, sec_length1[j] );
} /* FOR j < NSECT */
@@ -2132,10 +1957,11 @@ void pitch_ol_ivas_fx(
{
/* The threshold increase is directly dependent on normalized correlation */
/* *old_thres += (0.16f * cor_mean); */
- *old_thres = round_fx( L_mac( L_deposit_h( *old_thres ), 5243, cor_mean ) );
+ *old_thres = round_fx( L_mac0( L_deposit_h( *old_thres ), 5243 /* 0.16f in Q15 */, cor_mean ) ); // Q14
+ move16();
}
- *old_thres = s_min( *old_thres, THRES3 );
+ *old_thres = s_min( *old_thres, 11469 /* 0.7f in Q14 */ ); // Q14
move16();
IF( GT_16( voicing[1], voicing[0] ) )
diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h
index cff02d9111782ac2d48c4d6e550a934184d266c9..8a0c0b82933b1dca2ddb7053b878e1840b1f97b7 100644
--- a/lib_enc/prot_fx_enc.h
+++ b/lib_enc/prot_fx_enc.h
@@ -46,21 +46,21 @@
*----------------------------------------------------------------------------------*/
ivas_error acelp_core_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 inp_fx[], /* i : i signal of the current frame */
- const Word32 ener_fx, /* i : residual energy from Levinson-Durbin*/
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes*/
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors */
- const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame */
- Word16 vad_hover_flag_fx, /* i : VAD hangover flag */
- const Word16 attack_flag, /* i : attack flag (GSC or TC) */
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits_fx, /* o : number of unused bits */
+ const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/
+ const Word32 ener_fx, /* i : residual energy from Levinson-Durbin Q6*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors Qx*/
+ const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors Qx*/
+ Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame Q15*/
+ Word16 vad_hover_flag_fx, /* i : VAD hangover flag Q0*/
+ const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn*/
+ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word16 *unbits_fx, /* o : number of unused bits Q0*/
const Word16 Q_new,
const Word16 shift
#ifdef ADD_LRTD
@@ -88,20 +88,20 @@ void analy_lp_ivas_fx(
Word16 *Q_r /*stores q for ener*/ );
void analy_lp_fx(
- const Word16 speech[], /* i : pointer to the speech frame */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 L_look, /* i : look-ahead */
- Word32 *ener, /* o : residual energy from Levinson-Durbin */
- Word16 A[], /* o : A(z) filter coefficients */
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
- Word16 lsp_new[], /* o : current frame LSPs */
- Word16 lsp_mid[], /* o : current mid-frame LSPs */
- Word16 lsp_old[], /* i/o: previous frame unquantized LSPs */
- const Word16 Top[2], /* i : open loop pitch lag */
- const Word16 Tnc[2], /* i : open loop pitch gain */
- const Word32 Core_sr, /* i : Internal core sampling rate */
- const Word16 sec_chan_low_rate, /* i : flag to signal second channel */
+ const Word16 speech[], /* i : pointer to the speech frame Q_new*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 L_look, /* i : look-ahead Q0*/
+ Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A[], /* o : A(z) filter coefficients Q14*/
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 lsp_new[], /* o : current frame LSPs Q15*/
+ Word16 lsp_mid[], /* o : current mid-frame LSPs Q15*/
+ Word16 lsp_old[], /* i/o: previous frame unquantized LSPs Q15*/
+ const Word16 Top[2], /* i : open loop pitch lag Q0*/
+ const Word16 Tnc[2], /* i : open loop pitch gain Q15*/
+ const Word32 Core_sr, /* i : Internal core sampling rate Q0*/
+ const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/
Word16 Q_new,
Word16 *Q_r );
@@ -149,8 +149,8 @@ void bw_detect_fx(
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 */
- const Word16 inp16k[], /* i : i signal @16 kHz */
+ 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,
@@ -160,10 +160,10 @@ void core_switching_post_enc_fx( /*done */
void core_switching_pre_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *old_inp_12k8, /* i : old i signal @12.8kHz */
- const Word16 *old_inp_16k, /* i : old i signal @16kHz */
- const Word16 active_cnt, /* i : active frame counter */
- const Word16 last_element_mode /* i : last_element_mode */
+ const Word16 *old_inp_12k8, /* i : old i signal @12.8kHz Qx*/
+ const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/
+ const Word16 active_cnt, /* i : active frame counter Q0*/
+ const Word16 last_element_mode /* i : last_element_mode Q0*/
);
Word16 correlation_shift_fx( /* o : noise dependent voicing correction Q15 */
@@ -172,16 +172,16 @@ Word16 correlation_shift_fx( /* o : noise dependent
void dtx_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 vad, /* i : vad flag */
- const Word16 speech[], /* i : Pointer to the speech frame */
+ const Word16 vad, /* i : vad flag Q0*/
+ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/
Word16 Q_speech /* i : Q factor for speech */
);
void dtx_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word32 ivas_total_brate, /* i : IVAS total bitrate */
- const Word16 vad, /* i : vad flag for DTX */
- const Word16 speech[], /* i : Pointer to the speech frame */
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/
+ const Word16 vad, /* i : vad flag for DTX Q0*/
+ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/
Word16 Q_speech /* i : Q factor for speech */
);
@@ -226,70 +226,75 @@ Word16 ffr_getSfWord32(
const Word16 len /*!< Length of i vector */
);
void find_tilt_ivas_fx(
- const Word32 fr_bands[], /* i : energy in frequency bands Q_new*/
- const Word32 bckr[], /* i : per band background noise energy estimate Q_new*/
- Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
- const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
- const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
- const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new - 2*/
- const Word16 corr_shift, /* i : normalized correlation correction Q15*/
- const Word16 bwidth, /* i : i signal bandwidth */
- const Word16 max_band, /* i : maximum critical band */
- Word32 hp_E[], /* o : energy in HF Q_new*/
- const Word16 codec_mode, /* i : MODE1 or MODE2 */
- const Word16 Q_new, /* i : scaling factor */
- Word32 *bckr_tilt_lt,
- Word16 Opt_vbr_mode );
+ const Word32 fr_bands[], /* i : energy in frequency bands Q_new*/
+ const Word32 bckr[], /* i : per band background noise energy estimate Q_new*/
+ Word32 ee[2], /* o : lf/hf E ration for present frame Q_bckr*/
+ const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
+ const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
+ const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new - 2*/
+ const Word16 corr_shift, /* i : normalized correlation correction Q15*/
+ const Word16 bwidth, /* i : input signal bandwidth Q0*/
+ const Word16 max_band, /* i : maximum critical band Q0*/
+ Word32 hp_E[], /* o : energy in HF Q_new*/
+ const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/
+ const Word16 Q_new, /* i : scaling factor */
+ Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16*/
+ ,
+ Word16 Opt_vbr_mode /* Q0 */
+);
void find_tilt_fx(
- const Word32 fr_bands[], /* i : energy in frequency bands Q_new + Q_SCALE*/
- const Word32 bckr[], /* i : per band background noise energy estimate Q_new + Q_SCALE*/
- Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
- const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
- const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
+ const Word32 fr_bands[], /* i : energy in frequency bands Q_new + Q_SCALE*/
+ const Word32 bckr[], /* i : per band background noise energy estimate Q_new + Q_SCALE*/
+ Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
+ const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
+ const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new + Q_SCALE - 2*/
- const Word16 corr_shift, /* i : normalized correlation correction Q15*/
- const Word16 bwidth, /* i : i signal bandwidth */
- const Word16 max_band, /* i : maximum critical band */
+ const Word16 corr_shift, /* i : normalized correlation correction Q15*/
+ const Word16 bwidth, /* i : input signal bandwidth Q0*/
+ const Word16 max_band, /* i : maximum critical band Q0*/
Word32 hp_E[], /* o : energy in HF Q_new + Q_SCALE*/
- const Word16 codec_mode, /* i : MODE1 or MODE2 */
- const Word16 Q_new, /* i : scaling factor */
- Word32 *bckr_tilt_lt,
- Word16 Opt_vbr_mode );
+ const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/
+ const Word16 Q_new, /* i : scaling factor */
+ Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16*/
+ ,
+ Word16 Opt_vbr_mode /* Q0 */
+);
Word16 find_uv_ivas_fx( /* o : coding type */
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6 */
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15 */
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new */
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6 */
- Word32 *dE1X, /* o : sudden energy increase for S/M classifier */
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15 */
- const Word16 relE, /* i : relative frame energy Q8 */
- const Word16 Etot, /* i : total energy Q8 */
- const Word32 hp_E[], /* i : energy in HF Q_new */
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
- const Word16 last_core_orig, /* i : original last core */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
+ Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
+ const Word16 relE, /* i : relative frame energy Q8*/
+ const Word16 Etot, /* i : total energy Q8*/
+ const Word32 hp_E[], /* i : energy in HF q_hp_E*/
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
+ const Word16 last_core_orig, /* i : original last core Q0*/
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
const Word16 Q_new,
const Word16 q_hp_E );
+
Word16 find_uv_fx( /* o : coding type */
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
+ Encoder_State *st_fx, /* i/o: encoder state structure */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
#ifdef IVAS_CODE
Word32 *dE1X, /* o : sudden energy increase for S/M classifier */
#endif
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
- const Word16 relE, /* i : relative frame energy Q8*/
- const Word16 Etot, /* i : total energy Q8*/
- const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
+ const Word16 relE, /* i : relative frame energy Q8*/
+ const Word16 Etot, /* i : total energy Q8*/
+ const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
const Word16 Q_new,
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
const Word16 shift,
- const Word16 last_core_orig /* i : original last core */
+ const Word16 last_core_orig /* i : original last core Q0*/
#ifdef IVAS_CODE
,
STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */
@@ -353,6 +358,20 @@ void noise_est_down_fx(
const Word32 e_min /* i : minimum energy scaled Q_new + QSCALE */
);
+void noise_est_down_ivas_fx(
+ const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) */
+ const Word16 q_fr_bands, /* i : Q of fr_bands */
+ Word32 bckr[], /* i/o: per band background noise energy estimate */
+ Word32 tmpN[], /* o : temporary noise update */
+ Word32 enr[], /* o : averaged energy over both subframes */
+ const Word16 min_band, /* i : minimum critical band */
+ const Word16 max_band, /* i : maximum critical band */
+ Word16 *totalNoise, /* o : noise estimate over all critical bands */
+ Word16 Etot, /* i : Energy of current frame */
+ Word16 *Etot_last, /* i/o: Energy of last frame Q8 */
+ Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */
+);
+
void noise_est_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 old_pitch1, /* i : previous frame OL pitch[1] */
@@ -464,7 +483,8 @@ void pitch_ol_ivas_fx(
const Word16 relE, /* i : relative frame energy Q8 */
const Word16 last_class, /* i : frame classification of last frame */
const Word16 bwidth, /* i : bandwidth */
- const Word16 Opt_SC_VBR /* i : SC-VBR flag */
+ const Word16 Opt_SC_VBR, /* i : SC-VBR flag */
+ Word16 qwsp /* i : Q factor for wsp Q0 */
);
void pitch_ol_fx(
@@ -492,17 +512,17 @@ void pitch_ol_init_fx(
);
void Preemph_scaled(
- Word16 new_speech[], /* i : Speech to scale already on 14 bits*/
- Word16 *Q_new, /* o : Scaling factor */
- Word16 *mem_preemph, /* i/o: Preemph memory */
- Word16 *Q_max, /* i/o: Q_new limitation */
- const Word16 Preemph_factor, /* i : Preemphasis factor Q15 */
- const Word16 bits, /* i : Bit to remove from the output to (15-bits)*/
- const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */
- const Word16 L_Q_mem, /* i : Number of old scaling to take into account */
- const Word16 Lframe, /* i : Frame length */
- const Word16 last_coder_type, /* i : coder_type */
- const Word16 Search_scaling /* i : enable the search of a proper scaling factor*/
+ Word16 new_speech[], /* i : Speech to scale already on 14 bits Q_new*/
+ Word16 *Q_new, /* o : Scaling factor */
+ Word16 *mem_preemph, /* i/o: Preemph memory Q(-1)*/
+ Word16 *Q_max, /* i/o: Q_new limitation */
+ const Word16 Preemph_factor, /* i : Preemphasis factor Q15*/
+ const Word16 bits, /* i : Bit to remove from the output to (15-bits) */
+ const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */
+ const Word16 L_Q_mem, /* i : Number of old scaling to take into account Q0*/
+ const Word16 Lframe, /* i : Frame length Q0*/
+ const Word16 last_coder_type, /* i : coder_type Q0*/
+ const Word16 Search_scaling /* i : enable the search of a proper scaling factor Q0*/
);
void Scale_mem_enc(
@@ -518,17 +538,17 @@ void Scale_mem_enc(
Word16 *old_input_lp );
Word32 Scale_mem_pre_proc( /* o : Min energy scaled */
- Word16 ini_frame_fx, /* i : Frame number */
+ Word16 ini_frame_fx, /* i : Frame number Q0*/
Word16 Q_exp, /* i : Diff scaling factor */
Word16 *Q_new, /* i/o: Absolute scaling factor */
Word16 *old_speech, /* i/o: Speech memory */
- Word16 *mem_wsp, /* i/o: wsp vector memory */
- Word32 *enrO, /* i/o: Enr mem */
- Word32 *bckr, /* i/o: Back ground_fx ener mem */
- Word32 *ave_enr, /* i/o: Ave_enr mem */
- Word32 *ave_enr2, /* i/o: Ave_enr2 mem */
- Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame */
- Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago */
+ Word16 *mem_wsp, /* i/o: wsp vector memory st->mem_wsp_q*/
+ Word32 *enrO, /* i/o: Enr mem q_enrO*/
+ Word32 *bckr, /* i/o: Back ground_fx ener mem q_bckr*/
+ Word32 *ave_enr, /* i/o: Ave_enr mem Q_new + QSCALE*/
+ Word32 *ave_enr2, /* i/o: Ave_enr2 mem Q_new + QSCALE*/
+ Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame Q_new + QSCALE*/
+ Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago Q_new + QSCALE*/
Word32 *st_Bin_E_old );
void Scale_wsp(
@@ -540,7 +560,7 @@ void Scale_wsp(
Word16 *old_wsp, /* i/o: Old weighted speech buffer */
Word16 *mem_decim2, /* i/o: Decimation buffer */
Word16 *old_wsp12k8, /* i/o: wsp memory @ 12.8 kHz used in pitol2 */
- const Word16 Len_p_look /* i : L_frame + look ahead */
+ const Word16 Len_p_look /* i : L_frame + look ahead Q0*/
);
Word16 signal_clas_fx( /* o : classification for current frames */
@@ -783,28 +803,28 @@ Word16 wb_vad_fx(
Word16 wb_vad_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) Q_new+QSCALE*/
+ const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) q_fr_bands*/
+ const Word16 q_fr_bands, /* i : Q of fr_bands */
Word16 *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */
Word16 *clean_speech_HO, /* o : SC-VBR clean speech HO flag */
Word16 *NB_speech_HO, /* o : SC-VBR NB speech HO flag */
Word16 *snr_sum_he, /* o : Output snr_sum as weighted spectral measure*/
Word16 *localVAD_HE_SAD,
Word16 *flag_noisy_speech_snr, /* o : */
- const Word16 Q_new, /* i : scaling factor Q0 */
VAD_HANDLE hVAD, /* i/o: VAD data handle */
NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */
Word16 lp_speech, /* i : long term active speech energy average */
Word16 lp_noise /* i : long term noise energy */
);
-Word32 construct_snr_thresh_fx( Word16 sp_center[], /*(i) spectral center*/
- Word32 snr_flux, /*(i) snr flux*/
- Word32 lt_snr, /*(i) long time time domain snr*/
- Word32 l_snr, /*(i) long time frequency domain snr*/
- Word32 continuous_speech_num, /*(i) amount of continuous speech frames*/
- Word16 continuous_noise_num, /*(i) amount of continuous noise frames*/
- Word32 fg_energy_est_start, /*(i) whether if estimated energy*/
- Word16 bw_index /*(i) band width index*/
+Word32 construct_snr_thresh_fx( Word16 sp_center[], /*(i) spectral center Q10*/
+ Word32 snr_flux, /*(i) snr flux Q25*/
+ Word32 lt_snr, /*(i) long time time domain snr Q25*/
+ Word32 l_snr, /*(i) long time frequency domain snr Q25*/
+ Word32 continuous_speech_num, /*(i) amount of continuous speech frames Q0*/
+ Word16 continuous_noise_num, /*(i) amount of continuous noise frames Q0*/
+ Word32 fg_energy_est_start, /*(i) whether if estimated energy Q0*/
+ Word16 bw_index /*(i) band width index Q0*/
);
void sc_vbr_enc_init_fx(
@@ -831,8 +851,8 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX)
#endif
);
-Word16 E_ACELP_indexing_fx( const Word16 code[], const PulseConfig *config, Word16 num_tracks, Word16 prm[] );
-void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num );
+Word16 E_ACELP_indexing_fx( const Word16 code[] /*Q9*/, const PulseConfig *config, Word16 num_tracks /*Q0*/, Word16 prm[] /*Q(shift_bits)*/ );
+void fcb_pulse_track_joint_fx( UWord16 *idxs /*Q0*/, Word16 wordcnt /*Q0*/, UWord32 *index_n /*Q0*/, Word16 *pulse_num /*Q0*/, Word16 track_num /*Q0*/ );
Word16 gain_quant_fx( /* o: quantization index */
Word32 *gain, /* i/o: quantized gain */
@@ -933,7 +953,15 @@ void norm_corr_fx(
Word16 ncorr[], /* o : normalized correlation Q15 */
const Word16 L_subfr /* i : subframe size */
);
-
+void norm_corr_ivas_fx(
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t_min, /* i : minimum value of searched range */
+ const Word16 t_max, /* i : maximum value of searched range */
+ Word16 ncorr[], /* o : normalized correlation Q15 */
+ const Word16 L_subfr /* i : subframe size */
+);
Word16 peak_avrg_ratio_fx(
const Word32 total_brate,
const Word32 *input_hi_fx, /* i : i signal */
@@ -995,6 +1023,20 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag
const Word16 L_frame, /* i : length of the frame */
const Word16 L_subfr /* i : size of subframe */
);
+Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t0_min, /* i : minimum value in the searched range. Q0*/
+ const Word16 t0_max, /* i : maximum value in the searched range. Q0*/
+ Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */
+ const Word16 i_subfr, /* i : flag to first subframe */
+ const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */
+ const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */
+ const Word16 t0_fr1, /* i : minimum value for resolution 1 */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 L_subfr /* i : size of subframe */
+);
void pit_Q_enc_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
@@ -1141,20 +1183,20 @@ void GSC_enc_init_fx(
);
void td_cng_enc_init_fx(
TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */
- const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation */
- const Word16 max_bwidth /* i : maximum encoded bandwidth */
+ const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/
+ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/
);
void td_cng_enc_init_ivas_fx(
TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */
- const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation */
- const Word16 max_bwidth /* i : maximum encoded bandwidth */
+ const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/
+ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/
);
void dtx_enc_init_fx(
Encoder_State *st, /* i : Encoder state handle */
- const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */
- const Word16 interval_SID /* i : interval for SID update */
+ const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate Q0*/
+ const Word16 interval_SID /* i : interval for SID update Q0*/
);
void select_TC_fx(
const Word16 codec_mode, /* i : codec mode */
@@ -1247,7 +1289,8 @@ void AnalyzePowerSpectrum_ivas_fx(
Word16 mdctSpectrum_e,
Word16 const signal[], /* i : windowed signal corresponding to mdctSpectrum */
Word32 powerSpec[], /* o : Power spectrum. Can point to signal */
- Word16 *powerSpec_e );
+ Word16 powerSpec_e[] );
+
void AdaptLowFreqEmph_fx( Word32 x[],
Word16 x_e,
Word16 xq[],
@@ -1264,6 +1307,13 @@ Word16 SQ_gain_fx( /* o : SQ gain */
Word16 lg, /* i : vector size (2048 max) */
Word16 *gain_e ); /* o : SQ gain exponent */
+Word16 SQ_gain_ivas_fx( /* o : SQ gain */
+ Word32 x[], /* i : vector to quantize */
+ Word16 x_e, /* i : exponent */
+ Word16 nbitsSQ, /* i : number of bits targeted */
+ Word16 lg, /* i : vector size (2048 max) */
+ Word16 *gain_e ); /* o : SQ gain exponent */
+
Word16 SQ_gain_estimate_fx( /* o : SQ gain */
Word32 x[], /* i : vector to quantize */
Word16 x_e, /* i : exponent */
@@ -1456,34 +1506,34 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec,
void lpc_quantization_fx(
Encoder_State *st,
- const Word16 lsp[],
- const Word16 lspmid[],
- Word16 lsp_q[],
- Word16 lsf_q[], /* 14Q1*1.28 */
- Word16 lspmid_q[],
- Word16 lspq_ind[],
- Word16 clip_var[],
- const Word16 coder_type,
- const Word16 acelp_midLpc,
- Word16 param_lpc[],
- Word16 nbits_lpc[],
- Word16 *bits_param_lpc,
- Word16 *no_param_lpc,
+ const Word16 lsp[], /* Q15 */
+ const Word16 lspmid[], /* Q15 */
+ Word16 lsp_q[], /* Q15 */
+ Word16 lsf_q[], /* 14Q1*1.28 */
+ Word16 lspmid_q[], /* Q15 */
+ Word16 lspq_ind[], /* Q15 */
+ Word16 clip_var[], /* [2.56x,Q14,Q8,Q0,Q14,Q14] */
+ const Word16 coder_type, /* Q0 */
+ const Word16 acelp_midLpc, /* Q0 */
+ Word16 param_lpc[], /* Q0 */
+ Word16 nbits_lpc[], /* Q0 */
+ Word16 *bits_param_lpc, /* Q0 */
+ Word16 *no_param_lpc, /* Q0 */
const Word16 Q_ener );
void lpc_quantization_ivas_fx(
Encoder_State *st,
- const Word16 lsp[], /* Q15 */
- const Word16 lspmid[], /* Q15 */
- Word16 lsp_q[], /* Q15 */
- Word16 lsf_q[], /* 14Q1*1.28 */
- Word16 lspmid_q[], /* Q15 */
- const Word16 coder_type,
- const Word16 acelp_midLpc,
- Word16 param_lpc[],
- Word16 nbits_lpc[],
- Word16 *bits_param_lpc,
- Word16 *no_param_lpc,
+ const Word16 lsp[], /* Q15 */
+ const Word16 lspmid[], /* Q15 */
+ Word16 lsp_q[], /* Q15 */
+ Word16 lsf_q[], /* 14Q1*1.28 */
+ Word16 lspmid_q[], /* Q15 */
+ const Word16 coder_type, /* Q0 */
+ const Word16 acelp_midLpc, /* Q0 */
+ Word16 param_lpc[], /* Q0 */
+ Word16 nbits_lpc[], /* Q0 */
+ Word16 *bits_param_lpc, /* Q0 */
+ Word16 *no_param_lpc, /* Q0 */
const Word16 Q_ener );
void Mode2_pit_encode_fx(
@@ -1507,15 +1557,15 @@ void Mode2_pit_encode_fx(
Word16 pit_fr2,
Word16 pit_max,
Word16 pit_res_max );
-void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word16 code[], const PulseConfig *config, Word16 ind[], Word16 y[] );
+void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ );
void E_ACELP_4t_fx(
- Word16 dn[],
+ Word16 dn[], /* Qdn */
Word16 cn[] /* Q_xn */,
- Word16 H[],
- Word16 R[],
+ Word16 H[], /* Q12 */
+ Word16 R[], /* Qx */
Word8 acelpautoc,
- Word16 code[],
+ Word16 code[], /* Q9 */
Word16 cdk_index,
Word16 _index[],
const Word16 L_frame,
@@ -1525,12 +1575,12 @@ void E_ACELP_4t_fx(
const Word16 cmpl_flag );
void E_ACELP_4t_ivas_fx(
- Word16 dn[],
+ Word16 dn[], /* Qdn */
Word16 cn[] /* Q_xn */,
- Word16 H[],
- Word16 R[],
+ Word16 H[], /* Q12 */
+ Word16 R[], /* Qx */
Word8 acelpautoc,
- Word16 code[],
+ Word16 code[], /* Q9 */
Word16 cdk_index,
Word16 _index[],
const Word16 L_frame,
@@ -1567,8 +1617,9 @@ void E_ACELP_innovative_codebook_fx(
void CalculateTnsFilt_fx(
STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */
const Word32 pSpectrum[], /* i : MDCT spectrum Qx*/
- STnsData *pTnsData, /* o : TNS data struct */
- Word16 *predictionGain /* o : TNS prediction gain Q7*/
+ const Word16 pSpectrum_e,
+ STnsData *pTnsData, /* o : TNS data struct */
+ Word16 *predictionGain /* o : TNS prediction gain Q7*/
);
/** Detect TNS parameters.
@@ -1647,7 +1698,13 @@ void subband_FFT_fx(
Word32 Offset, /*(i) offset of the CLDFB*/
Word16 *fftoQ /*(o) the Scaling */
);
-Word16 E_ACELP_toeplitz_mul_fx( const Word16 R[], const Word16 c[], Word16 d[], const Word16 L_subfr, const Word16 highrate );
+Word16 E_ACELP_toeplitz_mul_fx(
+ const Word16 R[], /* Q9 */
+ const Word16 c[], /* Qx */
+ Word16 d[], /* exp(j) */
+ const Word16 L_subfr, /* Q0 */
+ const Word16 highrate /* Q0 */
+);
Word16 E_ACELP_code43bit_fx( const Word16 code[], UWord32 *ps, Word16 *p, UWord16 idxs[] );
void tc_classif_enc_fx(
const Word16 Q_new, /* i : scaling factor */
@@ -1697,21 +1754,22 @@ void ari_copy_states_fx(
TastatEnc *dest );
Word16 ari_encode_14bits_ext_fx(
- Word16 *ptr,
- Word16 bp,
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
TastatEnc *s,
- Word32 symbol,
- UWord16 const *cum_freq );
+ Word32 symbol, /* Q0 */
+ UWord16 const *cum_freq /* Q0 */
+);
Word16 ari_put_bit_plus_follow(
- Word16 ptr[], /* o: bit-stream */
- Word16 bp, /* i: bit-stream position */
- Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' */
- Word16 bit /* i: bit to send */
+ Word16 ptr[], /* o: bit-stream Q0*/
+ Word16 bp, /* i: bit-stream position Q0*/
+ Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' Q0*/
+ Word16 bit /* i: bit to send Q0*/
);
Word16 ari_done_encoding_14bits_fx(
- Word16 *ptr,
- Word16 bp,
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
TastatEnc *s );
void reset_rf_indices_fx(
@@ -1756,22 +1814,22 @@ void generate_comfort_noise_enc_fx( Encoder_State *stcod,
Word16 gen_exc );
Word16 cng_energy_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 bwidth, /* i : audio bandwidh */
- const Word16 CNG_mode, /* i : mode for DTX configuration */
- const Word16 CNG_att, /* i : attenuation factor for CNG */
- const Word16 *exc, /* i : i signal */
- const Word16 len, /* i : vector length */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 bwidth, /* i : audio bandwidh Q0*/
+ const Word16 CNG_mode, /* i : mode for DTX configuration Q0*/
+ const Word16 CNG_att, /* i : attenuation factor for CNG Q7*/
+ const Word16 *exc, /* i : input signal Q_new*/
+ const Word16 len, /* i : vector length Q0*/
const Word16 Q_new /* i : Input scaling */
);
void CNG_reset_enc_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- LPD_state_HANDLE hLPDmemm, /* i/o: acelp memories */
- Word16 *pitch_buf, /* o : floating pitch for each subframe */
- Word16 *voice_factors /* o : voicing factors */
- ,
- Word16 VBR_cng_reset_flag );
+ Encoder_State *st_fx, /* i/o: encoder state structure */
+ LPD_state_HANDLE hLPDmem, /* i/o: acelp memories */
+ Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 VBR_cng_reset_flag /* Q0 */
+);
void lsf_enc_fx(
Encoder_State *st_fx, /* i/o: state structure */
@@ -1798,86 +1856,97 @@ void lsf_enc_ivas_fx(
const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
const Word16 Q_new );
void Es_pred_enc_fx(
- Word16 *Es_pred, /* o : predicited scaled innovation energy Q8 */
- Word16 *indice, /* o : indice of quantization */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 *res, /* i : residual signal */
- const Word16 *voicing, /* i : normalized correlation in three 1/2frames */
- const Word16 nb_bits, /* i : allocated number of bits */
- const Word16 no_ltp, /* i : no_ltp flag */
- Word16 Q_new /* i : Scaling in speech Q0 */
+ Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/
+ Word16 *indice, /* o : indice of quantization Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ const Word16 *voicing, /* i : normalized correlation in three 1/2frames Q15*/
+ const Word16 nb_bits, /* i : allocated number of bits Q0*/
+ const Word16 no_ltp, /* i : no_ltp flag Q0*/
+ Word16 Q_new /* i : Scaling in speech Q0*/
);
void encod_nelp_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : i speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* o : residual signal */
- Word16 *synth_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : input speech Q_new-1*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ Word16 *res_fx, /* o : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift
);
void encod_nelp_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* o : residual signal */
- Word16 *synth_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ Encoder_State *st_fx, /* i/o: state structure */
+ const Word16 *speech_fx,
+ /* i : input speech */ /* Q_new-1 */
+ const Word16 Aw_fx[],
+ /* i : weighted A(z) unquantized for subframes */ /*exp(norm_s(Aw_fx[0])+1)*/
+ const Word16 Aq_fx[],
+ /* i : 12k8 Lp coefficient */ /*exp(norm_s(Aw_fx[0])+1)*/
+ Word16 *res_fx,
+ /* o : residual signal */ /* Q_new */
+ Word16 *synth_fx,
+ /* o : core synthesis */ /* Q_new */
+ Word16 *tmp_noise_fx,
+ /* o : long-term noise energy */ /* Q8 */
+ Word16 *exc_fx,
+ /* i/o: current non-enhanced excitation */ /* Q_new */
+ Word16 *exc2_fx,
+ /* i/o: current enhanced excitation */ /* Q_new */
+ Word16 *pitch_buf_fx,
+ /* o : floating pitch values for each subframe */ /* Q6 */
+ Word16 *voice_factors_fx,
+ /* o : voicing factors */ /* Q15 */
+ Word16 *bwe_exc_fx,
+ /* o : excitation for SWB TBE */ /* Q_new */
Word16 Q_new,
Word16 shift );
Word16 encod_tran_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : i speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
- Word16 tc_subfr, /* i/o: TC subframe classification */
- Word16 position, /* i : maximum of residual signal index */
- Word16 *unbits, /* i/o: number of unused bits */
- const Word16 shift, /* i : Scaling to get 12 bits */
- const Word16 Q_new /* i : Input scaling */
+ Encoder_State *st_fx, /* i/o: state structure */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
+ Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
+ Word16 position, /* i : maximum of residual signal index Q0*/
+ Word16 *unbits, /* i/o: number of unused bits Q0*/
+ const Word16 shift, /* i : Scaling to get 12 bits */
+ const Word16 Q_new /* i : Input scaling */
);
Word16 encod_tran_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
- Word16 tc_subfr, /* i/o: TC subframe classification */
- Word16 position, /* i : maximum of residual signal index */
- Word16 *unbits, /* i/o: number of unused bits */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
+ Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
+ Word16 position, /* i : maximum of residual signal index Q0*/
+ Word16 *unbits, /* i/o: number of unused bits Q0*/
const Word16 shift, /* i : Scaling to get 12 bits */
const Word16 Q_new /* i : Input scaling */
);
@@ -1887,61 +1956,66 @@ void deleteFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc );
void coder_acelp_rf_fx(
ACELP_config *acelp_cfg_rf, /*i /o : configuration of the ACELP coding*/
- const Word16 coder_type, /* i : coding type */
- const Word16 A[], /* i : coefficients 4xAz[M+1] */
- const Word16 Aq[], /* i : coefficients 4xAz_q[M+1] */
- Word16 speech[], /* i : speech[-M..lg] */
- const Word16 voicing[], /* i : open-loop LTP gain */
- const Word16 T_op[], /* i : open-loop LTP lag */
- Word16 stab_fac,
+ const Word16 coder_type, /* input: coding type Q0*/
+ const Word16 A[], /* input: coefficients 4xAz[M+1] Q12*/
+ const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] Q12*/
+ Word16 speech[], /* input: speech[-M..lg] Q_new-1*/
+ const Word16 voicing[], /* input: open-loop LTP gain Q15*/
+ const Word16 T_op[], /* input: open-loop LTP lag Q0*/
+ Word16 stab_fac, /* Q15 */
Encoder_State *st,
- Word16 target_bits, /* i/o : coder memory state */
- const Word16 rf_frame_type, /* i : rf_frame_type */
- Word16 *exc_rf, /* i/o: pointer to RF excitation */
- Word16 *syn_rf, /* i/o: pointer to RF synthesis */
+ Word16 target_bits, /* i/o : coder memory state Q0*/
+ const Word16 rf_frame_type, /* i : rf_frame_type Q0*/
+ Word16 *exc_rf, /* i/o: pointer to RF excitation Q_new*/
+ Word16 *syn_rf, /* i/o: pointer to RF synthesis Q_new-1*/
Word16 Q_new,
Word16 shift );
/* Create an instance of type FD_CNG */
void createFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc );
-void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale );
+void initFdCngEnc_fx(
+ HANDLE_FD_CNG_ENC hsEnc,
+ Word32 input_Fs, /* Q0 */
+ Word16 scale );
/* Configure CLDFB-CNG */
void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hs, /* i/o: Contains the variables related to the CLDFB-based CNG process */
- Word16 bandwidth, /* i: bandwidth */
- Word32 bitrate );
+ Word16 bandwidth, /* i: bandwidth Q0*/
+ Word32 bitrate /* Q0 */
+);
/* Perform noise estimation */
void perform_noise_estimation_enc_fx(
- Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */
+ Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN exp_band_energies*/
Word16 exp_band_energies,
- Word32 *enerBuffer,
+ Word32 *enerBuffer, /* enerBuffer_exp */
Word16 enerBuffer_exp,
HANDLE_FD_CNG_ENC st ); /* i/o: FD_CNG structure containing all buffers and variables */
void perform_noise_estimation_enc_ivas_fx(
- Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */
+ Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/
Word16 band_energies_exp,
- Word32 *enerBuffer,
+ Word32 *enerBuffer, /* enerBuffer_exp */
Word16 enerBuffer_exp,
HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */
- const Word32 input_Fs, /* i : input sampling rate */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */
);
/* Adjust the noise estimator at the beginning of each CNG phase (encoder-side) */
-Word16
-AdjustFirstSID_fx( Word16 npart,
- Word32 *msPeriodog,
- Word16 msPeriodog_exp,
- Word32 *energy_ho,
- Word16 *energy_ho_exp,
- Word32 *msNoiseEst,
- Word16 *msNoiseEst_exp,
- Word32 *msNoiseEst_old,
- Word16 *msNoiseEst_old_exp,
- Word16 *active_frame_counter,
- Encoder_State *stcod );
+Word16 AdjustFirstSID_fx(
+ Word16 npart, /* i : number of parts Q0*/
+ Word32 *msPeriodog, /* i : pointer to periodog vector msPeriodog_exp */
+ Word16 msPeriodog_exp, /* i : exponent of periodog vector */
+ Word32 *energy_ho, /* i/o : pointer to energy energy_ho_exp*/
+ Word16 *energy_ho_exp, /* i/o : pointer to exponent of energy */
+ Word32 *msNoiseEst, /* i/o : pointer to estimated noise msNoiseEst_exp*/
+ Word16 *msNoiseEst_exp, /* i/o : pointer to exponent of estimated noise */
+ Word32 *msNoiseEst_old, /* i/o : pointer to old estimated noise msNoiseEst_old_exp*/
+ Word16 *msNoiseEst_old_exp, /* i/o : pointer to exponent of old estimated noise */
+ Word16 *active_frame_counter, /* i/o : pointer to active frame counter Q0*/
+ Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */
+);
void FdCng_encodeSID_ivas_fx(
Encoder_State *st /* i/o: encoder state structure */
@@ -1951,113 +2025,113 @@ void resetFdCngEnc_fx( Encoder_State *st );
void encod_unvoiced_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : Input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
const Word16 Q_new,
const Word16 shift );
void encod_unvoiced_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : Input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
const Word16 Q_new,
const Word16 shift );
void enc_acelp_tcx_main_fx(
- const Word16 new_samples[], /* i : new samples */
- Encoder_State *st, /* i/o: encoder state structure */
- Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 lsp_new[M], /* i : LSPs at the end of the frame */
- const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame */
- Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 pitch_buf[], /* o : floating pitch for each subframe */
- Word16 vad_hover_flag, /* i : VAD hangover flag */
+ const Word16 new_samples[], /* i : new samples Q15*/
+ Encoder_State *st, /* i/o: encoder state structure */
+ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
+ const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame Q15*/
+ Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q_new*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 pitch_buf[], /* o : floating pitch for each subframe Q6*/
+ Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
Word16 *Q_new,
Word16 *shift );
ivas_error encod_ppp_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : i speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 speech_fx[], /* i : input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q14*/
+ Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q-1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift );
ivas_error encod_ppp_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 speech_fx[], /* i : input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q-1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift );
void encod_gen_voic_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : i speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits_fx, /* i/o: number of unused bits */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 speech_fx[], /* i : i speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
+ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 shift,
Word16 Q_new );
void encod_gen_voic_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits_fx, /* i/o: number of unused bits */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
+ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 shift,
Word16 Q_new );
@@ -2141,46 +2215,31 @@ void analy_sp_fx(
Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN */
Word16 *fft_buff /* o : FFT coefficients */
);
-void ivas_analy_sp_fx(
- const Word16 element_mode, /* i : element mode */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
- Word16 *speech, /* i : speech buffer Q_new - preemph_bits */
- const Word16 Q_new, /* i : current scaling exp Q0 */
- Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */
- Word32 *lf_E, /* o : per bin E for first... Q_new + QSCALE - 2*/
- Word16 *Etot, /* o : total input energy Q8 */
- const Word16 min_band, /* i : minimum critical band Q0 */
- const Word16 max_band, /* i : maximum critical band Q0 */
- const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE */
- Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */
- Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */
- Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
- Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE */
- Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */
- Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE + 2)*/
- Word16 *fft_buff /* o : FFT coefficients (Q_new + QSCALE + 2) */
-);
-void ivas_analy_sp_fx_front(
+void ivas_analy_sp_fx(
const Word16 element_mode, /* i : element mode */
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
const Word32 input_Fs, /* i : input sampling rate */
Word16 *speech, /* i : speech buffer Q_new - preemph_bits */
const Word16 Q_new, /* i : current scaling exp Q0 */
- Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */
- Word32 *lf_E, /* o : per bin E for first... Q_new + QSCALE - 2*/
+ Word32 *fr_bands, /* o : energy in critical frequency bands q_fr_bands */
+ Word16 *q_fr_bands, /* o : Q of energy in critical frequency bands Q0 */
+ Word32 *lf_E, /* o : per bin E for first... Q0 */
+ Word16 *q_lf_E, /* o : Q of per bin E for first... q_lf_E */
Word16 *Etot, /* o : total input energy Q8 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
- const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE */
- Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */
- Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */
- Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
- Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */
+ Word32 *Bin_E, /* o : per-bin energy spectrum q_Bin_E */
+ Word16 *q_Bin_E, /* o : Q of per-bin energy spectrum Q0 */
+ Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame q_Bin_E_old */
+ Word16 *q_Bin_E_old, /* o : Q of per-bin energy spectrum of the previous frame Q0 */
+ Word32 *PS, /* o : per-bin energy spectrum q_PS */
+ Word16 *q_PS, /* o : Q of per-bin energy spectrum Q0 */
Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */
- Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE)*/
- Word16 *fft_buff /* o : FFT coefficients (Q_new + Scale_fac[i_subfr]) */
+ Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (q_band_energies)*/
+ Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */
+ Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */
+ Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */
);
void find_wsp_fx(
const Word16 Az[],
@@ -2197,9 +2256,26 @@ void find_wsp_fx(
);
Word16 ari_encode_overflow_fx( TastatEnc *s );
-Word16 ari_encode_14bits_range_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 cum_freq_low, Word16 cum_freq_high );
-Word16 ari_encode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 sign );
-Word16 ari_done_cbr_encoding_14bits_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s );
+Word16 ari_encode_14bits_range_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word16 cum_freq_low, /* Q0 */
+ Word16 cum_freq_high /* Q0 */
+);
+Word16 ari_encode_14bits_sign_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word16 sign /* Q0 */
+);
+Word16 ari_done_cbr_encoding_14bits_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s );
void tcx_hm_analyse_fx(
const Word32 abs_spectrum[], /* i: absolute spectrum Q31-e */
@@ -2213,75 +2289,74 @@ void tcx_hm_analyse_fx(
const Word16 LtpGain, /* i: LTP gain Q15 */
Word16 *hm_bits_out /* o: bit consumption Q0 */
);
-void E_ACELP_4tsearchx_fx( Word16 dn[], const Word16 cn[], Word16 Rw[], Word16 code[], const PulseConfig *config, Word16 ind[] );
+void E_ACELP_4tsearchx_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_new*/, Word16 Rw[] /*Q9*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/ );
void E_ACELP_4tsearchx_ivas_fx(
- Word16 dn[],
- const Word16 cn[],
- Word16 Rw[],
- Word16 code[],
+ Word16 dn[], /*Qdn*/
+ const Word16 cn[], /*Q_new*/
+ Word16 Rw[], /*Q9*/
+ Word16 code[], /*Q9*/
const PulseConfig *config,
- Word16 ind[],
+ Word16 ind[], /*Q0*/
Word16 element_mode );
void E_ACELP_weighted_code(
- const Word16 code[], /* i: code */
- const Word16 H[], /* i: impulse response */
- Word16 Q, /* i: Q format of H */
- Word16 y[] /* o: weighted code */
+ const Word16 code[], /* i: code Q9*/
+ const Word16 H[], /* i: impulse response Q*/
+ Word16 Q, /* i: Q format of H */
+ Word16 y[] /* o: weighted code Q9*/
);
void find_targets_fx(
const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 i_subfr, /* i : subframe index Q0*/
Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization */
+ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15 */
+ Word16 tilt_fac, /* i : tilt factor Q15*/
Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
- Word16 *cn /* o : target vector in residual domain Q_new*/
- ,
- Word16 *h1 /* Q14 ?*/
+ Word16 *cn, /* o : target vector in residual domain Q_new*/
+ Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/
);
void find_targets_ivas_fx(
const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 i_subfr, /* i : subframe index Q0*/
Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization */
+ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15 */
+ Word16 tilt_fac, /* i : tilt factor Q15*/
Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
Word16 *cn, /* o : target vector in residual domain Q_new*/
- Word16 *h1 /* o : impulse response of weighted synthesis filter */
+ Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/
);
void E_ACELP_adaptive_codebook(
- Word16 *exc, /* i : pointer to the excitation frame */
- Word16 T0, /* i : integer pitch lag */
- Word16 T0_frac, /* i : fraction of lag */
- Word16 T0_res, /* i : pitch resolution */
- Word16 T0_res_max, /* i : maximum pitch resolution */
- Word16 mode, /* i : filtering mode (0: no, 1: yes, 2: adaptive) */
- Word16 i_subfr, /* i : subframe index */
- Word16 L_subfr, /* i : subframe length */
- Word16 L_frame, /* i : subframe length */
- Word16 *h1, /* i : impulse response of weighted synthesis filter */
- Word16 clip_gain,
- Word16 *xn, /* i : Close-loop Pitch search target vector */
- Word16 *y1, /* o : zero-memory filtered adaptive excitation */
+ Word16 *exc, /* i : pointer to the excitation frame Q_new */
+ Word16 T0, /* i : integer pitch lag Q0 */
+ Word16 T0_frac, /* i : fraction of lag Q0 */
+ Word16 T0_res, /* i : pitch resolution Q0 */
+ Word16 T0_res_max, /* i : maximum pitch resolution Q0 */
+ Word16 mode, /* i : filtering mode (0: no, 1: yes, 2: adaptive) Q0 */
+ Word16 i_subfr, /* i : subframe index */
+ Word16 L_subfr, /* i : subframe length Q0 */
+ Word16 L_frame, /* i : subframe length Q0 */
+ Word16 *h1, /* i : impulse response of weighted synthesis filter 1Q14+shift */
+ Word16 clip_gain, /* Q14 */
+ Word16 *xn, /* i : Close-loop Pitch search target vector Q_xn */
+ Word16 *y1, /* o : zero-memory filtered adaptive excitation Q_xn */
ACELP_CbkCorr *g_corr, /* o : ACELP correlation values */
Word16 **pt_indice, /* i/o: quantization indices pointer */
- Word16 *pitch_gain, /* o : adaptive codebook gain */
+ Word16 *pitch_gain, /* o : adaptive codebook gain 1Q14 */
Word16 exp_xn,
Word16 rf_mode,
Word16 use_prev_sf_pit_gain,
Word16 *lp_select );
-void E_ACELP_xy2_corr( Word16 xn[], Word16 y1[], Word16 y2[], ACELP_CbkCorr *g_corr, Word16 L_subfr, Word16 exp_xn );
+void E_ACELP_xy2_corr( Word16 xn[] /*Q_xn*/, Word16 y1[] /*Q_xn*/, Word16 y2[] /*Q9*/, ACELP_CbkCorr *g_corr, Word16 L_subfr /*Q0*/, Word16 exp_xn );
void gauss_L2_fx(
const Word16 h[], /* i : weighted LP filter impulse response Q14+s */
@@ -2325,12 +2400,12 @@ Word16 SearchPeriodicityIndex_fx(
);
Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
- const Word16 *x,
- Word16 nt,
- Word16 *lastnz,
- Word16 *nEncoded,
- Word16 target,
- Word16 *stop,
+ const Word16 *x, /* Q0 */
+ Word16 nt, /* Q0 */
+ Word16 *lastnz_out, /* Q0 */
+ Word16 *nEncoded, /* Q0 */
+ Word16 target, /* Q0 */
+ Word16 *stop, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg );
void tcx_arith_encode_envelope_fx(
@@ -2363,38 +2438,38 @@ void QuantizeGain( Word16 n, Word16 *pGain, Word16 *pGain_e, Word16 *pQuantizedG
void core_signal_analysis_high_bitrate_fx(
const Word16 *new_samples, /*i: 0Q15*/
- const Word16 T_op[3], /* i : open-loop pitch values for quantiz. */
- Word16 lsp_new[],
- Word16 lsp_mid[],
+ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/
+ Word16 lsp_new[], /* Q15 */
+ Word16 lsp_mid[], /* Q15 */
Encoder_State *st,
- Word16 pTnsSize[],
- Word16 pTnsBits[],
- Word16 param_core[],
- Word16 *ltpBits,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- const Word16 last_element_mode,
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- Word32 **spectrum,
+ Word16 pTnsSize[], /* Q0 */
+ Word16 pTnsBits[], /* Q0 */
+ Word16 param_core[], /* Q0 */
+ Word16 *ltpBits, /* Q0 */
+ const Word16 L_frame, /* Q0 */
+ const Word16 L_frameTCX, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ Word32 **spectrum, /* spectrum_e */
Word16 *spectrum_e,
Word16 *Q_new );
void core_signal_analysis_high_bitrate_ivas_fx(
const Word16 *new_samples, /*i: Q0 */
- const Word16 T_op[3], /* i : open-loop pitch values for quantiz. */
+ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/
Word16 lsp_new[], /* Q15 */
Word16 lsp_mid[], /* Q15 */
Encoder_State *st,
- Word16 pTnsSize[],
- Word16 pTnsBits[],
- Word16 param_core[],
- Word16 *ltpBits,
- Word32 *windowed_samples,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- const Word16 last_element_mode,
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- Word32 **spectrum,
+ Word16 pTnsSize[], /* Q0 */
+ Word16 pTnsBits[], /* Q0 */
+ Word16 param_core[], /* Q0 */
+ Word16 *ltpBits, /* Q0 */
+ Word32 *windowed_samples, /* q_win */
+ const Word16 L_frame, /* Q0 */
+ const Word16 L_frameTCX, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ Word32 **spectrum, /* exp(spectrum_e) */
Word16 *spectrum_e,
Word16 *Q_new,
Word16 *q_win );
@@ -2450,7 +2525,7 @@ void QuantizeTCXSpectrum_fx(
Encoder_State *st, /* i : state handle */
const Word16 frame_cnt, /* i : frame counter in the super_frame Q0 */
Word32 *x_orig_fx, /* i : shaped MDCT spectrum */
- const Word16 x_orig_e, /* i : exp of shaped MDCT spectrum */
+ Word16 x_orig_e, /* i : exp of shaped MDCT spectrum */
Word16 *gainlpc_fx, /* i : FDNS gains */
Word16 *gainlpc_e, /* i : exp of FDNS gains */
const Word16 *Aqind, /* i : frame-independent quantized coefficients (M+1) Q0 */
@@ -2572,9 +2647,9 @@ Word16 Q_lsf_tcxlpc_fx(
const Word32 *Bin_Ener,
const Word16 Q_ener );
-Word16 signalling_mode1_tcx20_enc(
+Word16 signalling_mode1_tcx20_enc_fx(
Encoder_State *st, /* i : encoder state structure */
- Word16 push );
+ Word16 push /*Q0*/ );
void coder_tcx_fx(
Word16 n,
@@ -2673,36 +2748,36 @@ void enc_prm_rf_fx(
void enc_prm_rf_ivas_fx( Encoder_State *st,
const Word16 rf_frame_type,
const Word16 fec_offset );
-void E_ACELP_pulsesign( const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sign[], Word16 vec[], const Word16 alp, Word16 const sign_val, const Word16 L_subfr );
+void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 dn2[] /*Qdn2*/, Word16 sign[] /*Q13*/, Word16 vec[] /*Q15*/, const Word16 alp /*Q13*/, Word16 const sign_val /*Q15*/, const Word16 L_subfr /*Q0*/ );
-void E_ACELP_findcandidates( Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[] );
+void E_ACELP_findcandidates( Word16 dn2[] /*Qx*/, Word16 dn2_pos[] /*Q0*/, Word16 pos_max[] /*Q0*/ );
void E_ACELP_setup_pulse_search_pos(
- const PulseConfig *config, /* i: pulse configuration */
- Word16 k, /* i: interation number */
- UWord8 ipos[] /* o: pulse search positions */
+ const PulseConfig *config, /* i: pulse configuration */
+ Word16 k, /* i: interation number Q0*/
+ UWord8 ipos[] /* o: pulse search positions Q0*/
);
void E_ACELP_build_code(
- Word16 nb_pulse, /* i */
- const Word16 codvec[], /* i */
- const Word16 sign[], /* i */
- Word16 code[], /* o */
- Word16 ind[] /* o */
+ Word16 nb_pulse, /* i Q0*/
+ const Word16 codvec[], /* i Q0*/
+ const Word16 sign[], /* i Q0*/
+ Word16 code[], /* o Q9*/
+ Word16 ind[] /* o Q0*/
);
void E_UTIL_f_convolve( const Word16 x[], const Word16 h[], Word16 y[], const Word16 size );
void E_ACELP_conv(
- const Word16 xn2[], /* i */
- const Word16 h2[], /* i */
- Word16 cn2[] /* o */
+ const Word16 xn2[], /* i Qx*/
+ const Word16 h2[], /* i Q12*/
+ Word16 cn2[] /* o Q0*/
);
-void E_ACELP_conv_ivas(
- const Word16 xn2[], /* i */
- const Word16 h2[], /* i */
- Word16 cn2[] /* o */
+void E_ACELP_conv_ivas_fx(
+ const Word16 xn2[], /* i Qx*/
+ const Word16 h2[], /* i Q12*/
+ Word16 cn2[] /* o Q0*/
);
void gPLC_encInfo_fx(
@@ -2772,18 +2847,18 @@ Word16 enc_lsf_tcxlpc_ivas_fx(
Word16 encode_lpc_avq_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 numlpc, /* i : Number of sets of lpc */
- const Word16 *param_lpc, /* i : lpc parameters */
- const Word16 core, /* i : core */
- const Word16 element_mode /* i : element mode - decides between SNS and LPC coding */
+ const Word16 numlpc, /* i : Number of sets of lpc Q0*/
+ const Word16 *param_lpc, /* i : lpc parameters Q0*/
+ const Word16 core, /* i : core Q0*/
+ const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/
);
Word16 encode_lpc_avq_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 numlpc, /* i : Number of sets of lpc */
- const Word16 *param_lpc, /* i : lpc parameters */
- const Word16 core, /* i : core */
- const Word16 element_mode /* i : element mode - decides between SNS and LPC coding */
+ const Word16 numlpc, /* i : Number of sets of lpc Q0*/
+ const Word16 *param_lpc, /* i : lpc parameters Q0*/
+ const Word16 core, /* i : core Q0*/
+ const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/
);
Word16 lsf_bctcvq_encprm_fx(
@@ -2826,11 +2901,11 @@ Word16 IGFEncWriteBitstream_fx( /**< ou
void ACcontextMapping_encode2_no_mem_s17_LC_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word16 *x,
- Word16 nt,
- Word16 lastnz,
- Word16 nbbits,
- Word16 resQMaxBits,
+ Word16 *x, /* Q0 */
+ Word16 nt, /* Q0 */
+ Word16 lastnz, /* Q0 */
+ Word16 nbbits, /* Q0 */
+ Word16 resQMaxBits, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg );
Word16 IGFEncWriteConcatenatedBitstream_fx( /**< out: Q0 | total number of bits written */
@@ -2845,7 +2920,7 @@ Word16 IGFEncWriteConcatenatedBitstream_ivas_fx(
void signaling_enc_rf_fx(
Encoder_State *st /* i : encoder state structure */
);
-void signalling_enc_rf(
+void signalling_enc_rf_fx(
Encoder_State *st /* i : encoder state structure */
);
@@ -2894,25 +2969,25 @@ void core_coder_mode_switch_fx(
const Word16 shift );
void corr_xh_fx(
- const Word16 x[], /* i : target signal */
- Word16 dn[], /* o : correlation between x[] and h[] */
- const Word16 h[] /* i : impulse response (of weighted synthesis filter) */
+ const Word16 x[], /* i : target signal Qx*/
+ Word16 dn[], /* o : correlation between x[] and h[] Qdn*/
+ const Word16 h[] /* i : impulse response (of weighted synthesis filter) Q14*/
);
void corr_hh_ivas_fx(
const Word16 *h, /* i : target signal e(norm_s(h1[0])+1) */
Word16 *y, /* o : correlation between x[] and h[] Q_new + 1 */
Word16 *Qy,
- const Word16 L_subfr /* i : length of the subframe */
+ const Word16 L_subfr /* i : length of the subframe Q0*/
);
void corr_xh_ivas_fx(
- const Word16 x[], /* i : target signal */
+ const Word16 x[], /* i : target signal Qx*/
const Word16 Qx,
- Word16 dn[], /* o : correlation between x[] and h[] */
+ Word16 dn[], /* o : correlation between x[] and h[] Qdn*/
Word16 *Qdn,
- const Word16 h[], /* i : impulse response (of weighted synthesis filter) */
- const Word16 L_subfr /* i : length of the subframe */
+ const Word16 h[], /* i : impulse response (of weighted synthesis filter) (Q15 - norm_s(h[0]))*/
+ const Word16 L_subfr /* i : length of the subframe Q0*/
);
void qlpc_avq_fx(
@@ -2920,11 +2995,11 @@ void qlpc_avq_fx(
const Word16 *lsfmid, /* i : Input LSF vectors (14Q1*1.28) */
Word16 *lsf_q, /* o : Quantized LFS vectors (14Q1*1.28) */
Word16 *lsfmid_q, /* o : Quantized LFS vectors (14Q1*1.28) */
- Word16 *index, /* o : Quantization indices */
- Word16 *nb_indices, /* o : Number of quantization indices */
- Word16 *nbbits, /* o : Number of quantization bits */
- const Word16 core, /* i : TCX10 or TCX20 */
- const Word32 sr_core /* i : internal sampling rate */
+ Word16 *index, /* o : Quantization indices Q0 */
+ Word16 *nb_indices, /* o : Number of quantization indices Q0 */
+ Word16 *nbbits, /* o : Number of quantization bits Q0 */
+ const Word16 core, /* i : TCX10 or TCX20 Q0 */
+ const Word32 sr_core /* i : internal sampling rate Q0 */
);
/* ivas_tcx_core_enc.c */
@@ -2973,7 +3048,7 @@ void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder st
Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */
Word16 e_mdct, /* i : exponent of pMDCTspectrum */
Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
- Word16 e_ps, /* i : exponent of pPowerSpectrum */
+ Word16 *e_ps, /* i : exponent of pPowerSpectrum */
const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
const int8_t isTNSActive, /* i : flag indicating if the TNS is active */
const int16_t sp_aud_decision0, /* i : first stage switching decision */
@@ -3032,33 +3107,32 @@ Word16 vad_proc_fx(
);
void calc_lf_snr_fx(
- Word32 *lf_snr_smooth, /* o : smoothed lf_snr*/
- Word32 *lf_snr, /* o : long time frequency domain
- SNR calculated by l_speech_snr and l_silence_snr*/
- const Word32 l_speech_snr, /* i : sum of active frames snr */
- const Word32 l_speech_snr_count, /* i : amount of the active frame */
- const Word32 l_silence_snr, /* i : sum of the nonactive frames snr*/
- const Word32 l_silence_snr_count, /* i : amount of the nonactive frame */
- const Word16 fg_energy_count, /* i : amount of the foreground energy frame */
- const Word16 bg_energy_count, /* i : amount of the background energy frame */
- const Word16 bw_index /* i : band width index*/
+ Word32 *lf_snr_smooth, /* o : smoothed lf_snr Q25*/
+ Word32 *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr Q25*/
+ const Word32 l_speech_snr, /* i : sum of active frames snr Q16*/
+ const Word32 l_speech_snr_count, /* i : amount of the active frame Q0*/
+ const Word32 l_silence_snr, /* i : sum of the nonactive frames snr Q16*/
+ const Word32 l_silence_snr_count, /* i : amount of the nonactive frame Q0*/
+ const Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/
+ const Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/
+ const Word16 bw_index /* i : band width index Q0*/
);
void calc_lt_snr_fx(
VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word32 *lt_snr_org_fp, /* o : original long time SNR*/
- Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy*/
- Word32 fg_energy, /* i : foreground energy sum */
- Word16 fg_energy_count, /* i : amount of the foreground energy frame */
- Word32 bg_energy, /* i : background energy sum */
- Word16 bg_energy_count, /* i : amount of the background energy frame */
- Word16 bw_index, /* i : band width index*/
- Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0*/
+ Word32 *lt_snr_org_fp, /* o : original long time SNR Q25*/
+ Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy Q25*/
+ Word32 fg_energy, /* i : foreground energy sum Qx*/
+ Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/
+ Word32 bg_energy, /* i : background energy sum Qx*/
+ Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/
+ Word16 bw_index, /* i : band width index Q0*/
+ Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0 Q10*/
);
-void calc_snr_flux_fx( Word32 tsnr_fix, /*(i) time-domain SNR*/
- Word32 *pre_snr, /*(io)time-domain SNR storage*/
- Word32 *snr_flux /*(o) average tsnr*/
+void calc_snr_flux_fx( Word32 tsnr_fix, /*(i) time-domain SNR Q25*/
+ Word32 *pre_snr, /*(io)time-domain SNR storage Q25*/
+ Word32 *snr_flux /*(o) average tsnr Q25*/
);
Word16 vlpc_2st_cod_fx( /* o : number of allocated bits */
@@ -3104,9 +3178,9 @@ void spec_flatness_fx( Word32 *spec_amp, /*(i) spectral amplitude*/
void SetModeIndex_fx(
Encoder_State *st,
- Word32 last_total_brate,
- const Word16 last_element_mode,
- const Word16 is_mct,
+ Word32 last_total_brate, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 is_mct, /* Q0 */
const Word16 shift );
void MDCT_selector_fx(
@@ -3165,39 +3239,40 @@ void IGFSCFEncoderRestoreContextState_fx(
);
void frame_spec_dif_cor_rate_fx(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word32 *spec_amp, /* i : spectral amplitude*/
- Word16 sacle, /* i : the scaling of spec_amp*/
- Word16 f_tonality_rate[3] /* o : tonality rate*/
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ Word32 *spec_amp, /* i : spectral amplitude scale*/
+ Word16 sacle, /* i : the scaling of spec_amp */
+ Word16 f_tonality_rate[3] /* o : tonality rate Qx*/
);
void est_energy_fx(
- Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band */
- Word16 enerBuffer_exp, /* i : exponent of energy vector */
- Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly*/
- Word32 *frame_energy2_p, /* o : frame energy 2*/
- Word32 *HB_Power_p, /* o : high frequency energy*/
- Word32 *frame_energy_p, /* o : frame energy 1*/
- Word16 *sb_power_Q, /* o : the scaling of sb_power*/
- Word16 *frame_energy2_Q, /* o : the scaling of frame_energy*/
- Word16 *HB_Power_Q, /* o : the scaling of HB_Power*/
- Word16 *frame_energy_Q, /* o : the Scaling of frame_energy*/
- Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[]*/
- const Word32 bandwidth /* i : band width*/
+ Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band enerBuffer_exp*/
+ Word16 enerBuffer_exp, /* i : exponent of energy vector */
+ Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly frame_sb_energy_scale*/
+ Word32 *frame_energy2_p, /* o : frame energy 2 frame_energy2_Q*/
+ Word32 *HB_Power_p, /* o : high frequency energy HB_Power_Q*/
+ Word32 *frame_energy_p, /* o : frame energy 1 frame_energy_Q*/
+ Word16 *sb_power_Q, /* o : the scaling of sb_power */
+ Word16 *frame_energy2_Q, /* o : the scaling of frame_energy */
+ Word16 *HB_Power_Q, /* o : the scaling of HB_Power */
+ Word16 *frame_energy_Q, /* o : the Scaling of frame_energy */
+ Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[] */
+ const Word32 bandwidth /* i : band width Q0*/
);
void background_update_fx(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word16 scale, /* i : the scaling of frame energy*/
- Word32 frame_energy, /* i : current frame energy*/
- Word32 update_flag, /* i : update flag*/
- Word16 music_backgound_f, /* i : background music flag*/
- Word32 snr );
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ Word16 scale, /* i : the scaling of frame energy */
+ Word32 frame_energy, /* i : current frame energy scale*/
+ Word32 update_flag, /* i : update flag Q0*/
+ Word16 music_backgound_f, /* i : background music flag Q0*/
+ Word32 snr /* Q25 */
+);
/* enc_gain.c */
-Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
- Word16 xn[],
- Word16 h[],
+Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/
+ Word16 xn[], /*Q_xn*/
+ Word16 h[], /* Q14+shift */
Word16 t0_min,
Word16 t0_min_frac,
Word16 t0_max,
@@ -3241,26 +3316,26 @@ void amr_wb_enc_init_fx(
);
void snr_calc(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- const Word16 sacle_sbpower, /* i : the Scaling of sbpower*/
- Word32 *snr, /* o : frequency domain SNR */
- Word32 *tsnr, /* o : time domain SNR */
- const Word32 frame_energy, /* i : current frame energy */
- const Word32 bwidth /* i : audio band width*/
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ const Word16 sacle_sbpower, /* i : the Scaling of sbpower */
+ Word32 *snr, /* o : frequency domain SNR Q25*/
+ Word32 *tsnr, /* o : time domain SNR Q25*/
+ const Word32 frame_energy, /* i : current frame energy sacle_sbpower*/
+ const Word32 bwidth /* i : audio band width Q0*/
);
void FEC_encode_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation */
- const Word16 coder_type, /* i : type of coder */
- Word16 clas, /* i : signal clas for current frame */
- const Word16 *fpit, /* i : close loop fractional pitch buffer */
- const Word16 *res, /* i : LP residual signal frame */
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse */
- const Word16 L_frame, /* i : Frame length */
- const Word32 total_brate, /* i : total codec bitrate */
- const Word16 Q_new, /* i : i scaling */
- const Word16 shift /* i : scaling to get 12bits */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
+ const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_synth*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ Word16 clas, /* i : signal clas for current frame Q0*/
+ const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
+ const Word16 *res, /* i : LP residual signal frame Qx*/
+ Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
+ const Word16 L_frame, /* i : Frame length Q0*/
+ const Word32 total_brate, /* i : total codec bitrate Q0*/
+ const Word16 Q_new, /* i : i scaling */
+ const Word16 shift /* i : scaling to get 12bits */
);
void updt_enc_fx(
@@ -3276,7 +3351,7 @@ void updt_enc_fx(
void dtx_hangover_control_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 lsp_new_fx[M] /* i : current frame LSPs */
+ const Word16 lsp_new_fx[M] /* i : current frame LSPs Q15*/
);
void update_average_rate_fx(
@@ -3414,44 +3489,44 @@ Word16 inov_encode_ivas_fx(
void gain_enc_mless_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 element_mode, /* i : element mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *xn, /* i : target vector */
- const Word16 *y1, /* i : zero-memory filtered adaptive excitation */
- const Word16 Q_xn, /* i : xn and y1 scaling */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word16 Es_pred, /* i : predicted scaled innovation energy */
- Word16 *gain_pit, /* o : quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 Q_xn, /* i : xn and y1 scaling */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/
);
void gain_enc_mless_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 element_mode, /* i : element mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *xn, /* i : target vector */
- const Word16 *y1, /* i : zero-memory filtered adaptive excitation */
- const Word16 Q_xn, /* i : xn and y1 scaling */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word16 Es_pred, /* i : predicted scaled innovation energy */
- Word16 *gain_pit, /* o : quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 Q_xn, /* i : xn and y1 scaling */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/
);
void updt_IO_switch_enc_fx(
Encoder_State *st, /* i/o: state structure */
@@ -3467,39 +3542,39 @@ void hf_cod_init_fx(
);
void analy_lp_AMR_WB_fx(
- const Word16 speech[], /* i : pointer to the speech frame */
- Word32 *ener, /* o : residual energy from Levinson-Durbin */
- Word16 A[], /* o : A(z) filter coefficients */
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
- Word16 isp_new[], /* o : current frame ISPs */
- Word16 isp_old[], /* i/o: previous frame unquantized ISPs */
- Word16 isf_new[], /* o : current frame ISPs */
- Word16 Top, /* i : open loop pitch lag */
- Word16 Tnc, /* i : open loop pitch gain */
+ const Word16 speech[], /* i : pointer to the speech frame Q_new*/
+ Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A[], /* o : A(z) filter coefficients Q14*/
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 isp_new[], /* o : current frame ISPs Q15*/
+ Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/
+ Word16 isf_new[], /* o : current frame ISPs Q15*/
+ Word16 Top, /* i : open loop pitch lag Q0*/
+ Word16 Tnc, /* i : open loop pitch gain Qx*/
Word16 Q_new,
Word16 *Q_r );
void encod_amr_wb_fx(
Encoder_State *st, /* i/o: state structure */
- const Word16 speech[], /* i : i speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 *res, /* i : residual signal */
- Word16 *syn, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *exc2, /* i/o: current enhanced excitation */
- Word16 *pitch_buf, /* i/o: floating pitch values for each subframe */
- Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */
- const Word16 *speech16k_fx, /* i : i speech @16kHz */
+ const Word16 speech[], /* i : i speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *syn, /* i/o: core synthesis st->Q_syn*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2, /* i/o: current enhanced excitation Q_new*/
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/
+ const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/
Word16 shift,
Word16 Q_new );
void re8_cod_fx(
- Word16 x[], /* i : point in RE8 (8-dimensional integer vector) */
- Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
- UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) */
- Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index */
+ Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/
+ Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/
+ UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/
+ Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/
);
void TBEreset_enc_fx(
@@ -3524,20 +3599,20 @@ void acelp_core_switch_enc_ivas_fx(
Word16 Q_new );
void gain_enc_amr_wb_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *xn, /* i : target vector */
- const Word16 Q_xn, /* i : xn and yy1 format Q0 */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word32 core_brate, /* i : core bitrate */
- Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- Word16 *past_qua_en /* i/o: gain quantization memory (4 words) */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 Q_xn, /* i : xn and yy1 format */
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/
);
@@ -3560,59 +3635,59 @@ void hf_cod_fx(
void transf_cdbk_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const Word16 i_subfr, /* i : subframe index */
- Word16 cn[], /* i/o: target vector in residual domain */
- Word16 exc[], /* i/o: pointer to excitation signal frame */
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 h1[], /* i : weighted filter i response */
- Word16 xn[], /* i/o: target vector */
- Word16 xn2[], /* i/o: target vector for innovation search */
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
- const Word16 y2[], /* i : zero-memory filtered innovative excitation */
- const Word16 Es_pred, /* i : predicited scaled innovation energy */
- Word16 *gain_pit, /* i/o: adaptive excitation gain */
- const Word32 gain_code, /* i : innovative excitation gain */
- Word16 g_corr[], /* o : ACELP correlation values */
- const Word16 clip_gain, /* i : adaptive gain clipping flag */
- Word16 *gain_preQ, /* o : prequantizer excitation gain */
- Word16 code_preQ[], /* o : prequantizer excitation */
- Word16 *unbits, /* o : number of AVQ unused bits */
+ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ Word16 cn[], /* i/o: target vector in residual domain Q_new*/
+ Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 h1[], /* i : weighted filter input response Q15*/
+ Word16 xn[], /* i/o: target vector Q_new + shift -1*/
+ Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
+ Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
+ const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
+ const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
+ Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
+ const Word32 gain_code, /* i : innovative excitation gain Q16*/
+ Word16 g_corr[], /* o : ACELP correlation values Q15*/
+ const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
+ Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
+ Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
+ Word16 *unbits, /* o : number of AVQ unused bits Q0*/
const Word16 Q_new, /* i : Current frame scaling */
const Word16 shift /* i : shifting applied to y1, xn,... */
);
void transf_cdbk_enc_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const Word16 i_subfr, /* i : subframe index */
- Word16 cn[], /* i/o: target vector in residual domain */
- Word16 exc[], /* i/o: pointer to excitation signal frame */
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 h1[], /* i : weighted filter input response */
- Word16 xn[], /* i/o: target vector */
- Word16 xn2[], /* i/o: target vector for innovation search */
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
- const Word16 y2[], /* i : zero-memory filtered innovative excitation */
- const Word16 Es_pred, /* i : predicited scaled innovation energy */
- Word16 *gain_pit, /* i/o: adaptive excitation gain */
- const Word32 gain_code, /* i : innovative excitation gain */
- Word16 g_corr[], /* o : ACELP correlation values */
- const Word16 clip_gain, /* i : adaptive gain clipping flag */
- Word16 *gain_preQ, /* o : prequantizer excitation gain */
- Word16 code_preQ[], /* o : prequantizer excitation */
- Word16 *unbits, /* o : number of AVQ unused bits */
+ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ Word16 cn[], /* i/o: target vector in residual domain Q_new*/
+ Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 h1[], /* i : weighted filter input response Q15*/
+ Word16 xn[], /* i/o: target vector Q_new + shift -1*/
+ Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
+ Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
+ const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
+ const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
+ Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
+ const Word32 gain_code, /* i : innovative excitation gain Q16*/
+ Word16 g_corr[], /* o : ACELP correlation values Q15*/
+ const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
+ Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
+ Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
+ Word16 *unbits, /* o : number of AVQ unused bits Q0*/
const Word16 Q_new, /* i : Current frame scaling */
const Word16 shift /* i : shifting applied to y1, xn,... */
);
void gain_enc_lbr_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 coder_type, /* i : coding type Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
const Word16 *xn, /* i : target vector Q_xn*/
const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
const Word16 Q_xn, /* i : xn and y1 format */
@@ -3623,17 +3698,17 @@ void gain_enc_lbr_fx(
Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const Word16 L_subfr /* i : subframe length */
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 L_subfr /* i : subframe length Q0*/
);
void gain_enc_lbr_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 coder_type, /* i : coding type Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
const Word16 *xn, /* i : target vector Q_xn*/
const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
const Word16 Q_xn, /* i : xn and y1 format */
@@ -3644,46 +3719,46 @@ void gain_enc_lbr_ivas_fx(
Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const int16_t L_subfr /* i : subframe length */
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 L_subfr /* i : subframe length Q0*/
);
void gain_enc_SQ_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *xn, /* i : target vector Q_xn */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9 */
- const Word16 *code, /* i : algebraic excitation Q9 */
- const Word16 Es_pred, /* i : predicted scaled innovation energy Q8 */
- Word16 *gain_pit, /* o : quantized pitch gain Q14 */
- Word32 *gain_code, /* o : quantized codebook gain Q16 */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12 */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16 */
- Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const Word16 Q_xn /* i : xn and y1 scaling */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
);
void gain_enc_SQ_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *xn, /* i : target vector Q_xn */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9 */
- const Word16 *code, /* i : algebraic excitation Q9 */
- const Word16 Es_pred, /* i : predicted scaled innovation energy Q8 */
- Word16 *gain_pit, /* o : quantized pitch gain Q14 */
- Word32 *gain_code, /* o : quantized codebook gain Q16 */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12 */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16 */
- Word16 *g_corr, /* i/o: correlations